Closed
Bug 1043106
Opened 10 years ago
Closed 10 years ago
event.storageArea === localStorage or === sessionStorage is always false
Categories
(Core :: DOM: Events, defect)
Tracking
()
RESOLVED
FIXED
mozilla34
People
(Reporter: grosser.meister.morti, Assigned: baku)
References
(Depends on 1 open bug, Blocks 1 open bug)
Details
(Keywords: reproducible, testcase)
Attachments
(2 files, 2 obsolete files)
7.15 KB,
patch
|
smaug
:
review+
|
Details | Diff | Splinter Review |
1.56 KB,
patch
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:30.0) Gecko/20100101 Firefox/30.0 (Beta/Release) Build ID: 20140611060104 Steps to reproduce: I registered a storage event listener and tried to filter out events that originate from the wrong storage area. Simplified code: window.addEventListener("storage", function (event) { if (event.storageArea !== localStorage) { return; } // handle event using event.key and event.newValue... }, false); Actual results: event.storageArea !== localStorage is always false. In fact comparing event.storageArea to localStorage or sessionStorage always fails. Expected results: event.storageArea !== localStorage should be false if the manipulated storageArea was in fact localStorage.
Updated•10 years ago
|
Status: UNCONFIRMED → NEW
Component: Untriaged → DOM: Events
Ever confirmed: true
Keywords: reproducible,
testcase
Product: Firefox → Core
Reporter | ||
Updated•10 years ago
|
Version: 30 Branch → 31 Branch
Reporter | ||
Comment 1•10 years ago
|
||
Just tested with Firefox 31: still the same. Here is an example: http://fiddle.jshell.net/AUzxP/3/show/ Open it in 2 windows, click the button in one of them and see the output in the other. Source: http://jsfiddle.net/AUzxP/3/
Assignee | ||
Updated•10 years ago
|
Assignee: nobody → amarchesini
Assignee | ||
Comment 2•10 years ago
|
||
I'm not sure this is correct from the spec point of view. I read: "When a user agent is to send a storage notification for a Document, the user agent must queue a task to fire a trusted event with the name storage, which does not bubble and is not cancelable, and which uses the StorageEvent interface, at the Document object's Window object. The storageArea attribute must return the value it was initialised to. When the object is created, this attribute must be initialised to null. It represents the Storage object that was affected." BTW: at the moment we emit 'storage' events only when another window changes the storage. I don't think this is correct. I didn't find this in the spec.
Attachment #8470784 -
Flags: review?(bugs)
Comment 3•10 years ago
|
||
As far as I know, it is correct to emit the events only in that case. IIRC we used to have the bug that we fired the event too often. But honza should know.
Comment 4•10 years ago
|
||
Comment on attachment 8470784 [details] [diff] [review] storageevent.patch >- dict.mStorageArea = aEvent->GetStorageArea(); >+ >+ nsRefPtr<DOMStorage> storageArea = aEvent->GetStorageArea(); >+ MOZ_ASSERT(storageArea); >+ >+ nsRefPtr<DOMStorage> storage; >+ if (storageArea->GetType() == DOMStorage::LocalStorage) { >+ storage = GetLocalStorage(aRv); >+ } else { >+ MOZ_ASSERT(storageArea->GetType() == DOMStorage::SessionStorage); >+ storage = GetSessionStorage(aRv); >+ } Can we somehow assert that the internal storage impl of 'storage' is the same as the internal storage impl of aEvent->GetStorageArea(). (Would like to see a patch with such change)
Attachment #8470784 -
Flags: review?(bugs)
Comment 5•10 years ago
|
||
http://dev.w3.org/html5/webstorage/#sessionStorageEvent 'When the setItem(), removeItem(), and clear() methods are called on a Storage object x that is associated with a session storage area, if the methods did not throw an exception or "do nothing" as defined above, then for every Document object whose Window object's sessionStorage attribute's Storage object is associated with the same storage area, other than x, send a storage notification.'
Assignee | ||
Comment 6•10 years ago
|
||
Attachment #8470784 -
Attachment is obsolete: true
Attachment #8470849 -
Flags: review?(bugs)
Comment 7•10 years ago
|
||
Comment on attachment 8470849 [details] [diff] [review] storageevent.patch >+ nsRefPtr<DOMStorage> storageArea = aEvent->GetStorageArea(); >+ MOZ_ASSERT(storageArea); >+ >+ nsRefPtr<DOMStorage> storage; >+ if (storageArea->GetType() == DOMStorage::LocalStorage) { >+ storage = GetLocalStorage(aRv); >+ } else { >+ MOZ_ASSERT(storageArea->GetType() == DOMStorage::SessionStorage); >+ storage = GetSessionStorage(aRv); >+ } >+ >+ if (aRv.Failed()) { >+ return nullptr; >+ } >+ >+ MOZ_ASSERT(storage); Based on the implementation of Get*Storage, they may return null, and not throw. So, you should just do if (!storage || aRv.Failed()) { return nullptr; }
Attachment #8470849 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 8•10 years ago
|
||
Pushed to try: https://tbpl.mozilla.org/?tree=Try&rev=a057410c33bd
OS: Linux → All
Hardware: x86_64 → All
Assignee | ||
Comment 9•10 years ago
|
||
Some mochitests in e10s fail. I'll debug this issue.
Assignee | ||
Comment 10•10 years ago
|
||
Attachment #8470849 -
Attachment is obsolete: true
Attachment #8472280 -
Flags: review?(bugs)
Comment 11•10 years ago
|
||
Comment on attachment 8472280 [details] [diff] [review] storageevent.patch Could you file a followup to clean up InnerSetNewDocument usage. It almost works for reuse case too.
Attachment #8472280 -
Flags: review?(bugs) → review+
Assignee | ||
Comment 12•10 years ago
|
||
https://tbpl.mozilla.org/?tree=Try&rev=63bd7560ca39 https://hg.mozilla.org/integration/mozilla-inbound/rev/c771f2431395
Comment 13•10 years ago
|
||
Oh, I just realized, we want + // The storage objects contain the URL of the window. We have to recreate + // them when the innerWindow is reused. + newInnerWindow->mLocalStorage = nullptr; + newInnerWindow->mSessionStorage = nullptr; only in case the document changes, to be safe.
Assignee | ||
Comment 14•10 years ago
|
||
https://hg.mozilla.org/integration/mozilla-inbound/rev/c2d008090340
Comment 15•10 years ago
|
||
https://hg.mozilla.org/mozilla-central/rev/c771f2431395 https://hg.mozilla.org/mozilla-central/rev/c2d008090340
Status: NEW → RESOLVED
Closed: 10 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla34
Comment 16•9 years ago
|
||
event.storageArea !== localStorage when a storage item was changed in a different tab, even if it is on the same page and using the same localStorage. Effectively this is still broken.
Comment 17•9 years ago
|
||
Ian, do you have a _minimal_ testcase for the issue you see? Could you file a new bug, and make it block this one. And add the testcase as an attachment to that bug. Thanks.
Flags: needinfo?(mozilla)
Comment 18•9 years ago
|
||
I'm actually only seeing a problem using the dom-storage2-changed notification. Using "storage" or "MozStorageChanged" directly is OK. I've raised bug 1192366 on the dom-storage2-changed glitch.
Flags: needinfo?(mozilla)
You need to log in
before you can comment on or make changes to this bug.
Description
•