1 // Copied from /dom/plugins/test/mochitest/utils.js
2 function getTestPlugin(pluginName) {
3 var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
4 .getService(SpecialPowers.Ci.nsIPluginHost);
5 var tags = ph.getPluginTags();
6 var name = pluginName || "Test Plug-in";
7 for (var tag of tags) {
8 if (tag.name == name) {
13 ok(false, "Could not find plugin tag with plugin name '" + name + "'");
16 function setTestPluginEnabledState(newEnabledState, pluginName) {
17 var oldEnabledState = SpecialPowers.setTestPluginEnabledState(newEnabledState, pluginName);
18 if (!oldEnabledState) {
21 var plugin = getTestPlugin(pluginName);
22 // Run a nested event loop to wait for the preference change to
23 // propagate to the child. Yuck!
24 SpecialPowers.Services.tm.spinEventLoopUntil(() => plugin.enabledState == newEnabledState);
25 SimpleTest.registerCleanupFunction(function() {
26 SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
29 setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
33 return SpecialPowers.getBoolPref("b2g.is_mulet");
41 iframe = document.querySelector("iframe");
42 iframe.src = "/tests/dom/serviceworkers/test/fetch/context/register.html";
43 window.onmessage = function(e) {
44 if (e.data.status == "ok") {
45 ok(e.data.result, e.data.message);
46 } else if (e.data.status == "todo") {
47 todo(e.data.result, e.data.message);
48 } else if (e.data.status == "registrationdone") {
49 iframe.src = "/tests/dom/serviceworkers/test/fetch/context/index.html?" + gTest;
50 } else if (e.data.status == "done") {
51 iframe.src = "/tests/dom/serviceworkers/test/fetch/context/unregister.html";
52 } else if (e.data.status == "unregistrationdone") {
53 window.onmessage = null;
54 ok(true, "Test finished successfully");
60 SimpleTest.waitForExplicitFinish();
62 SpecialPowers.pushPrefEnv({"set": [
63 ["beacon.enabled", true],
64 ["browser.send_pings", true],
65 ["browser.send_pings.max_per_link", -1],
66 ["dom.caches.enabled", true],
67 ["dom.requestcontext.enabled", true],
68 ["dom.serviceWorkers.exemptFromPerDomainMax", true],
69 ["dom.serviceWorkers.enabled", true],
70 ["dom.serviceWorkers.testing.enabled", true],