title: localStorage unreliable in Firefox
body: <p>I'm working on a <a href="http://asmor.com/anr/" rel="noreferrer">deck building application</a> for a card game I play. I'm using localStorage to save and retrieve decks. It seems to be working flawlessly in Chrome, but in Firefox it is working unreliably.</p>
  
  <p>In FF, everything seems to work fine at first, the deck even persists through a reload. However, if I add a second deck and reload, it only finds the first deck. If I delete the first deck, it no longer finds anything.</p>
  
  <p>All the local storage interaction is in scripts/vault.js, which I'll reproduce below. Am I doing something wrong?</p>
  
  <pre><code>vault = {};
  vault.makeKey = function (s) {
      return "deck:" + s;
  };
  vault.friendlyName = function(s) {
      if (s.indexOf("deck:") === 0) {
          return s.substring(5);
      } else {
          return s;
      }
  };
  vault.store = function (deck, name) {
      if (!window.localStorage) {
          alert("This browser doesn't support local storage. You will be unable to save decks.");
          return;
      }
      var key = vault.makeKey(name);
      localStorage.setItem(key, deck.export());
  };
  vault.retrieve = function (key) {
      deck.import(localStorage[key]);
  };
  vault.getDecks = function () {
      var keys = Object.keys(localStorage),
          out = [],
          i,
          k,
          name = "";
      for (i = 0; i &lt; keys.length; i++) {
          k = keys[i];
          name = vault.friendlyName(k);
          if (name !== k &amp;&amp; localStorage[k]) {
              out.push({name: name, key: k});
          }
      }
      out.sort(function (a, b) {
          return a.name &gt; b.name ? 1 : -1;
      });
      return out;
  };
  vault.deleteDeck = function (key) {
      localStorage.removeItem(key);
  };
  </code></pre>
  
  <p>Basically, it seems like at some point the keys in localStorage get 'frozen' for lack of a better term; localStorage will behave correctly while I manipulate it, but as soon as I refresh the page it seems to revert to whichever state it got frozen in.</p>