Files
palemoon27/dom/workers/test/serviceworkers/test_request_context.js
T
roytam1 9e4ed9857d import changes from `dev' branch of rmottola/Arctic-Fox:
- Bug 1183825 - Hide PushMessageData methods until we support sending push data. r=mt,smaug (c07f6b6c9)
- Bug 1186880 - Performance timing api in workers should output entries if preference is enabled. r=baku (642bd335a)
- Bug 1188091 - Fix the exposure of Push interfaces; r=dougt,bzbarsky,nsm Currently we don't check the dom.push.enabled pref in some cases for some of these interfaces.  This patch unifies how all of these interfaces are exposed to Window, Worker, and ServiceWorker. (dbe4ebfcc)
- Bug 1188062 - Unship Request.context; r=baku (6ca2ebcf6)
- Bug 1162714 - Don't let YCM generate machc. r=ehsan (7c5f36c12)
- Bug 1160897 - Fixing .ycm_extra_conf for Fennec. r=ehsan (22adf0705)
- goanna->gecko (94b69bd6c)
- improve (e87b53162)
- Bug 1147939 - The expression decompiler can't assume that it's called directly from script. (r=bhackett) (4759a5210)
- Bug 1188609 - Remove mirroring support from RokuApp (Toolkit) r=snorp (81a0bb66a)
- Bug 1050749 - Expose BatteryManager via getBattery() returning a Promise. r=bz, r=baku, r=jgraham (67d2dd502)
- Bug 1182347 - Remove nsIPrincipal::cookieJar. r=sicking (855d0e8ce)
- remove double method, probably misspach (3c256c5b4)
- Bug 1182357 - Add an API to mint nsExpandedPrincipals. r=mrbkap (42de17cfd)
- Bug 1172080 - Part 1: Throw when requesting origin for poorly behaved URIs, r=bholley (c8410f3c6)
- Bug 1124126 - Retry database connection for the case of corrupted permissions.sqlite. r=bsmedberg (748e9205a)
2021-12-23 09:44:29 +08:00

78 lines
2.6 KiB
JavaScript

// Copied from /dom/plugins/test/mochitest/utils.js
function getTestPlugin(pluginName) {
var ph = SpecialPowers.Cc["@mozilla.org/plugin/host;1"]
.getService(SpecialPowers.Ci.nsIPluginHost);
var tags = ph.getPluginTags();
var name = pluginName || "Test Plug-in";
for (var tag of tags) {
if (tag.name == name) {
return tag;
}
}
ok(false, "Could not find plugin tag with plugin name '" + name + "'");
return null;
}
function setTestPluginEnabledState(newEnabledState, pluginName) {
var oldEnabledState = SpecialPowers.setTestPluginEnabledState(newEnabledState, pluginName);
if (!oldEnabledState) {
return;
}
var plugin = getTestPlugin(pluginName);
while (plugin.enabledState != newEnabledState) {
// Run a nested event loop to wait for the preference change to
// propagate to the child. Yuck!
SpecialPowers.Services.tm.currentThread.processNextEvent(true);
}
SimpleTest.registerCleanupFunction(function() {
SpecialPowers.setTestPluginEnabledState(oldEnabledState, pluginName);
});
}
setTestPluginEnabledState(SpecialPowers.Ci.nsIPluginTag.STATE_ENABLED);
function isMulet() {
try {
return SpecialPowers.getBoolPref("b2g.is_mulet");
} catch(e) {
return false;
}
}
var iframe;
function runTest() {
iframe = document.querySelector("iframe");
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/context/register.html";
window.onmessage = function(e) {
if (e.data.status == "ok") {
ok(e.data.result, e.data.message);
} else if (e.data.status == "todo") {
todo(e.data.result, e.data.message);
} else if (e.data.status == "registrationdone") {
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/context/index.html?" + gTest;
} else if (e.data.status == "done") {
iframe.src = "/tests/dom/workers/test/serviceworkers/fetch/context/unregister.html";
} else if (e.data.status == "unregistrationdone") {
window.onmessage = null;
ok(true, "Test finished successfully");
SimpleTest.finish();
}
};
}
SimpleTest.waitForExplicitFinish();
onload = function() {
SpecialPowers.pushPrefEnv({"set": [
["beacon.enabled", true],
["browser.send_pings", true],
["browser.send_pings.max_per_link", -1],
["dom.caches.enabled", true],
["dom.image.picture.enabled", true],
["dom.image.srcset.enabled", true],
["dom.requestcontext.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true],
["dom.serviceWorkers.interception.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
]}, runTest);
};