title: Uncaught TypeError: Cannot read property 'local' of undefined in chrome extension
body: <p>I have written a Chrome extension. I cannot use 
  <code>localStorage.setItem</code> and <code>localStorage.getItem</code> for storing and retrieving because background and browser action runs in different environment [<a href="https://stackoverflow.com/questions/14008580/localstorage-returning-null-in-a-different-tab-in-chrome">as seen here</a>].</p>
  
  <p>So I decided to use the Chrome storage API:</p>
  
  <pre><code>var storage = chrome.storage.local;
  var myTestVar = 'somevar';
  var obj = {};
  obj[myTestVar] = $("#somevar").val();
  storage.set(obj);
  </code></pre>
  
  <p>which produced the following error:</p>
  
  <blockquote>
    <p>Uncaught TypeError: Cannot read property 'local' of undefined</p>
  </blockquote>
  
  <p>What am I doing wrong?</p>