gecko-dev/dom/serviceworkers/test/test_nofetch_handler.html
Kris Maglione 219ed0cc06 Bug 1454813: Part 2b - Rename SpawnTask.js to AddTask.js. r=florian
The old name no longer makes sense, since it no longer exports an spawn_task
symbol, and add_task is what we really care about.

MozReview-Commit-ID: IE7B8Czv8DH

--HG--
rename : testing/mochitest/tests/SimpleTest/SpawnTask.js => testing/mochitest/tests/SimpleTest/AddTask.js
extra : rebase_source : 03bca5aa69a7625a49b4455a6c96ce4c59de3a5a
2018-04-18 11:43:45 -07:00

59 lines
2.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<head>
<title>Test for Bugs 1181127 and 1325101</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/AddTask.js"></script>
<script src="error_reporting_helpers.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
</head>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1181127">Mozilla Bug 1181127</a>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1181127">Mozilla Bug 1325101</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
<script src="utils.js"></script>
<script class="testbody" type="text/javascript">
add_task(function setupPrefs() {
return SpecialPowers.pushPrefEnv({"set": [
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
// Make sure the event handler during the install event persists. This ensures
// the reason for which the interception doesn't occur is because of the
// handlesFetch=false flag from ServiceWorkerInfo.
["dom.serviceWorkers.idle_timeout", 299999],
]});
});
var iframeg;
function create_iframe(url) {
return new Promise(function(res) {
iframe = document.createElement('iframe');
iframe.src = url;
iframe.onload = function() { res(iframe) }
document.body.appendChild(iframe);
iframeg = iframe;
})
}
add_task(async function test_nofetch_worker() {
let registration = await navigator.serviceWorker.register(
"nofetch_handler_worker.js", { scope: "./nofetch_handler_worker/"} )
.then(swr => waitForState(swr.installing, 'activated', swr));
let iframe = await create_iframe("./nofetch_handler_worker/doesnt_exist.html");
ok(!iframe.contentDocument.body.innerHTML.includes("intercepted"), "Request was not intercepted.");
await SpecialPowers.popPrefEnv();
await registration.unregister();
});
</script>
</body>
</html>