diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/storageevent/test_storageNotifications.html | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/tests/mochitest/storageevent/test_storageNotifications.html')
-rw-r--r-- | dom/tests/mochitest/storageevent/test_storageNotifications.html | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/dom/tests/mochitest/storageevent/test_storageNotifications.html b/dom/tests/mochitest/storageevent/test_storageNotifications.html new file mode 100644 index 000000000..8d11a5a77 --- /dev/null +++ b/dom/tests/mochitest/storageevent/test_storageNotifications.html @@ -0,0 +1,127 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title>sessionStorage basic test</title> + +<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> + +<script type="application/javascript;version=1.7"> + +var expectedTypes = [ + "localStorage", + "localStorage", + "sessionStorage", + "localStorage", + "sessionStorage", + "sessionStorage", + "localStorage", + "sessionStorage", + "localStorage", + "sessionStorage", + "localStorage", + "sessionStorage", + "sessionStorage", + "localStorage", + "sessionStorage", + "localStorage", +]; + +var tests = Tests(); +function setup() { + sessionStorage.clear(); + SimpleTest.executeSoon(function() { + tests.next(); + }); +} + +function Tests() +{ + // Initially check the both storages are empty + is(sessionStorage.length, 0, "Session storage is empty [1]"); + is(localStorage.length, 0, "Local storage is empty [1]"); + + var onStorageChanged = { + observe: function(subject, topic, type) { + if (topic == "dom-storage2-changed") { + ok(expectedTypes.length > 0, "Not more then expected events encountered"); + is(type, expectedTypes.shift(), "Expected type of the storage notificaiton"); + tests.next(); + } + } + } + + // Listen for dom-storage2-changed notification + SpecialPowers.Services.obs.addObserver(onStorageChanged, + "dom-storage2-changed", false); + + // add an empty-value key + localStorage.setItem("empty", ""); + yield undefined; + + localStorage.setItem("empty", "value-1"); + yield undefined; + + sessionStorage.setItem("empty", ""); + yield undefined; + + localStorage.removeItem("empty"); + yield undefined; + + sessionStorage.setItem("empty", "value-1"); + yield undefined; + + sessionStorage.removeItem("empty"); + yield undefined; + + localStorage.setItem("key1", "value-1"); + yield undefined; + + sessionStorage.setItem("key2", "value-2"); + yield undefined; + + localStorage.setItem("key1", "value-1-2"); + yield undefined; + + sessionStorage.setItem("key2", "value-2-2"); + yield undefined; + + localStorage.setItem("key3", "value-3"); + yield undefined; + + sessionStorage.setItem("key4", "value-4"); + yield undefined; + + sessionStorage.removeItem("key4"); + yield undefined; + + localStorage.setItem("key4", "value-4"); + yield undefined; + + sessionStorage.clear(); + yield undefined; + + localStorage.clear(); + yield undefined; + + SimpleTest.executeSoon(function () { + SpecialPowers.Services.obs.removeObserver(onStorageChanged, + "dom-storage2-changed", false); + is(expectedTypes.length, 0, "received the correct number of events"); + + sessionStorage.clear(); + localStorage.clear(); + tests = null; + SimpleTest.finish(); + }); +} + +SimpleTest.waitForExplicitFinish(); + +</script> + +</head> + +<body onload="setup();"> + +</body> +</html> |