1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 <title>Test for SharedWorker - Private Browsing
</title>
4 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
5 <link rel=
"stylesheet" type=
"text/css" href=
"chrome://mochikit/content/tests/SimpleTest/test.css"?>
9 <script type=
"application/javascript">
10 const {BrowserTestUtils} = ChromeUtils.importESModule(
11 "resource://testing-common/BrowserTestUtils.sys.mjs"
15 var contentPage =
"http://mochi.test:8888/chrome/dom/workers/test/empty.html";
17 function testOnWindow(aIsPrivate, aCallback) {
18 var win = mainWindow.OpenBrowserWindow({private: aIsPrivate});
19 win.addEventListener(
"load", function() {
20 win.addEventListener(
"DOMContentLoaded", function onInnerLoad() {
21 if (win.content.location.href != contentPage) {
22 BrowserTestUtils.startLoadingURIString(win.gBrowser, contentPage);
26 win.removeEventListener(
"DOMContentLoaded", onInnerLoad, true);
27 SimpleTest.executeSoon(function() { aCallback(win); });
29 }, {capture: true, once: true});
32 function setupWindow() {
33 mainWindow = window.browsingContext.topChromeWindow;
41 testOnWindow(false, function(aWin) {
44 testOnWindow(true, function(win) {
47 var sharedWorker1 = new wP.content.SharedWorker('sharedWorker_privateBrowsing.js');
48 sharedWorker1.port.onmessage = function(event) {
49 is(event.data,
1,
"Only 1 sharedworker expected in the private window");
51 var sharedWorker2 = new wN.content.SharedWorker('sharedWorker_privateBrowsing.js');
52 sharedWorker2.port.onmessage = function(event1) {
53 is(event1.data,
1,
"Only 1 sharedworker expected in the normal window");
55 var sharedWorker3 = new wP.content.SharedWorker('sharedWorker_privateBrowsing.js');
56 sharedWorker3.port.onmessage = function(event2) {
57 is(event2.data,
2,
"Only 2 sharedworker expected in the private window");
66 function doSystemSharedWorkerTest() {
69 new wP.SharedWorker(
"chrome://mochitests/content/dom/workers/test/sharedWorker_privateBrowsing.js");
70 ok(true,
"system SharedWorker created without throwing or crashing!");
72 ok(false,
"system SharedWorker should not throw or crash");
80 doSystemSharedWorkerTest,
92 var step = steps.shift();
96 SimpleTest.waitForExplicitFinish();
97 SpecialPowers.pushPrefEnv({
"set": [
98 [
"browser.startup.page",
0],
99 [
"browser.startup.homepage_override.mstone",
"ignore"],