diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /dom/workers/test/test_sharedWorker_privateBrowsing.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/workers/test/test_sharedWorker_privateBrowsing.html')
-rw-r--r-- | dom/workers/test/test_sharedWorker_privateBrowsing.html | 102 |
1 files changed, 102 insertions, 0 deletions
diff --git a/dom/workers/test/test_sharedWorker_privateBrowsing.html b/dom/workers/test/test_sharedWorker_privateBrowsing.html new file mode 100644 index 0000000000..f76e3db307 --- /dev/null +++ b/dom/workers/test/test_sharedWorker_privateBrowsing.html @@ -0,0 +1,102 @@ +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <title>Test for SharedWorker - Private Browsing</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"?> +</head> +<body> + +<script type="application/javascript"> +const {BrowserTestUtils} = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm"); +var mainWindow; + +var contentPage = "http://mochi.test:8888/chrome/dom/workers/test/empty.html"; + +function testOnWindow(aIsPrivate, aCallback) { + var win = mainWindow.OpenBrowserWindow({private: aIsPrivate}); + win.addEventListener("load", function() { + win.addEventListener("DOMContentLoaded", function onInnerLoad() { + if (win.content.location.href != contentPage) { + BrowserTestUtils.loadURIString(win.gBrowser, contentPage); + return; + } + + win.removeEventListener("DOMContentLoaded", onInnerLoad, true); + SimpleTest.executeSoon(function() { aCallback(win); }); + }, true); + }, {capture: true, once: true}); +} + +function setupWindow() { + mainWindow = window.browsingContext.topChromeWindow; + runTest(); +} + +var wN; +var wP; + +function doTests() { + testOnWindow(false, function(aWin) { + wN = aWin; + + testOnWindow(true, function(win) { + wP = win; + + var sharedWorker1 = new wP.content.SharedWorker('sharedWorker_privateBrowsing.js'); + sharedWorker1.port.onmessage = function(event) { + is(event.data, 1, "Only 1 sharedworker expected in the private window"); + + var sharedWorker2 = new wN.content.SharedWorker('sharedWorker_privateBrowsing.js'); + sharedWorker2.port.onmessage = function(event1) { + is(event1.data, 1, "Only 1 sharedworker expected in the normal window"); + + var sharedWorker3 = new wP.content.SharedWorker('sharedWorker_privateBrowsing.js'); + sharedWorker3.port.onmessage = function(event2) { + is(event2.data, 2, "Only 2 sharedworker expected in the private window"); + runTest(); + } + } + } + }); + }); +} + +function doSystemSharedWorkerTest() { + try { + let chromeShared = + new wP.SharedWorker("chrome://mochitests/content/dom/workers/test/sharedWorker_privateBrowsing.js"); + ok(true, "system SharedWorker created without throwing or crashing!"); + } catch (_ex) { + ok(false, "system SharedWorker should not throw or crash"); + } + runTest(); +} + +var steps = [ + setupWindow, + doTests, + doSystemSharedWorkerTest, +]; + +function runTest() { + if (!steps.length) { + wN.close(); + wP.close(); + + SimpleTest.finish(); + return; + } + + var step = steps.shift(); + step(); +} + +SimpleTest.waitForExplicitFinish(); +SpecialPowers.pushPrefEnv({"set": [ + ["browser.startup.page", 0], + ["browser.startup.homepage_override.mstone", "ignore"], +]}, runTest); + +</script> +</body> +</html> |