summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/storageevent
diff options
context:
space:
mode:
Diffstat (limited to '')
-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.html70
-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.js63
-rw-r--r--dom/tests/mochitest/storageevent/interOriginTest2.js60
-rw-r--r--dom/tests/mochitest/storageevent/mochitest.ini25
-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.html130
-rw-r--r--dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckNoPropagation.html43
-rw-r--r--dom/tests/mochitest/storageevent/test_storageSessionStorageEventCheckPropagation.html43
15 files changed, 842 insertions, 0 deletions
diff --git a/dom/tests/mochitest/storageevent/frameLocalStorageMaster.html b/dom/tests/mochitest/storageevent/frameLocalStorageMaster.html
new file mode 100644
index 0000000000..55cbad1d28
--- /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;
+});
+
+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', 'http://mochi.test:8888');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameLocalStorageSlaveEqual.html b/dom/tests/mochitest/storageevent/frameLocalStorageSlaveEqual.html
new file mode 100644
index 0000000000..ad3738bed2
--- /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);
+});
+
+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', 'http://mochi.test:8888');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameLocalStorageSlaveNotEqual.html b/dom/tests/mochitest/storageevent/frameLocalStorageSlaveNotEqual.html
new file mode 100644
index 0000000000..248604b400
--- /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;
+});
+
+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', 'http://mochi.test:8888');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html b/dom/tests/mochitest/storageevent/frameSessionStorageMasterEqual.html
new file mode 100644
index 0000000000..595e21351b
--- /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;
+});
+
+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', 'http://mochi.test:8888');">
+ <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 0000000000..6c66e085e0
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/frameSessionStorageMasterNotEqual.html
@@ -0,0 +1,70 @@
+<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;
+});
+
+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;
+}
+
+function startTest() {
+ postMsg('frame loaded', 'http://mochi.test:8888');
+ slaveFrame.location =
+ "http://example.com:80/tests/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html";
+}
+
+</script>
+
+</head>
+
+<body onload="startTest();">
+ <iframe 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 0000000000..c7326e9a89
--- /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);
+});
+
+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', 'http://example.com:80');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html b/dom/tests/mochitest/storageevent/frameSessionStorageSlaveNotEqual.html
new file mode 100644
index 0000000000..b86b3c02cc
--- /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;
+});
+
+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', 'http://example.org');">
+</body>
+</html>
diff --git a/dom/tests/mochitest/storageevent/interOriginFrame.js b/dom/tests/mochitest/storageevent/interOriginFrame.js
new file mode 100644
index 0000000000..f4b3d6c9ab
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/interOriginFrame.js
@@ -0,0 +1,63 @@
+let parentLocation = "";
+
+// The first time this gets called in a page, the location of the parent
+// should be passed in. This will be used as the target origin argument
+// for the postMessage call for all subsequent calls to postMsg().
+function postMsg(message, newParentLocation) {
+ if (newParentLocation) {
+ parentLocation = newParentLocation;
+ } else if (parentLocation == "") {
+ throw new Error("Failed to pass in newParentLocation");
+ }
+
+ parent.postMessage(message, parentLocation);
+}
+
+window.addEventListener("message", onMessageReceived);
+
+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 0000000000..733f88a32d
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/interOriginTest2.js
@@ -0,0 +1,60 @@
+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);
+
+function onMessageReceived(event) {
+ switch (event.data) {
+ // Indication of the frame onload event
+ case "frame loaded":
+ if (--frameLoadsPending) {
+ break;
+ }
+
+ // Indication of successfully finished step of a test
+ // Just fall through...
+ case "perf":
+ if (callMasterFrame) {
+ masterFrame.postMessage("step", "*");
+ } else if (slaveFrame) {
+ slaveFrame.postMessage("step", "*");
+ } else if (masterFrame.slaveFrame) {
+ 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 0000000000..49b2fb1e2d
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/mochitest.ini
@@ -0,0 +1,25 @@
+[DEFAULT]
+support-files =
+ frameLocalStorageMaster.html
+ frameLocalStorageSlaveEqual.html
+ frameLocalStorageSlaveNotEqual.html
+ frameSessionStorageMasterEqual.html
+ frameSessionStorageMasterNotEqual.html
+ frameSessionStorageSlaveEqual.html
+ frameSessionStorageSlaveNotEqual.html
+ interOriginFrame.js
+ interOriginTest2.js
+
+[test_storageLocalStorageEventCheckNoPropagation.html]
+skip-if =
+ http3
+[test_storageLocalStorageEventCheckPropagation.html]
+skip-if =
+ http3
+[test_storageNotifications.html]
+[test_storageSessionStorageEventCheckNoPropagation.html]
+skip-if =
+ http3
+[test_storageSessionStorageEventCheckPropagation.html]
+skip-if =
+ http3
diff --git a/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckNoPropagation.html b/dom/tests/mochitest/storageevent/test_storageLocalStorageEventCheckNoPropagation.html
new file mode 100644
index 0000000000..ee48abedba
--- /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 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 0000000000..a6d291e147
--- /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 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 0000000000..255de171de
--- /dev/null
+++ b/dom/tests/mochitest/storageevent/test_storageNotifications.html
@@ -0,0 +1,130 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>sessionStorage basic test</title>
+
+<script src="/tests/SimpleTest/SimpleTest.js"></script>
+<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+
+<script type="application/javascript">
+
+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]");
+
+ function onSessionStorageChanged(e) {
+ ok(expectedTypes.length, "Not more then expected events encountered");
+ is("sessionStorage", expectedTypes.shift(), "Expected session type of the storage notification");
+ tests.next();
+ }
+
+ function onLocalStorageChanged(e) {
+ ok(expectedTypes.length, "Not more then expected events encountered");
+ is("localStorage", expectedTypes.shift(), "Expected session type of the storage notification");
+ tests.next();
+ }
+
+ // Listen for storage notifications
+ SpecialPowers.addChromeEventListener("MozSessionStorageChanged", onSessionStorageChanged, true);
+ SpecialPowers.addChromeEventListener("MozLocalStorageChanged", onLocalStorageChanged, true);
+
+ // 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.removeChromeEventListener("MozSessionStorageChanged", onSessionStorageChanged, true);
+ SpecialPowers.removeChromeEventListener("MozLocalStorageChanged", onLocalStorageChanged, true);
+
+ 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 0000000000..7ffa70dbf6
--- /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 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 0000000000..4f3402b6bb
--- /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 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>