mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-25 11:15:34 +00:00
5dec0e0beb
This patch was autogenerated by my decomponents.py It covers almost every file with the extension js, jsm, html, py, xhtml, or xul. It removes blank lines after removed lines, when the removed lines are preceded by either blank lines or the start of a new block. The "start of a new block" is defined fairly hackily: either the line starts with //, ends with */, ends with {, <![CDATA[, """ or '''. The first two cover comments, the third one covers JS, the fourth covers JS embedded in XUL, and the final two cover JS embedded in Python. This also applies if the removed line was the first line of the file. It covers the pattern matching cases like "var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;". It'll remove the entire thing if they are all either Ci, Cr, Cc or Cu, or it will remove the appropriate ones and leave the residue behind. If there's only one behind, then it will turn it into a normal, non-pattern matching variable definition. (For instance, "const { classes: Cc, Constructor: CC, interfaces: Ci, utils: Cu } = Components" becomes "const CC = Components.Constructor".) MozReview-Commit-ID: DeSHcClQ7cG --HG-- extra : rebase_source : d9c41878036c1ef7766ef5e91a7005025bc1d72b
112 lines
3.1 KiB
HTML
112 lines
3.1 KiB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<title>Test for ServiceWorker - 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">
|
|
|
|
var mainWindow;
|
|
|
|
var contentPage = "http://mochi.test:8888/chrome/dom/workers/test/empty.html";
|
|
var workerScope = "http://mochi.test:8888/chrome/dom/serviceworkers/test/";
|
|
var workerURL = workerScope + "worker.js";
|
|
|
|
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) {
|
|
win.gBrowser.loadURI(contentPage);
|
|
return;
|
|
}
|
|
|
|
win.removeEventListener("DOMContentLoaded", onInnerLoad, true);
|
|
SimpleTest.executeSoon(function() { aCallback(win); });
|
|
}, true);
|
|
|
|
if (!aIsPrivate) {
|
|
win.gBrowser.loadURI(contentPage);
|
|
}
|
|
}, {capture: true, once: 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 registration;
|
|
var wP;
|
|
|
|
function testPrivateWindow() {
|
|
testOnWindow(true, function(aWin) {
|
|
wP = aWin;
|
|
ok(!("serviceWorker" in wP.content.navigator), "ServiceWorkers are not available for private windows");
|
|
runTest();
|
|
});
|
|
}
|
|
|
|
function doTests() {
|
|
testOnWindow(false, function(aWin) {
|
|
wN = aWin;
|
|
ok("serviceWorker" in wN.content.navigator, "ServiceWorkers are available for normal windows");
|
|
|
|
wN.content.navigator.serviceWorker.register(workerURL,
|
|
{ scope: workerScope })
|
|
.then(function(aRegistration) {
|
|
registration = aRegistration;
|
|
ok(registration, "Registering a service worker in a normal window should succeed");
|
|
|
|
// Bug 1255621: We should be able to load a controlled document in a private window.
|
|
testPrivateWindow();
|
|
}, function(aError) {
|
|
ok(false, "Error registering worker in normal window: " + aError);
|
|
testPrivateWindow();
|
|
});
|
|
});
|
|
}
|
|
|
|
var steps = [
|
|
setupWindow,
|
|
doTests
|
|
];
|
|
|
|
function cleanup() {
|
|
wN.close();
|
|
wP.close();
|
|
|
|
SimpleTest.finish();
|
|
}
|
|
|
|
function runTest() {
|
|
if (!steps.length) {
|
|
registration.unregister().then(cleanup, cleanup);
|
|
|
|
return;
|
|
}
|
|
|
|
var step = steps.shift();
|
|
step();
|
|
}
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
SpecialPowers.pushPrefEnv({"set": [
|
|
["dom.serviceWorkers.enabled", true],
|
|
["dom.serviceWorkers.testing.enabled", true],
|
|
["browser.startup.page", 0],
|
|
["browser.startup.homepage_override.mstone", "ignore"],
|
|
]}, runTest);
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|