Title: [202529] trunk
Revision
202529
Author
[email protected]
Date
2016-06-27 17:55:05 -0700 (Mon, 27 Jun 2016)

Log Message

Web Inspector: When modifying sessionStorage, localStorage gets updated
https://bugs.webkit.org/show_bug.cgi?id=159181
<rdar://problem/27043447>

Patch by Joseph Pecoraro <[email protected]> on 2016-06-27
Reviewed by Timothy Hatcher.

Source/WebInspectorUI:

* UserInterface/Test/Test.js:
(WebInspector.loaded):
Add registration for StorageManager and StorageObserver.

Source/WebKit2:

* WebProcess/Storage/StorageAreaMap.cpp:
(WebKit::StorageAreaMap::dispatchSessionStorageEvent):
This should be dispatching storage events.

LayoutTests:

* inspector/storage/domStorage-events-expected.txt: Added.
* inspector/storage/domStorage-events.html: Added.
Add a new test for DOMStorage domain events. Ensures that sessionStorage
and localStorage events are dispatched for the appropriate DOMStorageObject.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202528 => 202529)


--- trunk/LayoutTests/ChangeLog	2016-06-28 00:42:26 UTC (rev 202528)
+++ trunk/LayoutTests/ChangeLog	2016-06-28 00:55:05 UTC (rev 202529)
@@ -1,3 +1,16 @@
+2016-06-27  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: When modifying sessionStorage, localStorage gets updated
+        https://bugs.webkit.org/show_bug.cgi?id=159181
+        <rdar://problem/27043447>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/storage/domStorage-events-expected.txt: Added.
+        * inspector/storage/domStorage-events.html: Added.
+        Add a new test for DOMStorage domain events. Ensures that sessionStorage
+        and localStorage events are dispatched for the appropriate DOMStorageObject.
+
 2016-06-27  Myles C. Maxfield  <[email protected]>
 
         [Cocoa] Test gardening for the system font in macOS Sierra and iOS 10

Added: trunk/LayoutTests/inspector/storage/domStorage-events-expected.txt (0 => 202529)


--- trunk/LayoutTests/inspector/storage/domStorage-events-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/inspector/storage/domStorage-events-expected.txt	2016-06-28 00:55:05 UTC (rev 202529)
@@ -0,0 +1,36 @@
+Test for the DOMStorage events.
+
+
+== Running test suite: DOMStorage.Events
+-- Running test case: TestSessionStorage
+PASS: Should have a DOMStorageObject for sessionStorage.
+PASS: WebInspector.DOMStorageObject.Event.ItemAdded
+PASS: Should add key 'foo'.
+PASS: Should have value 'value1'.
+PASS: WebInspector.DOMStorageObject.Event.ItemAdded
+PASS: Should add key 'x'.
+PASS: Should have value 'xvalue'.
+PASS: WebInspector.DOMStorageObject.Event.ItemUpdated
+PASS: Should update key 'x'.
+PASS: Should have oldValue 'value1'.
+PASS: Should have new value 'value2'.
+PASS: WebInspector.DOMStorageObject.Event.ItemRemoved
+PASS: Should remove key 'x'.
+PASS: WebInspector.DOMStorageObject.Event.ItemsCleared
+
+-- Running test case: TestLocalStorage
+PASS: Should have a DOMStorageObject for localStorage.
+PASS: WebInspector.DOMStorageObject.Event.ItemAdded
+PASS: Should add key 'foo'.
+PASS: Should have value 'value1'.
+PASS: WebInspector.DOMStorageObject.Event.ItemAdded
+PASS: Should add key 'x'.
+PASS: Should have value 'xvalue'.
+PASS: WebInspector.DOMStorageObject.Event.ItemUpdated
+PASS: Should update key 'x'.
+PASS: Should have oldValue 'value1'.
+PASS: Should have new value 'value2'.
+PASS: WebInspector.DOMStorageObject.Event.ItemRemoved
+PASS: Should remove key 'x'.
+PASS: WebInspector.DOMStorageObject.Event.ItemsCleared
+

Added: trunk/LayoutTests/inspector/storage/domStorage-events.html (0 => 202529)


--- trunk/LayoutTests/inspector/storage/domStorage-events.html	                        (rev 0)
+++ trunk/LayoutTests/inspector/storage/domStorage-events.html	2016-06-28 00:55:05 UTC (rev 202529)
@@ -0,0 +1,95 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<script>
+function clearStorages() {
+    sessionStorage.clear();
+    localStorage.clear();
+}
+
+function triggerActions(storage) {
+    storage.setItem("foo", "value1");
+    storage.setItem("x", "xvalue");
+    storage.setItem("foo", "value2");
+    storage.removeItem("foo");
+    storage.clear();
+}
+
+function test()
+{
+    function testStorageEvents(storageObject, callback) {
+        let count = 0;
+        storageObject.addEventListener(WebInspector.DOMStorageObject.Event.ItemAdded, (event) => {
+            count++;
+
+            if (count === 1) {
+                InspectorTest.pass("WebInspector.DOMStorageObject.Event.ItemAdded");
+                InspectorTest.expectThat(event.data.key === "foo", "Should add key 'foo'.");
+                InspectorTest.expectThat(event.data.value === "value1", "Should have value 'value1'.");
+                return;
+            }
+
+            if (count === 2) {
+                InspectorTest.pass("WebInspector.DOMStorageObject.Event.ItemAdded");
+                InspectorTest.expectThat(event.data.key === "x", "Should add key 'x'.");
+                InspectorTest.expectThat(event.data.value === "xvalue", "Should have value 'xvalue'.");
+                return;
+            }
+
+            InspectorTest.fail("Unexpected WebInspector.DOMStorageObject.Event.ItemAdded");
+        });
+
+        storageObject.singleFireEventListener(WebInspector.DOMStorageObject.Event.ItemRemoved, (event) => {
+            InspectorTest.pass("WebInspector.DOMStorageObject.Event.ItemRemoved");
+            InspectorTest.expectThat(event.data.key === "foo", "Should remove key 'x'.");
+        });
+
+        storageObject.singleFireEventListener(WebInspector.DOMStorageObject.Event.ItemUpdated, (event) => {
+            InspectorTest.pass("WebInspector.DOMStorageObject.Event.ItemUpdated");
+            InspectorTest.expectThat(event.data.key === "foo", "Should update key 'x'.");
+            InspectorTest.expectThat(event.data.oldValue === "value1", "Should have oldValue 'value1'.");
+            InspectorTest.expectThat(event.data.value === "value2", "Should have new value 'value2'.");
+        });
+
+        storageObject.singleFireEventListener(WebInspector.DOMStorageObject.Event.ItemsCleared, (event) => {
+            InspectorTest.pass("WebInspector.DOMStorageObject.Event.ItemsCleared");
+            storageObject.removeEventListener(WebInspector.DOMStorageObject.Event.ItemAdded, null, null);
+            callback();
+        });
+    }
+
+    let suite = InspectorTest.createAsyncSuite("DOMStorage.Events");
+
+    suite.addTestCase({
+        name: "TestSessionStorage",
+        description: "Test backend generated DOMStorage added, removed, updated, and cleared events for sessionStorage.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("triggerActions(sessionStorage)");
+            let sessionStorage = WebInspector.storageManager.domStorageObjects.find((x) => !x.isLocalStorage());
+            InspectorTest.expectThat(sessionStorage, "Should have a DOMStorageObject for sessionStorage.");
+            testStorageEvents(sessionStorage, resolve);
+        }
+    });
+
+    suite.addTestCase({
+        name: "TestLocalStorage",
+        description: "Test backend generated DOMStorage added, removed, updated, and cleared events for localStorage.",
+        test: (resolve, reject) => {
+            InspectorTest.evaluateInPage("triggerActions(localStorage)");
+            let localStorage = WebInspector.storageManager.domStorageObjects.find((x) => x.isLocalStorage());
+            InspectorTest.expectThat(localStorage, "Should have a DOMStorageObject for localStorage.");
+            testStorageEvents(localStorage, resolve);
+        }
+    });
+
+    InspectorTest.evaluateInPage("clearStorages()", () => {
+        suite.runTestCasesAndFinish();
+    });
+}
+</script>
+</head>
+<body _onload_="runTest()">
+<p>Test for the DOMStorage events.</p>
+</body>
+</html>

Modified: trunk/Source/WebInspectorUI/ChangeLog (202528 => 202529)


--- trunk/Source/WebInspectorUI/ChangeLog	2016-06-28 00:42:26 UTC (rev 202528)
+++ trunk/Source/WebInspectorUI/ChangeLog	2016-06-28 00:55:05 UTC (rev 202529)
@@ -1,3 +1,15 @@
+2016-06-27  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: When modifying sessionStorage, localStorage gets updated
+        https://bugs.webkit.org/show_bug.cgi?id=159181
+        <rdar://problem/27043447>
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Test/Test.js:
+        (WebInspector.loaded):
+        Add registration for StorageManager and StorageObserver.
+
 2016-06-27  Brian Burg  <[email protected]>
 
         Web Inspector: RuntimeManager should not use view object WebInspector.quickConsole

Modified: trunk/Source/WebInspectorUI/UserInterface/Test/Test.js (202528 => 202529)


--- trunk/Source/WebInspectorUI/UserInterface/Test/Test.js	2016-06-28 00:42:26 UTC (rev 202528)
+++ trunk/Source/WebInspectorUI/UserInterface/Test/Test.js	2016-06-28 00:55:05 UTC (rev 202529)
@@ -42,6 +42,7 @@
     InspectorBackend.registerNetworkDispatcher(new WebInspector.NetworkObserver);
     InspectorBackend.registerDebuggerDispatcher(new WebInspector.DebuggerObserver);
     InspectorBackend.registerHeapDispatcher(new WebInspector.HeapObserver);
+    InspectorBackend.registerDOMStorageDispatcher(new WebInspector.DOMStorageObserver);
     InspectorBackend.registerTimelineDispatcher(new WebInspector.TimelineObserver);
     InspectorBackend.registerCSSDispatcher(new WebInspector.CSSObserver);
     InspectorBackend.registerRuntimeDispatcher(new WebInspector.RuntimeObserver);
@@ -50,6 +51,7 @@
 
     // Instantiate controllers used by tests.
     this.frameResourceManager = new WebInspector.FrameResourceManager;
+    this.storageManager = new WebInspector.StorageManager;
     this.domTreeManager = new WebInspector.DOMTreeManager;
     this.cssStyleManager = new WebInspector.CSSStyleManager;
     this.logManager = new WebInspector.LogManager;

Modified: trunk/Source/WebKit2/ChangeLog (202528 => 202529)


--- trunk/Source/WebKit2/ChangeLog	2016-06-28 00:42:26 UTC (rev 202528)
+++ trunk/Source/WebKit2/ChangeLog	2016-06-28 00:55:05 UTC (rev 202529)
@@ -1,3 +1,15 @@
+2016-06-27  Joseph Pecoraro  <[email protected]>
+
+        Web Inspector: When modifying sessionStorage, localStorage gets updated
+        https://bugs.webkit.org/show_bug.cgi?id=159181
+        <rdar://problem/27043447>
+
+        Reviewed by Timothy Hatcher.
+
+        * WebProcess/Storage/StorageAreaMap.cpp:
+        (WebKit::StorageAreaMap::dispatchSessionStorageEvent):
+        This should be dispatching storage events.
+
 2016-06-27  Alex Christensen  <[email protected]>
 
         Fix flakiness on Sierra after r202511

Modified: trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp (202528 => 202529)


--- trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp	2016-06-28 00:42:26 UTC (rev 202528)
+++ trunk/Source/WebKit2/WebProcess/Storage/StorageAreaMap.cpp	2016-06-28 00:55:05 UTC (rev 202529)
@@ -344,7 +344,7 @@
         frames.append(frame);
     }
 
-    StorageEventDispatcher::dispatchLocalStorageEventsToFrames(page->group(), frames, key, oldValue, newValue, urlString, m_securityOrigin.ptr());
+    StorageEventDispatcher::dispatchSessionStorageEventsToFrames(*page, frames, key, oldValue, newValue, urlString, m_securityOrigin.ptr());
 }
 
 void StorageAreaMap::dispatchLocalStorageEvent(uint64_t sourceStorageAreaID, const String& key, const String& oldValue, const String& newValue, const String& urlString)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to