diff options
Diffstat (limited to 'LayoutTests/storage/domstorage/events')
19 files changed, 923 insertions, 0 deletions
diff --git a/LayoutTests/storage/domstorage/events/basic-body-attribute-expected.txt b/LayoutTests/storage/domstorage/events/basic-body-attribute-expected.txt new file mode 100644 index 0000000..273c95b --- /dev/null +++ b/LayoutTests/storage/domstorage/events/basic-body-attribute-expected.txt @@ -0,0 +1,102 @@ +This is a test to make sure DOM Storage mutations fire StorageEvents that are caught by the event listener specified as an attribute on the body. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Testing sessionStorage +storage.clear() +PASS storage.length is 0 +iframe.onload = step1 +iframe.src = 'resources/body-event-handler.html' +Reset storage event list +storageEventList = new Array() +storage.setItem('FOO', 'BAR') +PASS storageEventList.length is 1 +PASS storageEventList[0].key is "FOO" +PASS storageEventList[0].oldValue is null +PASS storageEventList[0].newValue is "BAR" +storage.setItem('FU', 'BAR') +storage.setItem('a', '1') +storage.setItem('b', '2') +storage.setItem('b', '3') +PASS storageEventList.length is 5 +PASS storageEventList[1].key is "FU" +PASS storageEventList[1].oldValue is null +PASS storageEventList[1].newValue is "BAR" +PASS storageEventList[2].key is "a" +PASS storageEventList[2].oldValue is null +PASS storageEventList[2].newValue is "1" +PASS storageEventList[3].key is "b" +PASS storageEventList[3].oldValue is null +PASS storageEventList[3].newValue is "2" +PASS storageEventList[4].key is "b" +PASS storageEventList[4].oldValue is "2" +PASS storageEventList[4].newValue is "3" +storage.removeItem('FOO') +PASS storageEventList.length is 6 +PASS storageEventList[5].key is "FOO" +PASS storageEventList[5].oldValue is "BAR" +PASS storageEventList[5].newValue is null +storage.removeItem('FU') +PASS storageEventList.length is 7 +PASS storageEventList[6].key is "FU" +PASS storageEventList[6].oldValue is "BAR" +PASS storageEventList[6].newValue is null +storage.clear() +PASS storageEventList.length is 8 +PASS storageEventList[7].key is null +PASS storageEventList[7].oldValue is null +PASS storageEventList[7].newValue is null + + +Testing localStorage +storage.clear() +PASS storage.length is 0 +iframe.onload = step1 +iframe.src = 'resources/body-event-handler.html' +Reset storage event list +storageEventList = new Array() +storage.setItem('FOO', 'BAR') +PASS storageEventList.length is 1 +PASS storageEventList[0].key is "FOO" +PASS storageEventList[0].oldValue is null +PASS storageEventList[0].newValue is "BAR" +storage.setItem('FU', 'BAR') +storage.setItem('a', '1') +storage.setItem('b', '2') +storage.setItem('b', '3') +PASS storageEventList.length is 5 +PASS storageEventList[1].key is "FU" +PASS storageEventList[1].oldValue is null +PASS storageEventList[1].newValue is "BAR" +PASS storageEventList[2].key is "a" +PASS storageEventList[2].oldValue is null +PASS storageEventList[2].newValue is "1" +PASS storageEventList[3].key is "b" +PASS storageEventList[3].oldValue is null +PASS storageEventList[3].newValue is "2" +PASS storageEventList[4].key is "b" +PASS storageEventList[4].oldValue is "2" +PASS storageEventList[4].newValue is "3" +storage.removeItem('FOO') +PASS storageEventList.length is 6 +PASS storageEventList[5].key is "FOO" +PASS storageEventList[5].oldValue is "BAR" +PASS storageEventList[5].newValue is null +storage.removeItem('FU') +PASS storageEventList.length is 7 +PASS storageEventList[6].key is "FU" +PASS storageEventList[6].oldValue is "BAR" +PASS storageEventList[6].newValue is null +storage.clear() +PASS storageEventList.length is 8 +PASS storageEventList[7].key is null +PASS storageEventList[7].oldValue is null +PASS storageEventList[7].newValue is null + + +PASS successfullyParsed is true + +TEST COMPLETE + + diff --git a/LayoutTests/storage/domstorage/events/basic-body-attribute.html b/LayoutTests/storage/domstorage/events/basic-body-attribute.html new file mode 100644 index 0000000..c2778ff --- /dev/null +++ b/LayoutTests/storage/domstorage/events/basic-body-attribute.html @@ -0,0 +1,13 @@ +<html> +<head> +<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css"> +<script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../../../fast/js/resources/js-test-post-function.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/eventTestHarness.js"></script> +<script src="script-tests/basic-body-attribute.js"></script> +</body> +</html> diff --git a/LayoutTests/storage/domstorage/events/basic-expected.txt b/LayoutTests/storage/domstorage/events/basic-expected.txt new file mode 100644 index 0000000..bccdb5c --- /dev/null +++ b/LayoutTests/storage/domstorage/events/basic-expected.txt @@ -0,0 +1,98 @@ +This is a test to make sure DOM Storage mutations fire StorageEvents that are caught by the event listener set via window.onstorage. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Testing sessionStorage +storage.clear() +PASS storage.length is 0 +Reset storage event list +storageEventList = new Array() +storage.setItem('FOO', 'BAR') +PASS storageEventList.length is 1 +PASS storageEventList[0].key is "FOO" +PASS storageEventList[0].oldValue is null +PASS storageEventList[0].newValue is "BAR" +storage.setItem('FU', 'BAR') +storage.setItem('a', '1') +storage.setItem('b', '2') +storage.setItem('b', '3') +PASS storageEventList.length is 5 +PASS storageEventList[1].key is "FU" +PASS storageEventList[1].oldValue is null +PASS storageEventList[1].newValue is "BAR" +PASS storageEventList[2].key is "a" +PASS storageEventList[2].oldValue is null +PASS storageEventList[2].newValue is "1" +PASS storageEventList[3].key is "b" +PASS storageEventList[3].oldValue is null +PASS storageEventList[3].newValue is "2" +PASS storageEventList[4].key is "b" +PASS storageEventList[4].oldValue is "2" +PASS storageEventList[4].newValue is "3" +storage.removeItem('FOO') +PASS storageEventList.length is 6 +PASS storageEventList[5].key is "FOO" +PASS storageEventList[5].oldValue is "BAR" +PASS storageEventList[5].newValue is null +storage.removeItem('FU') +PASS storageEventList.length is 7 +PASS storageEventList[6].key is "FU" +PASS storageEventList[6].oldValue is "BAR" +PASS storageEventList[6].newValue is null +storage.clear() +PASS storageEventList.length is 8 +PASS storageEventList[7].key is null +PASS storageEventList[7].oldValue is null +PASS storageEventList[7].newValue is null + + +Testing localStorage +storage.clear() +PASS storage.length is 0 +Reset storage event list +storageEventList = new Array() +storage.setItem('FOO', 'BAR') +PASS storageEventList.length is 1 +PASS storageEventList[0].key is "FOO" +PASS storageEventList[0].oldValue is null +PASS storageEventList[0].newValue is "BAR" +storage.setItem('FU', 'BAR') +storage.setItem('a', '1') +storage.setItem('b', '2') +storage.setItem('b', '3') +PASS storageEventList.length is 5 +PASS storageEventList[1].key is "FU" +PASS storageEventList[1].oldValue is null +PASS storageEventList[1].newValue is "BAR" +PASS storageEventList[2].key is "a" +PASS storageEventList[2].oldValue is null +PASS storageEventList[2].newValue is "1" +PASS storageEventList[3].key is "b" +PASS storageEventList[3].oldValue is null +PASS storageEventList[3].newValue is "2" +PASS storageEventList[4].key is "b" +PASS storageEventList[4].oldValue is "2" +PASS storageEventList[4].newValue is "3" +storage.removeItem('FOO') +PASS storageEventList.length is 6 +PASS storageEventList[5].key is "FOO" +PASS storageEventList[5].oldValue is "BAR" +PASS storageEventList[5].newValue is null +storage.removeItem('FU') +PASS storageEventList.length is 7 +PASS storageEventList[6].key is "FU" +PASS storageEventList[6].oldValue is "BAR" +PASS storageEventList[6].newValue is null +storage.clear() +PASS storageEventList.length is 8 +PASS storageEventList[7].key is null +PASS storageEventList[7].oldValue is null +PASS storageEventList[7].newValue is null + + +PASS successfullyParsed is true + +TEST COMPLETE + + diff --git a/LayoutTests/storage/domstorage/events/basic-setattribute-expected.txt b/LayoutTests/storage/domstorage/events/basic-setattribute-expected.txt new file mode 100644 index 0000000..99c7f18 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/basic-setattribute-expected.txt @@ -0,0 +1,102 @@ +This is a test to make sure DOM Storage mutations fire StorageEvents that are caught by the event listener attached via setattribute. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Testing sessionStorage +storage.clear() +PASS storage.length is 0 +iframe.onload = step1 +iframe.src = 'resources/setattribute-event-handler.html' +Reset storage event list +storageEventList = new Array() +storage.setItem('FOO', 'BAR') +PASS storageEventList.length is 1 +PASS storageEventList[0].key is "FOO" +PASS storageEventList[0].oldValue is null +PASS storageEventList[0].newValue is "BAR" +storage.setItem('FU', 'BAR') +storage.setItem('a', '1') +storage.setItem('b', '2') +storage.setItem('b', '3') +PASS storageEventList.length is 5 +PASS storageEventList[1].key is "FU" +PASS storageEventList[1].oldValue is null +PASS storageEventList[1].newValue is "BAR" +PASS storageEventList[2].key is "a" +PASS storageEventList[2].oldValue is null +PASS storageEventList[2].newValue is "1" +PASS storageEventList[3].key is "b" +PASS storageEventList[3].oldValue is null +PASS storageEventList[3].newValue is "2" +PASS storageEventList[4].key is "b" +PASS storageEventList[4].oldValue is "2" +PASS storageEventList[4].newValue is "3" +storage.removeItem('FOO') +PASS storageEventList.length is 6 +PASS storageEventList[5].key is "FOO" +PASS storageEventList[5].oldValue is "BAR" +PASS storageEventList[5].newValue is null +storage.removeItem('FU') +PASS storageEventList.length is 7 +PASS storageEventList[6].key is "FU" +PASS storageEventList[6].oldValue is "BAR" +PASS storageEventList[6].newValue is null +storage.clear() +PASS storageEventList.length is 8 +PASS storageEventList[7].key is null +PASS storageEventList[7].oldValue is null +PASS storageEventList[7].newValue is null + + +Testing localStorage +storage.clear() +PASS storage.length is 0 +iframe.onload = step1 +iframe.src = 'resources/setattribute-event-handler.html' +Reset storage event list +storageEventList = new Array() +storage.setItem('FOO', 'BAR') +PASS storageEventList.length is 1 +PASS storageEventList[0].key is "FOO" +PASS storageEventList[0].oldValue is null +PASS storageEventList[0].newValue is "BAR" +storage.setItem('FU', 'BAR') +storage.setItem('a', '1') +storage.setItem('b', '2') +storage.setItem('b', '3') +PASS storageEventList.length is 5 +PASS storageEventList[1].key is "FU" +PASS storageEventList[1].oldValue is null +PASS storageEventList[1].newValue is "BAR" +PASS storageEventList[2].key is "a" +PASS storageEventList[2].oldValue is null +PASS storageEventList[2].newValue is "1" +PASS storageEventList[3].key is "b" +PASS storageEventList[3].oldValue is null +PASS storageEventList[3].newValue is "2" +PASS storageEventList[4].key is "b" +PASS storageEventList[4].oldValue is "2" +PASS storageEventList[4].newValue is "3" +storage.removeItem('FOO') +PASS storageEventList.length is 6 +PASS storageEventList[5].key is "FOO" +PASS storageEventList[5].oldValue is "BAR" +PASS storageEventList[5].newValue is null +storage.removeItem('FU') +PASS storageEventList.length is 7 +PASS storageEventList[6].key is "FU" +PASS storageEventList[6].oldValue is "BAR" +PASS storageEventList[6].newValue is null +storage.clear() +PASS storageEventList.length is 8 +PASS storageEventList[7].key is null +PASS storageEventList[7].oldValue is null +PASS storageEventList[7].newValue is null + + +PASS successfullyParsed is true + +TEST COMPLETE + + diff --git a/LayoutTests/storage/domstorage/events/basic-setattribute.html b/LayoutTests/storage/domstorage/events/basic-setattribute.html new file mode 100644 index 0000000..2b95568 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/basic-setattribute.html @@ -0,0 +1,13 @@ +<html> +<head> +<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css"> +<script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../../../fast/js/resources/js-test-post-function.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/eventTestHarness.js"></script> +<script src="script-tests/basic-setattribute.js"></script> +</body> +</html> diff --git a/LayoutTests/storage/domstorage/events/basic.html b/LayoutTests/storage/domstorage/events/basic.html new file mode 100644 index 0000000..4c52d07 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/basic.html @@ -0,0 +1,13 @@ +<html> +<head> +<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css"> +<script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../../../fast/js/resources/js-test-post-function.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/eventTestHarness.js"></script> +<script src="script-tests/basic.js"></script> +</body> +</html> diff --git a/LayoutTests/storage/domstorage/events/case-sensitive-expected.txt b/LayoutTests/storage/domstorage/events/case-sensitive-expected.txt new file mode 100644 index 0000000..6cdf19f --- /dev/null +++ b/LayoutTests/storage/domstorage/events/case-sensitive-expected.txt @@ -0,0 +1,38 @@ +Verify that storage events fire even when only the case of the value changes. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Testing sessionStorage +storage.clear() +PASS storage.length is 0 + +Verify storage events are case sensitive +storage.foo = 'test' +Reset storage event list +storageEventList = new Array() +storage.foo = 'test' +PASS storageEventList.length is 0 +storage.foo = 'TEST' +PASS storageEventList.length is 1 + + +Testing localStorage +storage.clear() +PASS storage.length is 0 + +Verify storage events are case sensitive +storage.foo = 'test' +Reset storage event list +storageEventList = new Array() +storage.foo = 'test' +PASS storageEventList.length is 0 +storage.foo = 'TEST' +PASS storageEventList.length is 1 + + +PASS successfullyParsed is true + +TEST COMPLETE + + diff --git a/LayoutTests/storage/domstorage/events/case-sensitive.html b/LayoutTests/storage/domstorage/events/case-sensitive.html new file mode 100644 index 0000000..c8da433 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/case-sensitive.html @@ -0,0 +1,13 @@ +<html> +<head> +<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css"> +<script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../../../fast/js/resources/js-test-post-function.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/eventTestHarness.js"></script> +<script src="script-tests/case-sensitive.js"></script> +</body> +</html> diff --git a/LayoutTests/storage/domstorage/events/documentURI-expected.txt b/LayoutTests/storage/domstorage/events/documentURI-expected.txt new file mode 100644 index 0000000..5952523 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/documentURI-expected.txt @@ -0,0 +1,40 @@ +Test that changing documentURI has no effects on the uri passed into storage events. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Testing sessionStorage +storage.clear() +PASS storage.length is 0 +Reset storage event list +storageEventList = new Array() +storage.foo = '123' +PASS storageEventList.length is 1 +Saving URI +document.documentURI = 'abc' +PASS document.documentURI is "abc" +storage.foo = 'xyz' +PASS storageEventList.length is 2 +PASS true is true + + +Testing localStorage +storage.clear() +PASS storage.length is 0 +Reset storage event list +storageEventList = new Array() +storage.foo = '123' +PASS storageEventList.length is 1 +Saving URI +document.documentURI = 'abc' +PASS document.documentURI is "abc" +storage.foo = 'xyz' +PASS storageEventList.length is 2 +PASS true is true + + +PASS successfullyParsed is true + +TEST COMPLETE + + diff --git a/LayoutTests/storage/domstorage/events/documentURI.html b/LayoutTests/storage/domstorage/events/documentURI.html new file mode 100644 index 0000000..7721e87 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/documentURI.html @@ -0,0 +1,13 @@ +<html> +<head> +<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css"> +<script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../../../fast/js/resources/js-test-post-function.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/eventTestHarness.js"></script> +<script src="script-tests/documentURI.js"></script> +</body> +</html> diff --git a/LayoutTests/storage/domstorage/events/resources/body-event-handler.html b/LayoutTests/storage/domstorage/events/resources/body-event-handler.html new file mode 100644 index 0000000..a1218fe --- /dev/null +++ b/LayoutTests/storage/domstorage/events/resources/body-event-handler.html @@ -0,0 +1,8 @@ +<html><head><script> + +function handleStorageEvent(e) { + window.parent.storageEventList.push(e); +} + +</script></head><body onstorage="handleStorageEvent(window.event);"> +</body></html> diff --git a/LayoutTests/storage/domstorage/events/resources/eventTestHarness.js b/LayoutTests/storage/domstorage/events/resources/eventTestHarness.js new file mode 100644 index 0000000..8f15c31 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/resources/eventTestHarness.js @@ -0,0 +1,51 @@ +if (window.layoutTestController) { + layoutTestController.dumpAsText(); + layoutTestController.waitUntilDone(); +} + +iframe = document.createElement("IFRAME"); +iframe.src = "about:blank"; +document.body.appendChild(iframe); +iframe.contentWindow.document.body.innerText = "Nothing to see here."; + +storageEventList = new Array(); +iframe.contentWindow.onstorage = function (e) { + window.parent.storageEventList.push(e); +} + +function runAfterStorageEvents(callback) { + var currentCount = storageEventList.length; + function onTimeout() { + if (currentCount != storageEventList.length) + runAfterStorageEvents(callback); + else + callback(); + } + setTimeout(onTimeout, 0); +} + +function testStorages(testCallback) +{ + // When we're done testing LocalStorage, this is run. + function allDone() + { + debug(""); + debug(""); + window.successfullyParsed = true; + isSuccessfullyParsed(); + debug(""); + if (window.layoutTestController) + layoutTestController.notifyDone() + } + + // When we're done testing with SessionStorage, this is run. + function runLocalStorage() + { + debug(""); + debug(""); + testCallback("localStorage", allDone); + } + + // First run the test with SessionStorage. + testCallback("sessionStorage", runLocalStorage); +} diff --git a/LayoutTests/storage/domstorage/events/resources/setattribute-event-handler.html b/LayoutTests/storage/domstorage/events/resources/setattribute-event-handler.html new file mode 100644 index 0000000..a764c53 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/resources/setattribute-event-handler.html @@ -0,0 +1,11 @@ +<html><head></head><body> +<script> + +function handleStorageEvent(e) { + window.parent.storageEventList.push(e); +} + +document.body.setAttribute("onstorage", "handleStorageEvent(window.event);"); + +</script> +</body></html> diff --git a/LayoutTests/storage/domstorage/events/script-tests/TEMPLATE.html b/LayoutTests/storage/domstorage/events/script-tests/TEMPLATE.html new file mode 100644 index 0000000..d9af438 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/script-tests/TEMPLATE.html @@ -0,0 +1,13 @@ +<html> +<head> +<link rel="stylesheet" href="../../../fast/js/resources/js-test-style.css"> +<script src="../../../fast/js/resources/js-test-pre.js"></script> +<script src="../../../fast/js/resources/js-test-post-function.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="resources/eventTestHarness.js"></script> +<script src="YOUR_JS_FILE_HERE"></script> +</body> +</html> diff --git a/LayoutTests/storage/domstorage/events/script-tests/basic-body-attribute.js b/LayoutTests/storage/domstorage/events/script-tests/basic-body-attribute.js new file mode 100644 index 0000000..7054069 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/script-tests/basic-body-attribute.js @@ -0,0 +1,98 @@ +description("This is a test to make sure DOM Storage mutations fire StorageEvents that are caught by the event listener specified as an attribute on the body."); + +function test(storageString, callback) +{ + window.completionCallback = callback; + window.storage = eval(storageString); + if (!storage) { + testFailed(storageString + " DOES NOT exist"); + return; + } + + debug("Testing " + storageString); + + evalAndLog("storage.clear()"); + shouldBe("storage.length", "0"); + + evalAndLog("iframe.onload = step1"); + evalAndLog("iframe.src = 'resources/body-event-handler.html'"); +} + +function step1() +{ + debug("Reset storage event list"); + evalAndLog("storageEventList = new Array()"); + evalAndLog("storage.setItem('FOO', 'BAR')"); + + runAfterStorageEvents(step2); +} + +function step2() +{ + shouldBe("storageEventList.length", "1"); + shouldBeEqualToString("storageEventList[0].key", "FOO"); + shouldBeNull("storageEventList[0].oldValue"); + shouldBeEqualToString("storageEventList[0].newValue", "BAR"); + evalAndLog("storage.setItem('FU', 'BAR')"); + evalAndLog("storage.setItem('a', '1')"); + evalAndLog("storage.setItem('b', '2')"); + evalAndLog("storage.setItem('b', '3')"); + + runAfterStorageEvents(step3); +} + +function step3() +{ + shouldBe("storageEventList.length", "5"); + shouldBeEqualToString("storageEventList[1].key", "FU"); + shouldBeNull("storageEventList[1].oldValue"); + shouldBeEqualToString("storageEventList[1].newValue", "BAR"); + shouldBeEqualToString("storageEventList[2].key", "a"); + shouldBeNull("storageEventList[2].oldValue"); + shouldBeEqualToString("storageEventList[2].newValue", "1"); + shouldBeEqualToString("storageEventList[3].key", "b"); + shouldBeNull("storageEventList[3].oldValue"); + shouldBeEqualToString("storageEventList[3].newValue", "2"); + shouldBeEqualToString("storageEventList[4].key", "b"); + shouldBeEqualToString("storageEventList[4].oldValue", "2"); + shouldBeEqualToString("storageEventList[4].newValue", "3"); + evalAndLog("storage.removeItem('FOO')"); + + runAfterStorageEvents(step4); +} + +function step4() +{ + shouldBe("storageEventList.length", "6"); + shouldBeEqualToString("storageEventList[5].key", "FOO"); + shouldBeEqualToString("storageEventList[5].oldValue", "BAR"); + shouldBeNull("storageEventList[5].newValue"); + evalAndLog("storage.removeItem('FU')"); + + runAfterStorageEvents(step5); +} + +function step5() +{ + shouldBe("storageEventList.length", "7"); + shouldBeEqualToString("storageEventList[6].key", "FU"); + shouldBeEqualToString("storageEventList[6].oldValue", "BAR"); + shouldBeNull("storageEventList[6].newValue"); + evalAndLog("storage.clear()"); + + runAfterStorageEvents(step6); +} + +function step6() +{ + shouldBe("storageEventList.length", "8"); + shouldBeNull("storageEventList[7].key"); + shouldBeNull("storageEventList[7].oldValue"); + shouldBeNull("storageEventList[7].newValue"); + + completionCallback(); +} + +testStorages(test); + +var successfullyParsed = true; diff --git a/LayoutTests/storage/domstorage/events/script-tests/basic-setattribute.js b/LayoutTests/storage/domstorage/events/script-tests/basic-setattribute.js new file mode 100644 index 0000000..0da34a6 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/script-tests/basic-setattribute.js @@ -0,0 +1,98 @@ +description("This is a test to make sure DOM Storage mutations fire StorageEvents that are caught by the event listener attached via setattribute."); + +function test(storageString, callback) +{ + window.completionCallback = callback; + window.storage = eval(storageString); + if (!storage) { + testFailed(storageString + " DOES NOT exist"); + return; + } + + debug("Testing " + storageString); + + evalAndLog("storage.clear()"); + shouldBe("storage.length", "0"); + + evalAndLog("iframe.onload = step1"); + evalAndLog("iframe.src = 'resources/setattribute-event-handler.html'"); +} + +function step1() +{ + debug("Reset storage event list"); + evalAndLog("storageEventList = new Array()"); + evalAndLog("storage.setItem('FOO', 'BAR')"); + + runAfterStorageEvents(step2); +} + +function step2() +{ + shouldBe("storageEventList.length", "1"); + shouldBeEqualToString("storageEventList[0].key", "FOO"); + shouldBeNull("storageEventList[0].oldValue"); + shouldBeEqualToString("storageEventList[0].newValue", "BAR"); + evalAndLog("storage.setItem('FU', 'BAR')"); + evalAndLog("storage.setItem('a', '1')"); + evalAndLog("storage.setItem('b', '2')"); + evalAndLog("storage.setItem('b', '3')"); + + runAfterStorageEvents(step3); +} + +function step3() +{ + shouldBe("storageEventList.length", "5"); + shouldBeEqualToString("storageEventList[1].key", "FU"); + shouldBeNull("storageEventList[1].oldValue"); + shouldBeEqualToString("storageEventList[1].newValue", "BAR"); + shouldBeEqualToString("storageEventList[2].key", "a"); + shouldBeNull("storageEventList[2].oldValue"); + shouldBeEqualToString("storageEventList[2].newValue", "1"); + shouldBeEqualToString("storageEventList[3].key", "b"); + shouldBeNull("storageEventList[3].oldValue"); + shouldBeEqualToString("storageEventList[3].newValue", "2"); + shouldBeEqualToString("storageEventList[4].key", "b"); + shouldBeEqualToString("storageEventList[4].oldValue", "2"); + shouldBeEqualToString("storageEventList[4].newValue", "3"); + evalAndLog("storage.removeItem('FOO')"); + + runAfterStorageEvents(step4); +} + +function step4() +{ + shouldBe("storageEventList.length", "6"); + shouldBeEqualToString("storageEventList[5].key", "FOO"); + shouldBeEqualToString("storageEventList[5].oldValue", "BAR"); + shouldBeNull("storageEventList[5].newValue"); + evalAndLog("storage.removeItem('FU')"); + + runAfterStorageEvents(step5); +} + +function step5() +{ + shouldBe("storageEventList.length", "7"); + shouldBeEqualToString("storageEventList[6].key", "FU"); + shouldBeEqualToString("storageEventList[6].oldValue", "BAR"); + shouldBeNull("storageEventList[6].newValue"); + evalAndLog("storage.clear()"); + + runAfterStorageEvents(step6); +} + +function step6() +{ + shouldBe("storageEventList.length", "8"); + shouldBeNull("storageEventList[7].key"); + shouldBeNull("storageEventList[7].oldValue"); + shouldBeNull("storageEventList[7].newValue"); + + completionCallback(); +} + +testStorages(test); + +var successfullyParsed = true; diff --git a/LayoutTests/storage/domstorage/events/script-tests/basic.js b/LayoutTests/storage/domstorage/events/script-tests/basic.js new file mode 100644 index 0000000..06591b1 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/script-tests/basic.js @@ -0,0 +1,97 @@ +description("This is a test to make sure DOM Storage mutations fire StorageEvents that are caught by the event listener set via window.onstorage."); + +function test(storageString, callback) +{ + window.completionCallback = callback; + window.storage = eval(storageString); + if (!storage) { + testFailed(storageString + " DOES NOT exist"); + return; + } + + debug("Testing " + storageString); + + evalAndLog("storage.clear()"); + shouldBe("storage.length", "0"); + + runAfterStorageEvents(step1); +} + +function step1() +{ + debug("Reset storage event list"); + evalAndLog("storageEventList = new Array()"); + evalAndLog("storage.setItem('FOO', 'BAR')"); + + runAfterStorageEvents(step2); +} + +function step2() +{ + shouldBe("storageEventList.length", "1"); + shouldBeEqualToString("storageEventList[0].key", "FOO"); + shouldBeNull("storageEventList[0].oldValue"); + shouldBeEqualToString("storageEventList[0].newValue", "BAR"); + evalAndLog("storage.setItem('FU', 'BAR')"); + evalAndLog("storage.setItem('a', '1')"); + evalAndLog("storage.setItem('b', '2')"); + evalAndLog("storage.setItem('b', '3')"); + + runAfterStorageEvents(step3); +} + +function step3() +{ + shouldBe("storageEventList.length", "5"); + shouldBeEqualToString("storageEventList[1].key", "FU"); + shouldBeNull("storageEventList[1].oldValue"); + shouldBeEqualToString("storageEventList[1].newValue", "BAR"); + shouldBeEqualToString("storageEventList[2].key", "a"); + shouldBeNull("storageEventList[2].oldValue"); + shouldBeEqualToString("storageEventList[2].newValue", "1"); + shouldBeEqualToString("storageEventList[3].key", "b"); + shouldBeNull("storageEventList[3].oldValue"); + shouldBeEqualToString("storageEventList[3].newValue", "2"); + shouldBeEqualToString("storageEventList[4].key", "b"); + shouldBeEqualToString("storageEventList[4].oldValue", "2"); + shouldBeEqualToString("storageEventList[4].newValue", "3"); + evalAndLog("storage.removeItem('FOO')"); + + runAfterStorageEvents(step4); +} + +function step4() +{ + shouldBe("storageEventList.length", "6"); + shouldBeEqualToString("storageEventList[5].key", "FOO"); + shouldBeEqualToString("storageEventList[5].oldValue", "BAR"); + shouldBeNull("storageEventList[5].newValue"); + evalAndLog("storage.removeItem('FU')"); + + runAfterStorageEvents(step5); +} + +function step5() +{ + shouldBe("storageEventList.length", "7"); + shouldBeEqualToString("storageEventList[6].key", "FU"); + shouldBeEqualToString("storageEventList[6].oldValue", "BAR"); + shouldBeNull("storageEventList[6].newValue"); + evalAndLog("storage.clear()"); + + runAfterStorageEvents(step6); +} + +function step6() +{ + shouldBe("storageEventList.length", "8"); + shouldBeNull("storageEventList[7].key"); + shouldBeNull("storageEventList[7].oldValue"); + shouldBeNull("storageEventList[7].newValue"); + + completionCallback(); +} + +testStorages(test); + +var successfullyParsed = true; diff --git a/LayoutTests/storage/domstorage/events/script-tests/case-sensitive.js b/LayoutTests/storage/domstorage/events/script-tests/case-sensitive.js new file mode 100644 index 0000000..b5038a8 --- /dev/null +++ b/LayoutTests/storage/domstorage/events/script-tests/case-sensitive.js @@ -0,0 +1,50 @@ +description("Verify that storage events fire even when only the case of the value changes."); + +function test(storageString, callback) +{ + window.completionCallback = callback; + window.storage = eval(storageString); + if (!storage) { + testFailed(storageString + " DOES NOT exist"); + return; + } + + debug("Testing " + storageString); + + evalAndLog("storage.clear()"); + shouldBe("storage.length", "0"); + + debug(""); + debug("Verify storage events are case sensitive"); + evalAndLog("storage.foo = 'test'"); + + runAfterStorageEvents(step1); +} + +function step1() +{ + debug("Reset storage event list"); + evalAndLog("storageEventList = new Array()"); + evalAndLog("storage.foo = 'test'"); + + runAfterStorageEvents(step2); +} + +function step2() +{ + shouldBe("storageEventList.length", "0"); + evalAndLog("storage.foo = 'TEST'"); + + runAfterStorageEvents(step3); +} + +function step3() +{ + shouldBe("storageEventList.length", "1"); + + completionCallback(); +} + +testStorages(test); + +var successfullyParsed = true; diff --git a/LayoutTests/storage/domstorage/events/script-tests/documentURI.js b/LayoutTests/storage/domstorage/events/script-tests/documentURI.js new file mode 100644 index 0000000..4b4f4cb --- /dev/null +++ b/LayoutTests/storage/domstorage/events/script-tests/documentURI.js @@ -0,0 +1,52 @@ +description("Test that changing documentURI has no effects on the uri passed into storage events."); + +function test(storageString, callback) +{ + window.completionCallback = callback; + window.storage = eval(storageString); + if (!storage) { + testFailed(storageString + " DOES NOT exist"); + return; + } + + debug("Testing " + storageString); + + evalAndLog("storage.clear()"); + shouldBe("storage.length", "0"); + + runAfterStorageEvents(step1); +} + +function step1() +{ + debug("Reset storage event list"); + evalAndLog("storageEventList = new Array()"); + evalAndLog("storage.foo = '123'"); + + runAfterStorageEvents(step2); +} + +function step2() +{ + shouldBe("storageEventList.length", "1"); + debug("Saving URI"); + window.lastURI = storageEventList[0].uri; + + evalAndLog("document.documentURI = 'abc'"); + shouldBeEqualToString("document.documentURI", "abc"); + evalAndLog("storage.foo = 'xyz'"); + + runAfterStorageEvents(step3); +} + +function step3() +{ + shouldBe("storageEventList.length", "2"); + shouldBeTrue(String(window.lastURI == storageEventList[1].uri)); + + completionCallback(); +} + +testStorages(test); + +var successfullyParsed = true; |