Bug 159174

Summary: Main frame storage event never dispatched for localStorage/sessionStorage modifications
Product: WebKit Reporter: Joseph Pecoraro <joepeck>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: achristensen, andersca, beidson, jj, joepeck, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Joseph Pecoraro 2016-06-27 15:27:36 PDT
Summary:
Main frame storage event never dispatched for localStorage/sessionStorage modifications

Steps to Reproduce:
1. Inspect this page
2. js> window.onstorage = function(e) { console.log(e); }; localStorage.x = 123;
  => Expected console to log, it did not.

Notes:
- LayoutTests/storage/domstorage/events/basic.html shows that the storage event does fire for a subframe, but surprisingly it does not fire for the main frame
Comment 1 Radar WebKit Bug Importer 2016-06-27 15:28:07 PDT
<rdar://problem/27040485>
Comment 2 Joseph Pecoraro 2016-06-27 16:51:32 PDT
MDN says, about the Storage Event:
This won't work on the same page that is making the changes — it is really a way for other pages on the domain using the storage to sync any changes that are made.

So if that is the case, this is behaving correctly.
Comment 3 Joseph Pecoraro 2016-06-27 17:00:22 PDT
<https://html.spec.whatwg.org/multipage/webstorage.html#the-localstorage-attribute>

> When the setItem(), removeItem(), and clear() methods are called on a Storage object x
> that is associated with a local 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
> localStorage attribute's Storage object is associated with the same storage area,
> other than x, send a storage notification.

The operative words being "other than x".

Seems like this behaves correctly, closing.