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

Patch by Joseph Pecoraro <pecoraro@apple.com> 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.

Canonical link: https://commits.webkit.org/177280@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202529 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
JosephPecoraro authored and webkit-commit-queue committed Jun 28, 2016
1 parent 977c2ac commit 676fdcec697a908cce04b6c5e9170f5602a83275
@@ -1,3 +1,16 @@
2016-06-27 Joseph Pecoraro <pecoraro@apple.com>

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 <mmaxfield@apple.com>

[Cocoa] Test gardening for the system font in macOS Sierra and iOS 10
@@ -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

@@ -0,0 +1,95 @@
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
<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>
@@ -1,3 +1,15 @@
2016-06-27 Joseph Pecoraro <pecoraro@apple.com>

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 <bburg@apple.com>

Web Inspector: RuntimeManager should not use view object WebInspector.quickConsole
@@ -42,6 +42,7 @@ WebInspector.loaded = function()
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 @@ WebInspector.loaded = function()

// 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;
@@ -1,3 +1,15 @@
2016-06-27 Joseph Pecoraro <pecoraro@apple.com>

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 <achristensen@webkit.org>

Fix flakiness on Sierra after r202511
@@ -344,7 +344,7 @@ void StorageAreaMap::dispatchSessionStorageEvent(uint64_t sourceStorageAreaID, c
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)

0 comments on commit 676fdce

Please sign in to comment.