Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test gets skipped with pattern: xorigin OR http3 OR http2
- Manifest: dom/serviceworkers/test/mochitest-dFPI.toml includes dom/serviceworkers/test/mochitest-common.toml
- Manifest: dom/serviceworkers/test/mochitest.toml includes dom/serviceworkers/test/mochitest-common.toml
<!--
Any copyright is dedicated to the Public Domain.
-->
<!DOCTYPE HTML>
<html>
<head>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<p id="display"></p>
<div id="content" style="display: none">
<iframe></iframe>
</div>
<pre id="test"></pre>
<script class="testbody" type="text/javascript">
var iframe;
function runTest() {
navigator.serviceWorker.ready.then(setupSW);
navigator.serviceWorker.register("serviceworker_not_sharedworker.js",
{scope: SCOPE});
}
var sw, worker;
function setupSW(registration) {
sw = registration.waiting || registration.active;
worker = new SharedWorker("serviceworker_not_sharedworker.js", SCOPE);
worker.port.start();
iframe = document.querySelector("iframe");
iframe.src = "message_receiver.html";
iframe.onload = function() {
window.onmessage = function(e) {
is(e.data.result, "serviceworker", "We should be talking to a service worker");
window.onmessage = null;
worker.port.onmessage = function(msg) {
is(msg.data.result, "sharedworker", "We should be talking to a shared worker");
registration.unregister().then(function(success) {
ok(success, "unregister should succeed");
SimpleTest.finish();
}, function(ex) {
dump("Unregistering the SW failed with " + ex + "\n");
SimpleTest.finish();
});
};
worker.port.postMessage({msg: "whoareyou"});
};
sw.postMessage({msg: "whoareyou"});
};
}
SimpleTest.waitForExplicitFinish();
onload = function() {
SpecialPowers.pushPrefEnv({"set": [
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true]
]}, runTest);
};
</script>
</pre>
</body>
</html>