User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.10 Safari/535.1 Build Identifier: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:2.0.1) Gecko/20100101 Firefox/4.0.1 If there are two windows open with pages on the same domain, localStorage.keys() won't include data written from the other page. Reproducible: Always Steps to Reproduce: 1. Open a window and call localStorage.clear() 2. Open another window and call localStorage.setItem( "a", "a" ) 3. Go back to the first page and call localStorage.key( 0 ); Actual Results: An error is thrown because the index is out of range. Expected Results: The key "a" should be returned. Accessing localStorage.length causes the keys to update.
I'll write a test for this to confirm.
The patch for this bug has been backed out from Aurora by https://hg.mozilla.org/releases/mozilla-aurora/rev/de96bbe87419 because of bug 683316. Fix for this bug and for bug 683316 too has been landed on mozilla-central. It will be merged to Aurora in some 5 days.
I'm still saying this same basic behaviour in 11.0a1. Has this landed yet? What I see is: 1. Open two different windows at http://trippingthebits.com/webstorage/test.html 2. Enter a local storage item in the 1st window. 3. Press dump button in the 1st window, item is shown. 3. Press dump button in the 2nd window, nothing. 4. Enter an item in the second window. 5. Press button in 2nd window, both items are shown.
I'm seeing something similar in Firefox 9.0.1. Turn on Private Mode and then create two tabs both in http://trippingthebits.com/webstorage/test.html Perform the following in the "local" section of the test page: In tab 1 save test1/1 and then dump. Test1 can be seen. In tab 2 hit dump. test1 is missing. In tab 2 save test2/2 and then dump. Test2 is seen, but test1 is still missing. In tab 1 hit dump. Test2 can be seen but test1 has gone!! In tab 1 save test3/3 and hit dump. Now all three are seen. In tab 2 hit dump. Only test 3 is seen. Slightly different, but still incorrect, behavior is seen with non-Private Mode.
This is a similar test in non-Private mode. Create two tabs, enable Firebug in those tabs, and then load the test page in both tabs. In tab 1 save test1/1 and then dump. Test1 can be seen. In tab 2, hit dump. Nothing is displayed. At Firebug command line prompt, enter localStorage.length. It's 1 !!! At Firebug command line prompt, enter localStorage.key(0). It shows test1 Hit DUMP again, still nothing. Why can Firebug commands see the contents of the localStorage but the JS code on the page can't?
Please ignore comment #8 and comment #9. While the problems I describe do occur when using the test page http://trippingthebits.com/webstorage/test.html, that page is not using localStorage directly (it's using a jQuery webStorage plugin). If I try the same tests on similar page which uses localStorage directly then everything behaves as expected.
Bug 715700 describes what appears to be a similar bug. However with 715700 the problem can only be seen in Private Mode and appears to have been introduced in Firefox 9.