summaryrefslogtreecommitdiffstats
path: root/dom/workers/test/test_multi_sharedWorker_lifetimes.html
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/workers/test/test_multi_sharedWorker_lifetimes.html
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/workers/test/test_multi_sharedWorker_lifetimes.html')
-rw-r--r--dom/workers/test/test_multi_sharedWorker_lifetimes.html156
1 files changed, 156 insertions, 0 deletions
diff --git a/dom/workers/test/test_multi_sharedWorker_lifetimes.html b/dom/workers/test/test_multi_sharedWorker_lifetimes.html
new file mode 100644
index 000000000..a3f4dc9b5
--- /dev/null
+++ b/dom/workers/test/test_multi_sharedWorker_lifetimes.html
@@ -0,0 +1,156 @@
+<!--
+ Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/
+-->
+<!DOCTYPE HTML>
+<html>
+ <head>
+ <title>Test for SharedWorker</title>
+ <script src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css">
+ <script class="testbody" type="text/javascript;version=1.7">
+ "use strict";
+
+ const scrollbarPref = "layout.testing.overlay-scrollbars.always-visible";
+ const bfCacheEnabledPref = "browser.sessionhistory.cache_subframes";
+ const bfCacheDepthPref = "browser.sessionhistory.max_total_viewers";
+ const bfCacheDepth = 10;
+
+ const frameRelativeURL = "multi_sharedWorker_frame.html";
+ const storedData = "0123456789abcdefghijklmnopqrstuvwxyz";
+
+ let testGenerator = (function() {
+ SimpleTest.waitForExplicitFinish();
+
+ // Force scrollbar to always be shown. The scrollbar setting is
+ // necessary to avoid the fade-in/fade-out from evicting our document
+ // from the BF cache below. If bug 1049277 is fixed, then we can
+ // stop setting the scrollbar pref here.
+ SpecialPowers.pushPrefEnv({ set: [[scrollbarPref, true]] },
+ sendToGenerator);
+ yield undefined;
+
+ window.addEventListener("message", function(event) {
+ if (typeof(event.data) == "string") {
+ info(event.data);
+ } else {
+ sendToGenerator(event);
+ }
+ });
+
+ let frame = document.getElementById("frame");
+ frame.src = frameRelativeURL;
+ frame.onload = sendToGenerator;
+
+ yield undefined;
+
+ frame = frame.contentWindow;
+ frame.postMessage({ command: "retrieve" }, "*");
+
+ let event = yield undefined;
+ ok(event instanceof MessageEvent, "Got a MessageEvent");
+ is(event.source, frame, "Correct window got the event");
+ is(event.data.type, "result", "Got a result message");
+ is(event.data.data, undefined, "No data stored yet");
+
+ frame.postMessage({ command: "store", data: storedData }, "*");
+ frame.postMessage({ command: "retrieve" }, "*");
+
+ event = yield undefined;
+ ok(event instanceof MessageEvent, "Got a MessageEvent");
+ is(event.source, frame, "Correct window got the event");
+ is(event.data.type, "result", "Got a result message");
+ is(event.data.data, storedData, "Got stored data");
+
+ // Navigate when the bfcache is disabled.
+ info("Navigating to about:blank");
+ frame = document.getElementById("frame");
+ frame.onload = sendToGenerator;
+ frame.src = "about:blank";
+ frame.contentWindow.document.body.offsetTop;
+
+ yield undefined;
+
+ info("Navigating to " + frameRelativeURL);
+ frame.src = frameRelativeURL;
+ frame.contentWindow.document.body.offsetTop;
+
+ yield undefined;
+
+ frame = frame.contentWindow;
+ frame.postMessage({ command: "retrieve" }, "*");
+
+ event = yield undefined;
+ ok(event instanceof MessageEvent, "Got a MessageEvent");
+ is(event.source, frame, "Correct window got the event");
+ is(event.data.type, "result", "Got a result message");
+ is(event.data.data, undefined, "No data stored");
+
+ frame.postMessage({ command: "store", data: storedData }, "*");
+ frame.postMessage({ command: "retrieve" }, "*");
+
+ event = yield undefined;
+ ok(event instanceof MessageEvent, "Got a MessageEvent");
+ is(event.source, frame, "Correct window got the event");
+ is(event.data.type, "result", "Got a result message");
+ is(event.data.data, storedData, "Got stored data");
+
+ info("Enabling '" + bfCacheEnabledPref + "' pref");
+ SpecialPowers.pushPrefEnv({ set: [[bfCacheEnabledPref, true],
+ [bfCacheDepthPref, bfCacheDepth]] },
+ sendToGenerator);
+ yield undefined;
+
+ // Navigate when the bfcache is enabled.
+ frame = document.getElementById("frame");
+ frame.onload = sendToGenerator;
+
+ info("Navigating to about:blank");
+ frame.src = "about:blank";
+ frame.contentWindow.document.body.offsetTop;
+
+ yield undefined;
+
+ for (let i = 0; i < 3; i++) {
+ info("Running GC");
+ SpecialPowers.exactGC(sendToGenerator);
+ yield undefined;
+
+ info("Waiting the event queue to clear");
+ SpecialPowers.executeSoon(sendToGenerator);
+ yield undefined;
+ }
+
+ info("Navigating to " + frameRelativeURL);
+ frame.src = frameRelativeURL;
+ frame.contentWindow.document.body.offsetTop;
+
+ yield undefined;
+
+ frame = frame.contentWindow;
+ frame.postMessage({ command: "retrieve" }, "*");
+
+ event = yield undefined;
+ ok(event instanceof MessageEvent, "Got a MessageEvent");
+ is(event.source, frame, "Correct window got the event");
+ is(event.data.type, "result", "Got a result message");
+ is(event.data.data, storedData, "Still have data stored");
+
+ info("Resetting '" + bfCacheEnabledPref + "' pref");
+ SpecialPowers.popPrefEnv(sendToGenerator);
+ yield undefined;
+
+ window.removeEventListener("message", sendToGenerator);
+
+ SimpleTest.finish();
+ yield undefined;
+ })();
+
+ let sendToGenerator = testGenerator.send.bind(testGenerator);
+
+ </script>
+ </head>
+ <body onload="testGenerator.next();">
+ <iframe id="frame"></iframe>
+ </body>
+</html>