- Revision
- 262058
- Author
- cdu...@apple.com
- Date
- 2020-05-22 08:17:10 -0700 (Fri, 22 May 2020)
Log Message
Regression(r254859) DOM storage event gets fired at the frame that caused the storage modification
https://bugs.webkit.org/show_bug.cgi?id=211503
<rdar://problem/62983284>
Reviewed by Maciej Stachowiak.
Source/WebKit:
r254859 refactored StorageAreaMap's dispatchSessionStorageEvent() &
dispatchLocalStorageEvent() to share more code by moving that code to
a new framesForEventDispatching() static function. However,
framesForEventDispatching() was always using the session storage no
matter the call site. It should be using the local storage when called
from dispatchLocalStorageEvent().
Test: storage/domstorage/events/storage-event-not-in-originator.html
* WebProcess/WebStorage/StorageAreaMap.cpp:
(WebKit::framesForEventDispatching):
(WebKit::StorageAreaMap::dispatchSessionStorageEvent):
(WebKit::StorageAreaMap::dispatchLocalStorageEvent):
LayoutTests:
Add layout test coverage.
* storage/domstorage/events/resources/storage-event-not-in-originator-frame.html: Added.
* storage/domstorage/events/storage-event-not-in-originator-expected.txt: Added.
* storage/domstorage/events/storage-event-not-in-originator.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (262057 => 262058)
--- trunk/LayoutTests/ChangeLog 2020-05-22 14:58:41 UTC (rev 262057)
+++ trunk/LayoutTests/ChangeLog 2020-05-22 15:17:10 UTC (rev 262058)
@@ -1,3 +1,17 @@
+2020-05-22 Chris Dumez <cdu...@apple.com>
+
+ Regression(r254859) DOM storage event gets fired at the frame that caused the storage modification
+ https://bugs.webkit.org/show_bug.cgi?id=211503
+ <rdar://problem/62983284>
+
+ Reviewed by Maciej Stachowiak.
+
+ Add layout test coverage.
+
+ * storage/domstorage/events/resources/storage-event-not-in-originator-frame.html: Added.
+ * storage/domstorage/events/storage-event-not-in-originator-expected.txt: Added.
+ * storage/domstorage/events/storage-event-not-in-originator.html: Added.
+
2020-05-22 Carlos Alberto Lopez Perez <clo...@igalia.com>
[css-grid] Update WPT imported tests and deduplicate common tests
Added: trunk/LayoutTests/storage/domstorage/events/resources/storage-event-not-in-originator-frame.html (0 => 262058)
--- trunk/LayoutTests/storage/domstorage/events/resources/storage-event-not-in-originator-frame.html (rev 0)
+++ trunk/LayoutTests/storage/domstorage/events/resources/storage-event-not-in-originator-frame.html 2020-05-22 15:17:10 UTC (rev 262058)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script>
+function storageEventHandler(e) {
+ top.childReceivedStorageEvent(e);
+}
+addEventListener("storage", storageEventHandler);
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/storage/domstorage/events/storage-event-not-in-originator-expected.txt (0 => 262058)
--- trunk/LayoutTests/storage/domstorage/events/storage-event-not-in-originator-expected.txt (rev 0)
+++ trunk/LayoutTests/storage/domstorage/events/storage-event-not-in-originator-expected.txt 2020-05-22 15:17:10 UTC (rev 262058)
@@ -0,0 +1,18 @@
+Tests that the storage event gets fired in other frames but not the originating one
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS sessionStorage.getItem(sessionStorageKey) is null
+PASS sessionStorageKey === localStorageKey is false
+PASS localStorage.getItem(localStorageKey) is null
+PASS Child frame received storage event.
+PASS event.newValue === expectedValue is true
+PASS Child frame received storage event.
+PASS event.newValue === expectedValue is true
+PASS topStorageEventCount is 0
+PASS childStorageEventCount is 2
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/storage/domstorage/events/storage-event-not-in-originator.html (0 => 262058)
--- trunk/LayoutTests/storage/domstorage/events/storage-event-not-in-originator.html (rev 0)
+++ trunk/LayoutTests/storage/domstorage/events/storage-event-not-in-originator.html 2020-05-22 15:17:10 UTC (rev 262058)
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that the storage event gets fired in other frames but not the originating one");
+jsTestIsAsync = true;
+
+function uuidv4()
+{
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
+ var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
+ return v.toString(16);
+ });
+}
+
+let topStorageEventCount = 0;
+let childStorageEventCount = 0;
+
+function childReceivedStorageEvent(e)
+{
+ event = e;
+ testPassed("Child frame received storage event.");
+ if (e.key === sessionStorageKey)
+ expectedValue = sessionStorageValue;
+ else
+ expectedValue = localStorageValue;
+ shouldBeTrue("event.newValue === expectedValue");
+
+ childStorageEventCount++;
+ if (childStorageEventCount == 2) {
+ setTimeout(() => {
+ shouldBe("topStorageEventCount", "0");
+ shouldBe("childStorageEventCount", "2");
+ finishJSTest();
+ }, 0);
+ }
+}
+
+function storageEventHandler(e) {
+ testFailed("Top frame received storage event.");
+ topStorageEventCount++;
+}
+addEventListener("storage", storageEventHandler);
+
+_onload_ = () => {
+ sessionStorageKey = uuidv4();
+ sessionStorageValue = "foo";
+ shouldBeNull("sessionStorage.getItem(sessionStorageKey)");
+ sessionStorage.setItem(sessionStorageKey, sessionStorageValue);
+
+ localStorageKey = uuidv4();
+ localStorageValue = "bar";
+ shouldBeFalse("sessionStorageKey === localStorageKey");
+ shouldBeNull("localStorage.getItem(localStorageKey)");
+ localStorage.setItem(localStorageKey, localStorageValue);
+}
+</script>
+<iframe src=""
+</body>
+</html>
Modified: trunk/Source/WebKit/ChangeLog (262057 => 262058)
--- trunk/Source/WebKit/ChangeLog 2020-05-22 14:58:41 UTC (rev 262057)
+++ trunk/Source/WebKit/ChangeLog 2020-05-22 15:17:10 UTC (rev 262058)
@@ -1,3 +1,25 @@
+2020-05-22 Chris Dumez <cdu...@apple.com>
+
+ Regression(r254859) DOM storage event gets fired at the frame that caused the storage modification
+ https://bugs.webkit.org/show_bug.cgi?id=211503
+ <rdar://problem/62983284>
+
+ Reviewed by Maciej Stachowiak.
+
+ r254859 refactored StorageAreaMap's dispatchSessionStorageEvent() &
+ dispatchLocalStorageEvent() to share more code by moving that code to
+ a new framesForEventDispatching() static function. However,
+ framesForEventDispatching() was always using the session storage no
+ matter the call site. It should be using the local storage when called
+ from dispatchLocalStorageEvent().
+
+ Test: storage/domstorage/events/storage-event-not-in-originator.html
+
+ * WebProcess/WebStorage/StorageAreaMap.cpp:
+ (WebKit::framesForEventDispatching):
+ (WebKit::StorageAreaMap::dispatchSessionStorageEvent):
+ (WebKit::StorageAreaMap::dispatchLocalStorageEvent):
+
2020-05-22 Tim Horton <timothy_hor...@apple.com>
REGRESSION (r261978): Cannot click on links with trackpad on iPad
Modified: trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp (262057 => 262058)
--- trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp 2020-05-22 14:58:41 UTC (rev 262057)
+++ trunk/Source/WebKit/WebProcess/WebStorage/StorageAreaMap.cpp 2020-05-22 15:17:10 UTC (rev 262058)
@@ -276,14 +276,28 @@
resetValues();
}
-static Vector<RefPtr<Frame>> framesForEventDispatching(Page& page, SecurityOrigin& origin, const Optional<StorageAreaImplIdentifier>& storageAreaImplID)
+static Vector<RefPtr<Frame>> framesForEventDispatching(Page& page, SecurityOrigin& origin, StorageType storageType, const Optional<StorageAreaImplIdentifier>& storageAreaImplID)
{
Vector<RefPtr<Frame>> frames;
page.forEachDocument([&](auto& document) {
if (!document.securityOrigin().equal(&origin))
return;
+
+ auto* window = document.domWindow();
+ if (!window)
+ return;
- auto* storage = document.domWindow() ? document.domWindow()->optionalSessionStorage() : nullptr;
+ Storage* storage = nullptr;
+ switch (storageType) {
+ case StorageType::Session:
+ storage = window->optionalSessionStorage();
+ break;
+ case StorageType::Local:
+ case StorageType::TransientLocal:
+ storage = window->optionalLocalStorage();
+ break;
+ }
+
if (!storage)
return;
@@ -311,7 +325,7 @@
if (!page)
return;
- auto frames = framesForEventDispatching(*page, m_securityOrigin, storageAreaImplID);
+ auto frames = framesForEventDispatching(*page, m_securityOrigin, StorageType::Session, storageAreaImplID);
StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
}
@@ -324,7 +338,7 @@
// Namespace IDs for local storage namespaces are equivalent to web page group IDs.
auto& pageGroup = *WebProcess::singleton().webPageGroup(m_namespace.pageGroupID())->corePageGroup();
for (auto* page : pageGroup.pages())
- frames.appendVector(framesForEventDispatching(*page, m_securityOrigin, storageAreaImplID));
+ frames.appendVector(framesForEventDispatching(*page, m_securityOrigin, StorageType::Local, storageAreaImplID));
StorageEventDispatcher::dispatchLocalStorageEventsToFrames(pageGroup, frames, key, oldValue, newValue, urlString, m_securityOrigin->data());
}