title: chrome.storage seems to lose state after switching back-and-forth between tabs
body: <p><strong>Background</strong></p>
  
  <p>I am currently building a chrome extension collects cookies for the active tab and stores these in chrome.storage.local as a JSON string (popup.html) before being redirected to a different popup (cookie_popup.html). The stored cookies are then used to populate a table to display the contents. This works fine as long as I do not switch between browser tabs, I can open- and close the popup (cookie_popup.html) as often as I want while getting the desired effect.</p>
  
  <p><strong>The problem</strong></p>
  
  <p>When I navigate to another tab the table is no longer populated and chrome.storage.local just returns an empty object. chrome.storage.local seemed to have cleared but <em>only</em> for the stored cookies, not any of the other states that I have stored. I hope somebody can help me understand why.</p>
  
  <p><strong>What I have tried</strong></p>
  
  <p>I have tried changing chrome.storage.local to chrome.storage.sync, nothing changed. I also made sure that the cookies were not accidentally set again upon loading a new tab.</p>
  
  <p><strong>The code</strong></p>
  
  <p>The tabHandler that sets cookies in storage (popup.html - only called on button press).</p>
  
  <pre class="lang-js prettyprint-override"><code>
      chrome.tabs.query({active: true, currentWindow: true}, tabHandler);
  
      function tabHandler(tabs) {
          chrome.cookies.getAll({url: tabs[0].url}, function(cookies) {
              chrome.storage.local.set({cookiejar: JSON.stringify(cookies)});
          });
      }
  
  </code></pre>
  
  <p>Populating the cookie table (cookie_popup.html).</p>
  
  <pre class="lang-js prettyprint-override"><code>
      chrome.storage.local.get('cookiejar', function(value) {
  
          try {
              let jar = JSON.parse(value.cookiejar);
              // ... Snipped ...
          } catch (e) {
              console.error(e);
              warningAlert.style = 'display: block;';
              warningAlert.innerText = 'Could not parse cookies; Please restart process.';
          }
      });
  
  </code></pre>
  
  <p>Whenever opening a different tab and opening the extension popup the JSON parsing fails because value.cookiejar is an empty object.</p>