gecko-dev/dom/serviceworkers/test/test_serviceworkermanager.xul
Brian Grinstead 911776d674 Bug 1544322 - Part 3 - Remove the [type] attribute for multiline <script> tags loading files in chrome://mochikit/content/ r=bzbarsky
This is an autogenerated commit to handle scripts loading mochitest harness files, in
the case where the script src is on the line below the script tag.

This was generated with https://bug1544322.bmoattachments.org/attachment.cgi?id=9058170
using the `--part 3` argument.

Differential Revision: https://phabricator.services.mozilla.com/D27458

--HG--
extra : moz-landing-system : lando
2019-04-16 03:59:25 +00:00

80 lines
2.7 KiB
XML

<?xml version="1.0"?>
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<window title="Test for ServiceWorkerManager"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="test();">
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
<script type="application/javascript" src="chrome_helpers.js"/>
<script type="application/javascript">
<![CDATA[
let IFRAME_URL = EXAMPLE_URL + "serviceworkermanager_iframe.html";
function test() {
SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({'set': [
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
]}, function () {
(async function() {
let registrations = swm.getAllRegistrations();
is(registrations.length, 0);
let iframe = $("iframe");
let promise = waitForIframeLoad(iframe);
iframe.src = IFRAME_URL;
await promise;
info("Check that the service worker manager notifies its listeners " +
"when a service worker is registered.");
promise = waitForRegister(EXAMPLE_URL);
iframe.contentWindow.postMessage("register", "*");
let registration = await promise;
registrations = swm.getAllRegistrations();
is(registrations.length, 1);
is(registrations.queryElementAt(0, Ci.nsIServiceWorkerRegistrationInfo),
registration);
info("Check that the service worker manager does not notify its " +
"listeners when a service worker is registered with the same " +
"scope as an existing registration.");
let listener = {
onRegister: function () {
ok(false, "Listener should not have been notified.");
}
};
swm.addListener(listener);
iframe.contentWindow.postMessage("register", "*");
info("Check that the service worker manager notifies its listeners " +
"when a service worker is unregistered.");
promise = waitForUnregister(EXAMPLE_URL);
iframe.contentWindow.postMessage("unregister", "*");
registration = await promise;
swm.removeListener(listener);
registrations = swm.getAllRegistrations();
is(registrations.length, 0);
SimpleTest.finish();
})();
});
}
]]>
</script>
<body xmlns="http://www.w3.org/1999/xhtml">
<p id="display"></p>
<div id="content" style="display:none;"></div>
<pre id="test"></pre>
<iframe id="iframe"></iframe>
</body>
<label id="test-result"/>
</window>