Files
palemoon27/dom/workers/test/test_sharedWorker_privateBrowsing.html
T
roytam1 963b86a51f import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1175138 P1 Make the dom.caches.testing.enabled pref available in workers. r=ehsan (fe47d0e0a)
- Bug 1175138 P2 Expose dom.serviceWorkers.testing.enabled to workers. r=ehsan (efab5d0d3)
- Bug 1160458 - Part 1: Use the CSP of the principal passed to CreateServiceWorker. r=nsm (4d0a1d742)
- Bug 1172948 - Part 3: Add an explicit test case to ensure that authenticated origins that have a non-authenticated parent cannot register a service worker; r=nsm (78b3087c9)
- Bug 803537 - XHR crashes in workers and in debug-builds when blob URLs are used from file scheme documents, r=khuey (aa86f77b7)
- Bug 1163900 - crash in mozilla::net::nsHttpChannelCacheKey::GetData(unsigned int*, nsACString_internal&), r=jduell (adb5ddb01)
- Bug 1147746 - Null check mInterceptListener in HttpChannelChild::ResetInterception; r=jdm (4c8c4e630)
- Bug 1157283 - Recreate IPC redirected HTTP channels as necessary after intercepting the request in the child. r=mayhemer (3b144e45e)
- Bug 1172884 P1 Properly decode body when intercepted response redirects. r=jduell (f49c37d4f)
- Bug 1172884 P2 Add test for synthesizing a redirect to a compressed resource. r=ehsan (823d2122a)
- Bug 1160458 - Part 2: Test. r=nsm (02b9fb3a0)
- Bug 1169249 - Unregister service worker registration when uninstalling a service-worker-enabled application. Tests. r=baku (5509a19d6)
- Bug 1177621 - SharedWorkers should not be shared between a private and a non-private documents, r=nsm (0836234c7)
- Bug 1175138 P3 Expose the devtools SW testing flag on workers. r=ehsan (aade20454)
- Bug 1173467 P3 Pass private browsing flag into CacheStorage factory methods. r=ehsan (c4d062a80)
- Bug 1173467 P4 Add a test to validate Cache in private browsing window. r=ehsan (dde897e69)
- Bug 1162487 - Enable the dom.caches.enabled pref in test_chrome_constructor.html; r=baku (2c73e2929)
- Bug 1175138 P4 Enable dom.caches.testing.enabled in existing tests. r=ehsan (c453e03fb)
- Bug 1175138 P5 Make CacheStorage reject on untrusted origins. r=ehsan (c85424d4e)
- Bug 1175138 P6 Add a simple test to verify CacheStorage rejects in http origin. r=ehsan (5832eb99d)
- Bug 1179567 - Make ServiceWorker keep its document and window alive; r=baku (1ae847884)
- Bug 1179982 - Fix all compile errors in dom/workers on non-unified build. r=mrbkap (d30bece64)
2021-05-14 09:30:14 +08:00

107 lines
3.1 KiB
HTML

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Test for SharedWorker - Private Browsing</title>
<script type="application/javascript" 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 Ci = Components.interfaces;
var mainWindow;
var prefBranch = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefBranch);
prefBranch.setIntPref("browser.startup.page", 0);
prefBranch.setCharPref("browser.startup.homepage_override.mstone", "ignore");
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 onLoad() {
win.removeEventListener("load", onLoad, false);
win.addEventListener("DOMContentLoaded", function onInnerLoad() {
if (win.content.location.href != contentPage) {
win.gBrowser.loadURI(contentPage);
return;
}
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
SimpleTest.executeSoon(function() { aCallback(win); });
}, true);
if (!aIsPrivate) {
win.gBrowser.loadURI(contentPage);
}
}, true);
}
function setupWindow() {
mainWindow = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
runTest();
}
var wN;
var wP;
function doTests() {
testOnWindow(false, function(aWin) {
wN = aWin;
testOnWindow(true, function(aWin) {
wP = aWin;
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(event) {
is(event.data, 1, "Only 1 sharedworker expected in the normal window");
var sharedWorker3 = new wP.content.SharedWorker('sharedWorker_privateBrowsing.js');
sharedWorker3.port.onmessage = function(event) {
is(event.data, 2, "Only 2 sharedworker expected in the private window");
SimpleTest.finish();
}
}
}
});
});
}
var steps = [
setupWindow,
doTests
];
function runTest() {
if (!steps.length) {
wN.close();
wP.close();
prefBranch.clearUserPref("browser.startup.page")
prefBranch.clearUserPref("browser.startup.homepage_override.mstone");
SimpleTest.finish();
return;
}
var step = steps.shift();
step();
}
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({"set": [["dom.workers.sharedWorkers.enabled", true]]}, runTest);
</script>
</body>
</html>