summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/storageevent
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /dom/tests/mochitest/storageevent
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-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')
-rw-r--r--dom/tests/mochitest/storageevent/frameLocalStorageMaster.html63
-rw-r--r--dom/tests/mochitest/storageevent/frameLocalStorageSlaveEqual.html55
-rw-r--r--dom/tests/mochitest/storageevent/frameLocalStorageSlaveNotEqual.html39
-rw-r--r--dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html67
-rw-r--r--dom/tests/mochitest/storageevent/frameSessionStorageMasterNotEqual.html66
-rw-r--r--dom/tests/mochitest/storageevent/frameSessionStorageSlaveEqual.html59
-rw-r--r--dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html39
-rw-r--r--dom/tests/mochitest/storageevent/interOriginFrame.js56
-rw-r--r--dom/tests/mochitest/storageevent/interOriginTest2.js59
-rw-r--r--dom/tests/mochitest/storageevent/mochitest.ini17
-rw-r--r--dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckNoPropagation.html43
-rw-r--r--dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckPropagation.html43
-rw-r--r--dom/tests/mochitest/storageevent/test_storageNotifications.html127
-rw-r--r--dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckNoPropagation.html43
-rw-r--r--dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckPropagation.html43
15 files changed, 819 insertions, 0 deletions
diff --git a/dom/tests/mochitest/storageevent/frameLocalStorageMaster.html b/dom/tests/mochitest/storageevent/frameLocalStorageMaster.html
new file mode 100644
index 000000000..b4f372d6c
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameLocalStorageMaster.html
@@ -0,0 +1,63 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>master frame for event storage propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 1;
+var gotEvent = false;
+
+window.addEventListener("storage", function(event)
+{
+ gotEvent = true;
+}, false);
+
+function doStep()
+{
+ switch (currentStep)
+ {
+ case 1:
+ // Must not fire (storage must be clear!)
+ localStorage.clear();
+ // Must fire X:null->'1'
+ localStorage.setItem("X", "1");
+ // Must fire X:'1'->'2'
+ localStorage.setItem("X", "2");
+ // Must not fire
+ localStorage.setItem("X", "2");
+ // Must fire X:'2'->null
+ localStorage.removeItem("X");
+ // Must not fire
+ localStorage.removeItem("X");
+ // Must not fire
+ localStorage.removeItem("Y");
+ // Must fire X:null->'2' (we need something in the storage)
+ localStorage.setItem("X", "2");
+ // Must fire null:null->null (one item has been erased)
+ localStorage.clear();
+ // Must not fire
+ localStorage.clear();
+ break;
+
+ // Wait some time to let the async event be propagated
+ case 11:
+ is(gotEvent, false, "Expected no events");
+ return finishTest();
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameLocalStorageSlaveEqual.html b/dom/tests/mochitest/storageevent/frameLocalStorageSlaveEqual.html
new file mode 100644
index 000000000..3bde58c49
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameLocalStorageSlaveEqual.html
@@ -0,0 +1,55 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>slave for storage event propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 2;
+
+var events = [];
+
+window.addEventListener("storage", function(event)
+{
+ events.push(event);
+}, false);
+
+function doStep()
+{
+ function checkEvent(expectedKey, expectedOldValue, expectedNewValue)
+ {
+ var event = events.shift();
+ is(event.key, expectedKey, "key name check");
+ is(event.oldValue, expectedOldValue, "old value check");
+ is(event.newValue, expectedNewValue, "new value check");
+ is(event.url, "http://example.com/tests/dom/tests/mochitest/storageevent/frameLocalStorageMaster.html");
+ ok(event.storageArea);
+ }
+
+ switch (currentStep)
+ {
+ case 10:
+ is(events.length, 5, "Expected 5 events");
+ checkEvent("X", null, "1");
+ checkEvent("X", "1", "2");
+ checkEvent("X", "2", null);
+ checkEvent("X", null, "2");
+ checkEvent(null, null, null);
+ break;
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameLocalStorageSlaveNotEqual.html b/dom/tests/mochitest/storageevent/frameLocalStorageSlaveNotEqual.html
new file mode 100644
index 000000000..ba0e4ff98
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameLocalStorageSlaveNotEqual.html
@@ -0,0 +1,39 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>slave for storage event propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 2;
+var gotEvent = false;
+
+window.addEventListener("storage", function(event)
+{
+ gotEvent = true;
+}, false);
+
+function doStep()
+{
+ switch (currentStep)
+ {
+ case 10:
+ is(gotEvent, false, "Expected no events");
+ break;
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html b/dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html
new file mode 100644
index 000000000..70e89f7e4
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html
@@ -0,0 +1,67 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>master frame for event storage propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 1;
+var gotEvent = false;
+
+window.addEventListener("storage", function(event)
+{
+ gotEvent = true;
+}, false);
+
+function doStep()
+{
+ switch (currentStep)
+ {
+ // In step 2 we instantiate sessionStorage in the other frame
+ case 1:
+ // Must not fire (storage must be clear!)
+ sessionStorage.clear();
+ // Must fire X:null->'1'
+ sessionStorage.setItem("X", "1");
+ // Must fire X:'1'->'2'
+ sessionStorage.setItem("X", "2");
+ // Must not fire
+ sessionStorage.setItem("X", "2");
+ // Must fire X:'2'->null
+ sessionStorage.removeItem("X");
+ // Must not fire
+ sessionStorage.removeItem("X");
+ // Must not fire
+ sessionStorage.removeItem("Y");
+ // Must fire X:null->'2' (we need something in the storage)
+ sessionStorage.setItem("X", "2");
+ // Must fire null:null->null (one item has been erased)
+ sessionStorage.clear();
+ // Must not fire
+ sessionStorage.clear();
+ break;
+
+ // Wait some time to let the async event be propagated
+ case 11:
+ is(gotEvent, false, "Expected no events");
+ return finishTest();
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+ <iframe src="http://example.com:80/tests/dom/tests/mochitest/storageevent/frameSessionStorageSlaveEqual.html"
+ name="slaveFrame">
+ </iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameSessionStorageMasterNotEqual.html b/dom/tests/mochitest/storageevent/frameSessionStorageMasterNotEqual.html
new file mode 100644
index 000000000..a101b8858
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameSessionStorageMasterNotEqual.html
@@ -0,0 +1,66 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>master frame for event storage propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 1;
+var gotEvent = false;
+
+window.addEventListener("storage", function(event)
+{
+ gotEvent = true;
+}, false);
+
+function doStep()
+{
+ switch (currentStep)
+ {
+ case 1:
+ // Must not fire (storage must be clear!)
+ sessionStorage.clear();
+ // Must fire X:null->'1'
+ sessionStorage.setItem("X", "1");
+ // Must fire X:'1'->'2'
+ sessionStorage.setItem("X", "2");
+ // Must not fire
+ sessionStorage.setItem("X", "2");
+ // Must fire X:'2'->null
+ sessionStorage.removeItem("X");
+ // Must not fire
+ sessionStorage.removeItem("X");
+ // Must not fire
+ sessionStorage.removeItem("Y");
+ // Must fire X:null->'2' (we need something in the storage)
+ sessionStorage.setItem("X", "2");
+ // Must fire null:null->null (one item has been erased)
+ sessionStorage.clear();
+ // Must not fire
+ sessionStorage.clear();
+ break;
+
+ // Wait some time to let the async event be propagated
+ case 11:
+ is(gotEvent, false, "Expected no events");
+ return finishTest();
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+ <iframe src="http://example.com:80/tests/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html"
+ name="slaveFrame">
+ </iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameSessionStorageSlaveEqual.html b/dom/tests/mochitest/storageevent/frameSessionStorageSlaveEqual.html
new file mode 100644
index 000000000..287cb22f6
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameSessionStorageSlaveEqual.html
@@ -0,0 +1,59 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>slave for storage event propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 2;
+
+var events = [];
+
+window.addEventListener("storage", function(event)
+{
+ events.push(event);
+}, false);
+
+function doStep()
+{
+ function checkEvent(expectedKey, expectedOldValue, expectedNewValue)
+ {
+ var event = events.shift();
+ ok(event, "Event is present");
+ if (!event)
+ return;
+
+ is(event.key, expectedKey, "key name check");
+ is(event.oldValue, expectedOldValue, "old value check");
+ is(event.newValue, expectedNewValue, "new value check");
+ is(event.url, "http://example.com/tests/dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html");
+ ok(event.storageArea);
+ }
+
+ switch (currentStep)
+ {
+ case 10:
+ is(events.length, 5, "Expected 5 events");
+ checkEvent("X", null, "1");
+ checkEvent("X", "1", "2");
+ checkEvent("X", "2", null);
+ checkEvent("X", null, "2");
+ checkEvent(null, null, null);
+ break;
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html b/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html
new file mode 100644
index 000000000..ba0e4ff98
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html
@@ -0,0 +1,39 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>slave for storage event propagation</title>
+
+<script type="text/javascript" src="interOriginFrame.js"></script>
+<script type="text/javascript">
+
+var currentStep = 2;
+var gotEvent = false;
+
+window.addEventListener("storage", function(event)
+{
+ gotEvent = true;
+}, false);
+
+function doStep()
+{
+ switch (currentStep)
+ {
+ case 10:
+ is(gotEvent, false, "Expected no events");
+ break;
+ }
+
+ // Increase by two to distinguish each test step order
+ // in both master doStep and slave doStep functions.
+ ++currentStep;
+ ++currentStep;
+
+ return true;
+}
+
+</script>
+
+</head>
+
+<body onload="postMsg('frame loaded');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/interOriginFrame.js b/dom/tests/mochitest/storageevent/interOriginFrame.js
new file mode 100644
index 000000000..b1180c908
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/interOriginFrame.js
@@ -0,0 +1,56 @@
+function postMsg(message)
+{
+ var l = SpecialPowers.wrap(parent.window.location);
+ parent.postMessage(message, l.protocol + "//" + l.host);
+}
+
+window.addEventListener("message", onMessageReceived, false);
+
+function onMessageReceived(event)
+{
+ if (event.data == "step") {
+ var performed = false;
+ try {
+ performed = doStep();
+ }
+ catch (ex) {
+ postMsg("FAILURE: exception threw at "+ location +":\n" + ex);
+ finishTest();
+ }
+
+ if (performed)
+ postMsg("perf");
+
+ return;
+ }
+
+ if (parent)
+ postMsg(event.data);
+}
+
+function ok(a, message)
+{
+ if (!a)
+ postMsg("FAILURE: " + message);
+ else
+ postMsg(message);
+}
+
+function is(a, b, message)
+{
+ if (a != b)
+ postMsg("FAILURE: " + message + ", expected "+b+" got "+a);
+ else
+ postMsg(message + ", expected "+b+" got "+a);
+}
+
+function todo(a, b, message)
+{
+ postMsg("TODO: " + message + ", expected "+b+" got "+a);
+}
+
+function finishTest()
+{
+ postMsg("done");
+ return false;
+}
diff --git a/dom/tests/mochitest/storageevent/interOriginTest2.js b/dom/tests/mochitest/storageevent/interOriginTest2.js
new file mode 100644
index 000000000..939462a4c
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/interOriginTest2.js
@@ -0,0 +1,59 @@
+var frameLoadsPending = 2;
+
+var callMasterFrame = true;
+var testDone = false;
+
+var masterFrameOrigin = "";
+var slaveFrameOrigin = "";
+
+var failureRegExp = new RegExp("^FAILURE");
+var todoRegExp = new RegExp("^TODO");
+
+const framePath = "/tests/dom/tests/mochitest/storageevent/";
+
+window.addEventListener("message", onMessageReceived, false);
+
+function onMessageReceived(event)
+{
+
+ switch (event.data)
+ {
+ // Indication of the frame onload event
+ case "frame loaded":
+ if (--frameLoadsPending)
+ break;
+
+ // Just fall through...
+
+ // Indication of successfully finished step of a test
+ case "perf":
+ if (callMasterFrame)
+ masterFrame.postMessage("step", "*");
+ else if (slaveFrame)
+ slaveFrame.postMessage("step", "*");
+ else if (SpecialPowers.wrap(masterFrame).slaveFrame)
+ SpecialPowers.wrap(masterFrame).slaveFrame.postMessage("step", "*");
+ callMasterFrame = !callMasterFrame;
+ break;
+
+ // Indication of all test parts finish (from any of the frames)
+ case "done":
+ if (testDone)
+ break;
+
+ testDone = true;
+ SimpleTest.finish();
+ break;
+
+ // Any other message indicates error, succes or todo message of a test
+ default:
+ if (typeof event.data == "undefined")
+ break; // XXXkhuey this receives undefined values
+ // (which used to become empty strings) on occasion ...
+ if (event.data.match(todoRegExp))
+ SimpleTest.todo(false, event.data);
+ else
+ SimpleTest.ok(!event.data.match(failureRegExp), event.data);
+ break;
+ }
+}
diff --git a/dom/tests/mochitest/storageevent/mochitest.ini b/dom/tests/mochitest/storageevent/mochitest.ini
new file mode 100644
index 000000000..e16d9cd2e
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/mochitest.ini
@@ -0,0 +1,17 @@
+[DEFAULT]
+support-files =
+ frameLocalStorageMaster.html
+ frameLocalStorageSlaveEqual.html
+ frameLocalStorageSlaveNotEqual.html
+ frameSessionStorageMasterEqual.html
+ frameSessionStorageMasterNotEqual.html
+ frameSessionStorageSlaveEqual.html
+ frameSessionStorageSlaveNotEqual.html
+ interOriginFrame.js
+ interOriginTest2.js
+
+[test_storageLocalStorageEventCheckNoPropagation.html]
+[test_storageLocalStorageEventCheckPropagation.html]
+[test_storageNotifications.html]
+[test_storageSessionStorageEventCheckNoPropagation.html]
+[test_storageSessionStorageEventCheckPropagation.html]
diff --git a/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckNoPropagation.html b/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckNoPropagation.html
new file mode 100644
index 000000000..0abfff454
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckNoPropagation.html
@@ -0,0 +1,43 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>storage event propagation test</title>
+
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="text/javascript" src="interOriginTest2.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<!--
+ This test loads two frames from different
+ origins and checks that entries of localStorage
+ objects don't leak each between other.
+
+ The subsystem is based on postMessage and addEventListener
+ to send messages among different origins. The subsystem waits
+ for both frames be loaded and then alternately calls each frames'
+ doStep() function that on each call proceeds with a single step
+ of the test on its side. This way the subsystem alternate between
+ both frames until both sequences completely finish.
+-->
+
+<script type="text/javascript">
+
+function startTest()
+{
+ masterFrameOrigin = "http://example.com:80";
+ slaveFrameOrigin = "http://example.org:80";
+
+ masterFrame.location = masterFrameOrigin + framePath + "frameLocalStorageMaster.html";
+ slaveFrame.location = slaveFrameOrigin + framePath + "frameLocalStorageSlaveNotEqual.html";
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+
+</head>
+
+<body onload="startTest();">
+ <iframe src="" name="masterFrame"></iframe>
+ <iframe src="" name="slaveFrame"></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckPropagation.html b/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckPropagation.html
new file mode 100644
index 000000000..3ac4ac879
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckPropagation.html
@@ -0,0 +1,43 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>storage event propagation test</title>
+
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="text/javascript" src="interOriginTest2.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<!--
+ This test loads two frames from different
+ origins and checks that entries of localStorage
+ objects don't leak each between other.
+
+ The subsystem is based on postMessage and addEventListener
+ to send messages among different origins. The subsystem waits
+ for both frames be loaded and then alternately calls each frames'
+ doStep() function that on each call proceeds with a single step
+ of the test on its side. This way the subsystem alternate between
+ both frames until both sequences completely finish.
+-->
+
+<script type="text/javascript">
+
+function startTest()
+{
+ masterFrameOrigin = "http://example.com:80";
+ slaveFrameOrigin = "http://example.com:80";
+
+ masterFrame.location = masterFrameOrigin + framePath + "frameLocalStorageMaster.html";
+ slaveFrame.location = slaveFrameOrigin + framePath + "frameLocalStorageSlaveEqual.html";
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+
+</head>
+
+<body onload="startTest();">
+ <iframe src="" name="masterFrame"></iframe>
+ <iframe src="" name="slaveFrame"></iframe>
+</body>
+</html>
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>
diff --git a/dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckNoPropagation.html b/dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckNoPropagation.html
new file mode 100644
index 000000000..0b7f3ea67
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckNoPropagation.html
@@ -0,0 +1,43 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>storage event propagation test</title>
+
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="text/javascript" src="interOriginTest2.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<!--
+ This test loads two frames from different
+ origins and checks that entries of localStorage
+ objects don't leak each between other.
+
+ The subsystem is based on postMessage and addEventListener
+ to send messages among different origins. The subsystem waits
+ for both frames be loaded and then alternately calls each frames'
+ doStep() function that on each call proceeds with a single step
+ of the test on its side. This way the subsystem alternate between
+ both frames until both sequences completely finish.
+-->
+
+<script type="text/javascript">
+
+var slaveFrame = null;
+
+function startTest()
+{
+ masterFrameOrigin = "http://example.org:80";
+ slaveFrameOrigin = "http://example.com:80";
+
+ masterFrame.location = masterFrameOrigin + framePath + "frameSessionStorageMasterNotEqual.html";
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+
+</head>
+
+<body onload="startTest();">
+ <iframe src="" name="masterFrame"></iframe>
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckPropagation.html b/dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckPropagation.html
new file mode 100644
index 000000000..86c8ea348
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckPropagation.html
@@ -0,0 +1,43 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>storage event propagation test</title>
+
+<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+<script type="text/javascript" src="interOriginTest2.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<!--
+ This test loads two frames from different
+ origins and checks that entries of localStorage
+ objects don't leak each between other.
+
+ The subsystem is based on postMessage and addEventListener
+ to send messages among different origins. The subsystem waits
+ for both frames be loaded and then alternately calls each frames'
+ doStep() function that on each call proceeds with a single step
+ of the test on its side. This way the subsystem alternate between
+ both frames until both sequences completely finish.
+-->
+
+<script type="text/javascript">
+
+var slaveFrame = null;
+
+function startTest()
+{
+ masterFrameOrigin = "http://example.com:80";
+ slaveFrameOrigin = "http://example.com:80";
+
+ masterFrame.location = masterFrameOrigin + framePath + "frameSessionStorageMasterEqual.html";
+}
+
+SimpleTest.waitForExplicitFinish();
+
+</script>
+
+</head>
+
+<body onload="startTest();">
+ <iframe src="" name="masterFrame"></iframe>
+</body>
+</html>