Backed out 4 changesets (bug 1648545) for causing mass failures

Backed out changeset ac3d639547fa (bug 1648545)
Backed out changeset f63760c845f3 (bug 1648545)
Backed out changeset 652b48b10d37 (bug 1648545)
Backed out changeset 1ca7abd873d1 (bug 1648545)
This commit is contained in:
Noemi Erli
2023-05-26 02:12:58 +03:00
parent 423b61e69a
commit a08e78ef6e
90 changed files with 322 additions and 478 deletions

View File

@@ -90,8 +90,8 @@ const intermittently_loaded_scripts = {
"resource://testing-common/BrowserTestUtilsChild.sys.mjs", "resource://testing-common/BrowserTestUtilsChild.sys.mjs",
"resource://testing-common/ContentEventListenerChild.sys.mjs", "resource://testing-common/ContentEventListenerChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs", "resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://testing-common/SpecialPowersChild.sys.mjs", "resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://testing-common/WrapPrivileged.sys.mjs", "resource://specialpowers/WrapPrivileged.sys.mjs",
]), ]),
frameScripts: new Set([]), frameScripts: new Set([]),
processScripts: new Set([ processScripts: new Set([

View File

@@ -72,9 +72,9 @@ const intermittently_loaded_scripts = {
"chrome://remote/content/shared/Log.sys.mjs", "chrome://remote/content/shared/Log.sys.mjs",
"resource://testing-common/BrowserTestUtilsChild.sys.mjs", "resource://testing-common/BrowserTestUtilsChild.sys.mjs",
"resource://testing-common/ContentEventListenerChild.sys.mjs", "resource://testing-common/ContentEventListenerChild.sys.mjs",
"resource://testing-common/SpecialPowersChild.sys.mjs", "resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs", "resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://testing-common/WrapPrivileged.sys.mjs", "resource://specialpowers/WrapPrivileged.sys.mjs",
]), ]),
processScripts: new Set([]), processScripts: new Set([]),
}; };

View File

@@ -234,6 +234,9 @@ async function synthesizeMouse(browser, link, event) {
browser, browser,
[link, event], [link, event],
(linkInContent, eventInContent) => { (linkInContent, eventInContent) => {
const { EventUtils } = ChromeUtils.importESModule(
"resource://specialpowers/SpecialPowersEventUtils.sys.mjs"
);
const target = content.document.getElementById(linkInContent); const target = content.document.getElementById(linkInContent);
EventUtils.synthesizeMouseAtCenter(target, eventInContent, content); EventUtils.synthesizeMouseAtCenter(target, eventInContent, content);
return target.href; return target.href;

View File

@@ -155,7 +155,10 @@ async function clickOn(selector, beforeContentFn) {
} }
await SpecialPowers.spawn(lastTab.linkedBrowser, [selector], arg => { await SpecialPowers.spawn(lastTab.linkedBrowser, [selector], arg => {
/* eslint-env mozilla/chrome-script */ const { EventUtils } = ChromeUtils.importESModule(
"resource://specialpowers/SpecialPowersEventUtils.sys.mjs"
);
let element = content.document.querySelector(arg); let element = content.document.querySelector(arg);
return EventUtils.synthesizeClick(element); return EventUtils.synthesizeClick(element);
}); });

View File

@@ -7,13 +7,6 @@
const URL_FOUND = "resource://devtools/shared/DevToolsUtils.js"; const URL_FOUND = "resource://devtools/shared/DevToolsUtils.js";
const URL_NOT_FOUND = "resource://devtools/this/is/not/here.js"; const URL_NOT_FOUND = "resource://devtools/this/is/not/here.js";
// Disable `xpc::IsInAutomation()` so we don't crash when accessing a
// nonexistent resource URI.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
false
);
/** /**
* Test that non-existent files are handled correctly. * Test that non-existent files are handled correctly.
*/ */

View File

@@ -13,6 +13,9 @@
function triggerKey() { function triggerKey() {
SpecialPowers.loadChromeScript(() => { SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */ /* eslint-env mozilla/chrome-script */
const { EventUtils } = ChromeUtils.import(
"resource://specialpowers/SpecialPowersEventUtils.jsm"
);
var win = Services.wm.getMostRecentBrowserWindow(); var win = Services.wm.getMostRecentBrowserWindow();
for (let i = 0; i < 200; ++i) { for (let i = 0; i < 200; ++i) {
EventUtils.synthesizeKey("a", {}, win); EventUtils.synthesizeKey("a", {}, win);

View File

@@ -3,6 +3,9 @@
const { AppConstants } = ChromeUtils.importESModule( const { AppConstants } = ChromeUtils.importESModule(
"resource://gre/modules/AppConstants.sys.mjs" "resource://gre/modules/AppConstants.sys.mjs"
); );
const { ExtensionUtils } = ChromeUtils.import(
"resource://gre/modules/ExtensionUtils.jsm"
);
const { XPCShellContentUtils } = ChromeUtils.importESModule( const { XPCShellContentUtils } = ChromeUtils.importESModule(
"resource://testing-common/XPCShellContentUtils.sys.mjs" "resource://testing-common/XPCShellContentUtils.sys.mjs"
); );
@@ -16,10 +19,6 @@ XPCShellContentUtils.init(this);
let contentPage; let contentPage;
async function readBlob(key, sharedData = Services.cpmm.sharedData) { async function readBlob(key, sharedData = Services.cpmm.sharedData) {
const { ExtensionUtils } = ChromeUtils.import(
"resource://gre/modules/ExtensionUtils.jsm"
);
let reader = new FileReader(); let reader = new FileReader();
reader.readAsText(sharedData.get(key)); reader.readAsText(sharedData.get(key));
await ExtensionUtils.promiseEvent(reader, "loadend"); await ExtensionUtils.promiseEvent(reader, "loadend");
@@ -95,16 +94,21 @@ async function checkContentMaps(expected, parentOnly = false) {
if (!parentOnly) { if (!parentOnly) {
info("Checking out-of-process content map"); info("Checking out-of-process content map");
let contents = await contentPage.spawn([], getContents); let contents = await contentPage.spawn(undefined, getContents);
checkMap(contents, expected); checkMap(contents, expected);
} }
} }
async function loadContentPage() { async function loadContentPage() {
let page = await XPCShellContentUtils.loadContentPage("data:text/html,", { let page = await XPCShellContentUtils.loadContentPage("about:blank", {
remote, remote,
}); });
registerCleanupFunction(() => page.close()); registerCleanupFunction(() => page.close());
page.addFrameScriptHelper(`
var {ExtensionUtils} = ChromeUtils.import("resource://gre/modules/ExtensionUtils.jsm");
Cu.importGlobalProperties(["FileReader"]);
`);
return page; return page;
} }
@@ -228,7 +232,7 @@ add_task(async function test_sharedMap() {
sharedData.set("grick", true); sharedData.set("grick", true);
sharedData.flush(); sharedData.flush();
equal( equal(
await contentPage.spawn(["grick"], hasKey), await contentPage.spawn("grick", hasKey),
true, true,
"has() should see key after flush" "has() should see key after flush"
); );
@@ -236,7 +240,7 @@ add_task(async function test_sharedMap() {
sharedData.set("grack", true); sharedData.set("grack", true);
sharedData.flush(); sharedData.flush();
equal( equal(
await contentPage.spawn(["gruck"], hasKey), await contentPage.spawn("gruck", hasKey),
false, false,
"has() should return false for nonexistent key" "has() should return false for nonexistent key"
); );
@@ -289,12 +293,12 @@ add_task(async function test_blobs() {
); );
equal( equal(
await contentPage.spawn(["blob0"], readBlob), await contentPage.spawn("blob0", readBlob),
text[0], text[0],
"Expected text for blob0 in child 1 cpmm" "Expected text for blob0 in child 1 cpmm"
); );
equal( equal(
await contentPage.spawn(["blob1"], readBlob), await contentPage.spawn("blob1", readBlob),
text[1], text[1],
"Expected text for blob1 in child 1 cpmm" "Expected text for blob1 in child 1 cpmm"
); );
@@ -305,12 +309,12 @@ add_task(async function test_blobs() {
let page2 = await loadContentPage(); let page2 = await loadContentPage();
equal( equal(
await page2.spawn(["blob0"], readBlob), await page2.spawn("blob0", readBlob),
text[0], text[0],
"Expected text for blob0 in child 2 cpmm" "Expected text for blob0 in child 2 cpmm"
); );
equal( equal(
await page2.spawn(["blob1"], readBlob), await page2.spawn("blob1", readBlob),
text[1], text[1],
"Expected text for blob1 in child 2 cpmm" "Expected text for blob1 in child 2 cpmm"
); );
@@ -348,29 +352,29 @@ add_task(async function test_blobs() {
); );
equal( equal(
await contentPage.spawn(["blob0"], readBlob), await contentPage.spawn("blob0", readBlob),
text[2], text[2],
"Expected text for blob0 in child 1 cpmm" "Expected text for blob0 in child 1 cpmm"
); );
equal( equal(
await contentPage.spawn(["blob1"], readBlob), await contentPage.spawn("blob1", readBlob),
text[1], text[1],
"Expected text for blob1 in child 1 cpmm" "Expected text for blob1 in child 1 cpmm"
); );
equal( equal(
await page2.spawn(["blob0"], readBlob), await page2.spawn("blob0", readBlob),
text[2], text[2],
"Expected text for blob0 in child 2 cpmm" "Expected text for blob0 in child 2 cpmm"
); );
equal( equal(
await page2.spawn(["blob1"], readBlob), await page2.spawn("blob1", readBlob),
text[1], text[1],
"Expected text for blob1 in child 2 cpmm" "Expected text for blob1 in child 2 cpmm"
); );
deepEqual( deepEqual(
await page2.spawn(["data"], getKey), await page2.spawn("data", getKey),
data, data,
"Expected data for data key in child 2 cpmm" "Expected data for data key in child 2 cpmm"
); );

View File

@@ -88,7 +88,7 @@ async function ensureDataCleanup() {
// resulting install invocation. The installation's call to importScripts when evaluated // resulting install invocation. The installation's call to importScripts when evaluated
// will load the script directly out of the Cache API. // will load the script directly out of the Cache API.
function testSWUpdate(contentPage) { function testSWUpdate(contentPage) {
return contentPage.legacySpawn([], async () => { return contentPage.spawn([], async () => {
const oldReg = await this.content.navigator.serviceWorker.ready; const oldReg = await this.content.navigator.serviceWorker.ready;
const reg = await oldReg.update(); const reg = await oldReg.update();
const sw = reg.installing || reg.waiting || reg.active; const sw = reg.installing || reg.waiting || reg.active;
@@ -178,7 +178,7 @@ add_task(async function test_extension_invalid_sw_scripts_redirect_ignored() {
// Register the worker while the test extension isn't loaded and cannot // Register the worker while the test extension isn't loaded and cannot
// intercept and redirect the importedScripts requests. // intercept and redirect the importedScripts requests.
info("Register service worker from a content webpage"); info("Register service worker from a content webpage");
let workerMessage = await contentPage.legacySpawn([], async () => { let workerMessage = await contentPage.spawn([], async () => {
const reg = await this.content.navigator.serviceWorker.register("/sw.js"); const reg = await this.content.navigator.serviceWorker.register("/sw.js");
return new Promise(resolve => { return new Promise(resolve => {
const { port1, port2 } = new MessageChannel(); const { port1, port2 } = new MessageChannel();
@@ -281,7 +281,7 @@ add_task(async function test_filter_sw_script() {
"http://localhost/page.html" "http://localhost/page.html"
); );
let workerMessage = await contentPage.legacySpawn([], async () => { let workerMessage = await contentPage.spawn([], async () => {
const reg = await this.content.navigator.serviceWorker.register("/sw.js"); const reg = await this.content.navigator.serviceWorker.register("/sw.js");
return new Promise(resolve => { return new Promise(resolve => {
const { port1, port2 } = new MessageChannel(); const { port1, port2 } = new MessageChannel();
@@ -349,7 +349,7 @@ add_task(async function test_extension_redirect_sw_imported_script() {
// Register the worker while the test extension isn't loaded and cannot // Register the worker while the test extension isn't loaded and cannot
// intercept and redirect the importedScripts requests. // intercept and redirect the importedScripts requests.
let workerMessage = await contentPage.legacySpawn([], async () => { let workerMessage = await contentPage.spawn([], async () => {
const reg = await this.content.navigator.serviceWorker.register("/sw.js"); const reg = await this.content.navigator.serviceWorker.register("/sw.js");
return new Promise(resolve => { return new Promise(resolve => {
const { port1, port2 } = new MessageChannel(); const { port1, port2 } = new MessageChannel();

View File

@@ -26,6 +26,9 @@
// InputTaskManager properly // InputTaskManager properly
SpecialPowers.loadChromeScript(() => { SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */ /* eslint-env mozilla/chrome-script */
const { EventUtils } = ChromeUtils.import(
"resource://specialpowers/SpecialPowersEventUtils.jsm"
);
var win = Services.wm.getMostRecentBrowserWindow(); var win = Services.wm.getMostRecentBrowserWindow();
EventUtils.synthesizeKey("a", {}, win); EventUtils.synthesizeKey("a", {}, win);
EventUtils.synthesizeKey("b", {}, win); EventUtils.synthesizeKey("b", {}, win);

View File

@@ -14,6 +14,9 @@
input.focus(); input.focus();
SpecialPowers.loadChromeScript(() => { SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */ /* eslint-env mozilla/chrome-script */
const { EventUtils } = ChromeUtils.import(
"resource://specialpowers/SpecialPowersEventUtils.jsm"
);
var win = Services.wm.getMostRecentBrowserWindow(); var win = Services.wm.getMostRecentBrowserWindow();
EventUtils.synthesizeKey("a", {}, win); EventUtils.synthesizeKey("a", {}, win);
}); });

View File

@@ -3,13 +3,6 @@
const { AppConstants } = ChromeUtils.importESModule("resource://gre/modules/AppConstants.sys.mjs"); const { AppConstants } = ChromeUtils.importESModule("resource://gre/modules/AppConstants.sys.mjs");
// Disable `xpc::IsInAutomation()` so incomplete locales do not generate
// errors.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
false
);
add_task(function test_methods_presence() { add_task(function test_methods_presence() {
strictEqual(typeof Localization.prototype.formatValues, "function"); strictEqual(typeof Localization.prototype.formatValues, "function");
strictEqual(typeof Localization.prototype.formatMessages, "function"); strictEqual(typeof Localization.prototype.formatMessages, "function");

View File

@@ -3,13 +3,6 @@
const { AppConstants } = ChromeUtils.importESModule("resource://gre/modules/AppConstants.sys.mjs"); const { AppConstants } = ChromeUtils.importESModule("resource://gre/modules/AppConstants.sys.mjs");
// Disable `xpc::IsInAutomation()` so incomplete locales do not generate
// errors.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
false
);
add_task(function test_methods_calling() { add_task(function test_methods_calling() {
const l10nReg = new L10nRegistry(); const l10nReg = new L10nRegistry();

View File

@@ -9,7 +9,10 @@ add_task(async function test_explicit_object_prototype() {
const url = const url =
"http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_promise_userInteractionHandling.html"; "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_promise_userInteractionHandling.html";
await BrowserTestUtils.withNewTab(url, async browser => { await BrowserTestUtils.withNewTab(url, async browser => {
await SpecialPowers.spawn(browser, [], async () => { await ContentTask.spawn(browser, {}, async () => {
const { EventUtils } = ChromeUtils.importESModule(
"resource://specialpowers/SpecialPowersEventUtils.sys.mjs"
);
const DOMWindowUtils = EventUtils._getDOMWindowUtils(content.window); const DOMWindowUtils = EventUtils._getDOMWindowUtils(content.window);
is( is(
DOMWindowUtils.isHandlingUserInput, DOMWindowUtils.isHandlingUserInput,

View File

@@ -29,7 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=960820
// Check Components.stack, but first filter through the SpecialPowers junk. // Check Components.stack, but first filter through the SpecialPowers junk.
var stack = SpecialPowers.wrap(SpecialPowers.Components).stack; var stack = SpecialPowers.wrap(SpecialPowers.Components).stack;
while (/testing-common/.test(stack)) { while (/specialpowers/.test(stack)) {
stack = stack.caller; stack = stack.caller;
} }
ok(/clickCallback/.test(stack), "clickCallback should be reachable via Components.stack"); ok(/clickCallback/.test(stack), "clickCallback should be reachable via Components.stack");

View File

@@ -348,15 +348,15 @@ add_task(async function test_sharedMap_prefs() {
contentPage.addFrameScriptHelper(getPref); contentPage.addFrameScriptHelper(getPref);
let prefNames = Object.keys(TESTS); let prefNames = Object.keys(TESTS);
prefValues = await contentPage.legacySpawn(prefNames, getPrefs); prefValues = await contentPage.spawn(prefNames, getPrefs);
await runChecks("contentStartup"); await runChecks("contentStartup");
prefValues = await contentPage.legacySpawn(prefNames, getPrefs); prefValues = await contentPage.spawn(prefNames, getPrefs);
await runChecks("contentUpdate1"); await runChecks("contentUpdate1");
prefValues = await contentPage.legacySpawn(prefNames, getPrefs); prefValues = await contentPage.spawn(prefNames, getPrefs);
await runChecks("contentUpdate2"); await runChecks("contentUpdate2");
}); });

View File

@@ -66,7 +66,7 @@ add_task(async function test_sharedMap_static_prefs() {
registerCleanupFunction(() => contentPage.close()); registerCleanupFunction(() => contentPage.close());
/* eslint-disable no-shadow */ /* eslint-disable no-shadow */
let values = await contentPage.spawn([[PREF1_NAME, PREF2_NAME]], prefs => { let values = await contentPage.spawn([PREF1_NAME, PREF2_NAME], prefs => {
return prefs.map(pref => Services.prefs.getBoolPref(pref)); return prefs.map(pref => Services.prefs.getBoolPref(pref));
}); });
/* eslint-enable no-shadow */ /* eslint-enable no-shadow */

View File

@@ -37,7 +37,7 @@ export const CookieXPCShellUtils = {
async getCookieStringFromDocument(uri, options = {}) { async getCookieStringFromDocument(uri, options = {}) {
const contentPage = await this.loadContentPage(uri, options); const contentPage = await this.loadContentPage(uri, options);
const cookies = await contentPage.spawn( const cookies = await contentPage.spawn(
[], null,
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
() => content.document.cookie () => content.document.cookie
); );
@@ -48,7 +48,7 @@ export const CookieXPCShellUtils = {
async setCookieToDocument(uri, set, options = {}) { async setCookieToDocument(uri, set, options = {}) {
const contentPage = await this.loadContentPage(uri, options); const contentPage = await this.loadContentPage(uri, options);
await contentPage.spawn( await contentPage.spawn(
[set], set,
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
cookies => (content.document.cookie = cookies) cookies => (content.document.cookie = cookies)
); );

View File

@@ -154,12 +154,10 @@ async function do_set_cookies(uri, channel, session, expected) {
const thirdPartyUrl = "http://third.com/"; const thirdPartyUrl = "http://third.com/";
const contentPage = await CookieXPCShellUtils.loadContentPage(thirdPartyUrl); const contentPage = await CookieXPCShellUtils.loadContentPage(thirdPartyUrl);
await contentPage.spawn( await contentPage.spawn(
[ {
{ cookie: "can=has" + suffix,
cookie: "can=has" + suffix, url: uri.spec,
url: uri.spec, },
},
],
async obj => { async obj => {
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
await new content.Promise(resolve => { await new content.Promise(resolve => {

View File

@@ -34,7 +34,11 @@ AddonTestUtils.createAppInfo(
); );
AddonTestUtils.overrideCertDB(); AddonTestUtils.overrideCertDB();
Services.prefs.setBoolPref("preferences.force-disable.check.once.policy", true); // Attempting to set the
// security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
// preference to enable Cu.exitIfInAutomation crashes, probably due to
// shutdown behaviors faked by AddonTestUtils.jsm's cleanup function.
do_disable_fast_shutdown();
add_task(async function run_test() { add_task(async function run_test() {
_("Test fixtures."); _("Test fixtures.");

View File

@@ -8,7 +8,11 @@ const { Service } = ChromeUtils.importESModule(
"resource://services-sync/service.sys.mjs" "resource://services-sync/service.sys.mjs"
); );
Services.prefs.setBoolPref("preferences.force-disable.check.once.policy", true); // Attempting to set the
// security.turn_off_all_security_so_that_viruses_can_take_over_this_computer
// preference to enable Cu.exitIfInAutomation crashes, probably due to
// shutdown behaviors faked by AddonTestUtils.jsm's cleanup function.
do_disable_fast_shutdown();
add_task(async function run_test() { add_task(async function run_test() {
let engine = Service.engineManager.get("prefs"); let engine = Service.engineManager.get("prefs");

View File

@@ -1,12 +0,0 @@
"use strict";
module.exports = {
extends: ["plugin:mozilla/xpcshell-test"],
overrides: [
{
files: "*.html",
env: { browser: true },
},
],
};

View File

@@ -1,139 +0,0 @@
"use strict";
/* eslint-disable @microsoft/sdl/no-insecure-url */
const { XPCShellContentUtils } = ChromeUtils.import(
"resource://testing-common/XPCShellContentUtils.jsm"
);
XPCShellContentUtils.init(this);
const HTML = String.raw`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<span id="span">Hello there.</span>
</body>
</html>`;
const server = XPCShellContentUtils.createHttpServer({
hosts: ["example.com", "example.org"],
});
server.registerPathHandler("/", (request, response) => {
response.setHeader("Content-Type", "text/html");
response.write(HTML);
});
/**
* Tests that the shared sandbox functionality for cross-process script
* execution works as expected. In particular, ensures that Assert methods
* report the correct diagnostics in the caller scope.
*/
let scope = this;
async function interceptDiagnostics(func) {
let originalRecord = scope.do_report_result;
try {
let diags = [];
scope.do_report_result = (passed, msg, stack) => {
diags.push({ passed, msg, stack });
};
await func();
return diags;
} finally {
scope.do_report_result = originalRecord;
}
}
add_task(async function () {
const frameSrc = "http://example.com/";
const subframeSrc = "http://example.org/";
let page = await XPCShellContentUtils.loadContentPage(frameSrc, {
remote: true,
remoteSubframes: true,
});
let { SpecialPowers, browsingContext } = page;
let expected = [
[false, "Thing - 1 == 2"],
[true, "Hmm - 1 == 1"],
[true, "Yay. - true == true"],
[false, "Boo!. - false == true"],
];
// Test that a representative variety of assertions work as expected, and
// trigger the expected calls to the harness's reporting function.
//
// Note: Assert.sys.mjs has its own tests, and defers all of its reporting to a
// single reporting function, so we don't need to test it comprehensively. We
// just need to make sure that the general functionality works as expected.
let tests = {
"SpecialPowers.spawn": () => {
return SpecialPowers.spawn(browsingContext, [], async () => {
Assert.equal(1, 2, "Thing");
Assert.equal(1, 1, "Hmm");
Assert.ok(true, "Yay.");
Assert.ok(false, "Boo!.");
});
},
"SpecialPowers.spawn-subframe": () => {
return SpecialPowers.spawn(browsingContext, [subframeSrc], async src => {
let subFrame = this.content.document.createElement("iframe");
subFrame.src = src;
this.content.document.body.appendChild(subFrame);
await new Promise(resolve => {
subFrame.addEventListener("load", resolve, { once: true });
});
await SpecialPowers.spawn(subFrame, [], () => {
Assert.equal(1, 2, "Thing");
Assert.equal(1, 1, "Hmm");
Assert.ok(true, "Yay.");
Assert.ok(false, "Boo!.");
});
});
},
"SpecialPowers.spawnChrome": () => {
return SpecialPowers.spawnChrome([], async () => {
Assert.equal(1, 2, "Thing");
Assert.equal(1, 1, "Hmm");
Assert.ok(true, "Yay.");
Assert.ok(false, "Boo!.");
});
},
"SpecialPowers.loadChromeScript": async () => {
let script = SpecialPowers.loadChromeScript(() => {
/* eslint-env mozilla/chrome-script */
this.addMessageListener("ping", () => "pong");
Assert.equal(1, 2, "Thing");
Assert.equal(1, 1, "Hmm");
Assert.ok(true, "Yay.");
Assert.ok(false, "Boo!.");
});
await script.sendQuery("ping");
script.destroy();
},
};
for (let [name, func] of Object.entries(tests)) {
info(`Starting task: ${name}`);
let diags = await interceptDiagnostics(func);
let results = diags.map(diag => [diag.passed, diag.msg]);
deepEqual(results, expected, "Got expected assertions");
}
});

View File

@@ -1,68 +0,0 @@
"use strict";
const { XPCShellContentUtils } = ChromeUtils.import(
"resource://testing-common/XPCShellContentUtils.jsm"
);
XPCShellContentUtils.init(this);
const HTML = String.raw`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<span id="span">Hello there.</span>
</body>
</html>`;
const server = XPCShellContentUtils.createHttpServer({
hosts: ["example.com"],
});
server.registerPathHandler("/", (request, response) => {
response.setHeader("Content-Type", "text/html");
response.write(HTML);
});
add_task(async function () {
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
let page = await XPCShellContentUtils.loadContentPage("http://example.com/", {
remote: true,
remoteSubframes: true,
});
let { SpecialPowers, browsingContext } = page;
let result = await SpecialPowers.spawn(
browsingContext,
["#span"],
selector => {
let elem = content.document.querySelector(selector);
return elem.textContent;
}
);
equal(result, "Hello there.", "Got correct element text from frame");
let line = Components.stack.lineNumber + 1;
let callback = () => {
let e = new Error("Hello.");
return { filename: e.fileName, lineNumber: e.lineNumber };
};
let loc = await SpecialPowers.spawn(browsingContext, [], callback);
equal(
loc.filename,
Components.stack.filename,
"Error should have correct script filename"
);
equal(
loc.lineNumber,
line + 2,
"Error should have correct script line number"
);
await page.close();
});

View File

@@ -1,2 +0,0 @@
[test_SpecialPowersSandbox.js]
[test_SpecialPowersSpawn.js]

View File

@@ -11,5 +11,4 @@ TESTING_JS_MODULES += [
] ]
MOCHITEST_MANIFESTS += ["Harness_sanity/mochitest.ini"] MOCHITEST_MANIFESTS += ["Harness_sanity/mochitest.ini"]
XPCSHELL_TESTS_MANIFESTS += ["Harness_sanity/xpcshell.ini"]
BROWSER_CHROME_MANIFESTS += ["browser/browser.ini"] BROWSER_CHROME_MANIFESTS += ["browser/browser.ini"]

View File

@@ -22,12 +22,12 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
ContentTask: "resource://testing-common/ContentTask.sys.mjs", ContentTask: "resource://testing-common/ContentTask.sys.mjs",
SpecialPowersParent: "resource://testing-common/SpecialPowersParent.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs", TestUtils: "resource://testing-common/TestUtils.sys.mjs",
}); });
XPCOMUtils.defineLazyModuleGetters(lazy, { XPCOMUtils.defineLazyModuleGetters(lazy, {
HttpServer: "resource://testing-common/httpd.js", HttpServer: "resource://testing-common/httpd.js",
MessageChannel: "resource://testing-common/MessageChannel.jsm",
}); });
XPCOMUtils.defineLazyServiceGetters(lazy, { XPCOMUtils.defineLazyServiceGetters(lazy, {
@@ -43,11 +43,22 @@ var gRemoteContentScripts = Services.appinfo.browserTabsRemoteAutostart;
const REMOTE_CONTENT_SUBFRAMES = Services.appinfo.fissionAutostart; const REMOTE_CONTENT_SUBFRAMES = Services.appinfo.fissionAutostart;
function frameScript() { function frameScript() {
const { MessageChannel } = ChromeUtils.import(
"resource://testing-common/MessageChannel.jsm"
);
// We need to make sure that the ExtensionPolicy service has been initialized // We need to make sure that the ExtensionPolicy service has been initialized
// as it sets up the observers that inject extension content scripts. // as it sets up the observers that inject extension content scripts.
Cc["@mozilla.org/addons/policy-service;1"].getService(); Cc["@mozilla.org/addons/policy-service;1"].getService();
Services.obs.notifyObservers(this, "tab-content-frameloader-created"); const messageListener = {
async receiveMessage({ target, messageName, recipient, data, name }) {
/* globals content */
let resp = await content.fetch(data.url, data.options);
return resp.text();
},
};
MessageChannel.addListener(this, "Test:Fetch", messageListener);
// eslint-disable-next-line mozilla/balanced-listeners, no-undef // eslint-disable-next-line mozilla/balanced-listeners, no-undef
addEventListener( addEventListener(
@@ -165,10 +176,6 @@ class ContentPage {
let chromeDoc = await promiseDocumentLoaded(chromeShell.document); let chromeDoc = await promiseDocumentLoaded(chromeShell.document);
let { SpecialPowers } = chromeDoc.ownerGlobal;
SpecialPowers.xpcshellScope = XPCShellContentUtils.currentScope;
SpecialPowers.setAsDefaultAssertHandler();
let browser = chromeDoc.createXULElement("browser"); let browser = chromeDoc.createXULElement("browser");
browser.setAttribute("type", "content"); browser.setAttribute("type", "content");
browser.setAttribute("disableglobalhistory", "true"); browser.setAttribute("disableglobalhistory", "true");
@@ -223,8 +230,12 @@ class ContentPage {
return this.browser.browsingContext; return this.browser.browsingContext;
} }
get SpecialPowers() { sendMessage(msg, data) {
return this.browser.ownerGlobal.SpecialPowers; return lazy.MessageChannel.sendMessage(
this.browser.messageManager,
msg,
data
);
} }
loadFrameScript(func) { loadFrameScript(func) {
@@ -252,26 +263,11 @@ class ContentPage {
return promiseBrowserLoaded(this.browser, url, redirectUrl); return promiseBrowserLoaded(this.browser, url, redirectUrl);
} }
async fetch(...args) { async fetch(url, options) {
return this.spawn(args, async (url, options) => { return this.sendMessage("Test:Fetch", { url, options });
let resp = await this.content.fetch(url, options);
return resp.text();
});
} }
spawn(params, task) { spawn(params, task) {
return this.SpecialPowers.spawn(this.browser, params, task);
}
// Like spawn(), but uses the legacy ContentTask infrastructure rather than
// SpecialPowers. Exists only because the author of the SpecialPowers
// migration did not have the time to fix all of the legacy users who relied
// on the old semantics.
//
// DO NOT USE IN NEW CODE
legacySpawn(params, task) {
lazy.ContentTask.setTestScope(XPCShellContentUtils.currentScope);
return lazy.ContentTask.spawn(this.browser, params, task); return lazy.ContentTask.spawn(this.browser, params, task);
} }
@@ -327,8 +323,6 @@ export var XPCShellContentUtils = {
scope.do_get_profile(); scope.do_get_profile();
this.initCommon(scope); this.initCommon(scope);
lazy.SpecialPowersParent.registerActor();
}, },
initMochitest(scope) { initMochitest(scope) {
@@ -441,7 +435,7 @@ export var XPCShellContentUtils = {
} }
let fetchScope = await fetchScopePromise; let fetchScope = await fetchScopePromise;
return fetchScope.fetch(url, options); return fetchScope.sendMessage("Test:Fetch", { url, options });
}, },
/** /**
@@ -476,6 +470,8 @@ export var XPCShellContentUtils = {
userContextId = undefined, userContextId = undefined,
} = {} } = {}
) { ) {
lazy.ContentTask.setTestScope(this.currentScope);
let contentPage = new ContentPage( let contentPage = new ContentPage(
remote, remote,
remoteSubframes, remoteSubframes,

View File

@@ -33,4 +33,3 @@ user_pref("gfx.color_management.force_srgb", true);
user_pref("gfx.color_management.mode", 1); user_pref("gfx.color_management.mode", 1);
// Don't enable remote tiles on new-tab pages in xpcshell // Don't enable remote tiles on new-tab pages in xpcshell
user_pref("browser.topsites.contile.enabled", false); user_pref("browser.topsites.contile.enabled", false);
user_pref("security.turn_off_all_security_so_that_viruses_can_take_over_this_computer", true);

View File

@@ -4,10 +4,6 @@
/* globals ExtensionAPI, Services, XPCOMUtils */ /* globals ExtensionAPI, Services, XPCOMUtils */
ChromeUtils.defineESModuleGetters(this, {
SpecialPowersParent: "resource://testing-common/SpecialPowersParent.sys.mjs",
});
XPCOMUtils.defineLazyServiceGetter( XPCOMUtils.defineLazyServiceGetter(
this, this,
"resProto", "resProto",
@@ -31,7 +27,20 @@ this.specialpowers = class extends ExtensionAPI {
.QueryInterface(Ci.nsIComponentRegistrar) .QueryInterface(Ci.nsIComponentRegistrar)
.autoRegister(manifest); .autoRegister(manifest);
SpecialPowersParent.registerActor(); ChromeUtils.registerWindowActor("SpecialPowers", {
allFrames: true,
includeChrome: true,
child: {
esModuleURI: "resource://specialpowers/SpecialPowersChild.sys.mjs",
observers: [
"chrome-document-global-created",
"content-document-global-created",
],
},
parent: {
esModuleURI: "resource://specialpowers/SpecialPowersParent.sys.mjs",
},
});
ChromeUtils.registerWindowActor("AppTestDelegate", { ChromeUtils.registerWindowActor("AppTestDelegate", {
parent: { parent: {
@@ -50,7 +59,7 @@ this.specialpowers = class extends ExtensionAPI {
} }
onShutdown() { onShutdown() {
SpecialPowersParent.unregisterActor(); ChromeUtils.unregisterWindowActor("SpecialPowers");
ChromeUtils.unregisterWindowActor("AppTestDelegate"); ChromeUtils.unregisterWindowActor("AppTestDelegate");
resProto.setSubstitution("specialpowers", null); resProto.setSubstitution("specialpowers", null);
} }

View File

@@ -5,7 +5,7 @@
const lazy = {}; const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
WrapPrivileged: "resource://testing-common/WrapPrivileged.sys.mjs", WrapPrivileged: "resource://specialpowers/WrapPrivileged.sys.mjs",
}); });
const Cm = Components.manager; const Cm = Components.manager;

View File

@@ -6,7 +6,7 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
FileUtils: "resource://gre/modules/FileUtils.sys.mjs", FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
WrapPrivileged: "resource://testing-common/WrapPrivileged.sys.mjs", WrapPrivileged: "resource://specialpowers/WrapPrivileged.sys.mjs",
}); });
const Cm = Components.manager; const Cm = Components.manager;

View File

@@ -12,16 +12,14 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, { ChromeUtils.defineESModuleGetters(lazy, {
ContentTaskUtils: "resource://testing-common/ContentTaskUtils.sys.mjs", ContentTaskUtils: "resource://testing-common/ContentTaskUtils.sys.mjs",
MockColorPicker: "resource://testing-common/MockColorPicker.sys.mjs", MockColorPicker: "resource://specialpowers/MockColorPicker.sys.mjs",
MockFilePicker: "resource://testing-common/MockFilePicker.sys.mjs", MockFilePicker: "resource://specialpowers/MockFilePicker.sys.mjs",
MockPermissionPrompt: MockPermissionPrompt: "resource://specialpowers/MockPermissionPrompt.sys.mjs",
"resource://testing-common/MockPermissionPrompt.sys.mjs",
PerTestCoverageUtils: PerTestCoverageUtils:
"resource://testing-common/PerTestCoverageUtils.sys.mjs", "resource://testing-common/PerTestCoverageUtils.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
SpecialPowersSandbox: SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.sys.mjs",
"resource://testing-common/SpecialPowersSandbox.sys.mjs", WrapPrivileged: "resource://specialpowers/WrapPrivileged.sys.mjs",
WrapPrivileged: "resource://testing-common/WrapPrivileged.sys.mjs",
}); });
ChromeUtils.defineModuleGetter( ChromeUtils.defineModuleGetter(
lazy, lazy,
@@ -311,7 +309,7 @@ export class SpecialPowersChild extends JSWindowActorChild {
case "Assert": case "Assert":
{ {
if ("info" in message.data) { if ("info" in message.data) {
(this.xpcshellScope || this.SimpleTest).info(message.data.info); this.SimpleTest.info(message.data.info);
break; break;
} }
@@ -322,8 +320,6 @@ export class SpecialPowersChild extends JSWindowActorChild {
if (SimpleTest) { if (SimpleTest) {
let expected = expectFail ? "fail" : "pass"; let expected = expectFail ? "fail" : "pass";
SimpleTest.record(passed, name, diag, stack, expected); SimpleTest.record(passed, name, diag, stack, expected);
} else if (this.xpcshellScope) {
this.xpcshellScope.do_report_result(passed, name, stack);
} else { } else {
// Well, this is unexpected. // Well, this is unexpected.
dump(name + "\n"); dump(name + "\n");
@@ -1587,9 +1583,7 @@ export class SpecialPowersChild extends JSWindowActorChild {
args, args,
task: String(task), task: String(task),
caller: Cu.getFunctionSourceLocation(task), caller: Cu.getFunctionSourceLocation(task),
hasHarness: hasHarness: typeof this.SimpleTest === "object",
typeof this.SimpleTest === "object" ||
typeof this.xpcshellScope === "object",
imports: this._spawnTaskImports, imports: this._spawnTaskImports,
}); });
} }
@@ -1671,13 +1665,6 @@ export class SpecialPowersChild extends JSWindowActorChild {
this._SimpleTest = val; this._SimpleTest = val;
} }
get xpcshellScope() {
return this._xpcshellScope;
}
set xpcshellScope(val) {
this._xpcshellScope = val;
}
async evictAllContentViewers() { async evictAllContentViewers() {
if (Services.appinfo.sessionHistoryInParent) { if (Services.appinfo.sessionHistoryInParent) {
await this.sendQuery("EvictAllContentViewers"); await this.sendQuery("EvictAllContentViewers");

View File

@@ -11,8 +11,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
HiddenFrame: "resource://gre/modules/HiddenFrame.sys.mjs", HiddenFrame: "resource://gre/modules/HiddenFrame.sys.mjs",
PerTestCoverageUtils: PerTestCoverageUtils:
"resource://testing-common/PerTestCoverageUtils.sys.mjs", "resource://testing-common/PerTestCoverageUtils.sys.mjs",
SpecialPowersSandbox: SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.sys.mjs",
"resource://testing-common/SpecialPowersSandbox.sys.mjs",
}); });
XPCOMUtils.defineLazyModuleGetters(lazy, { XPCOMUtils.defineLazyModuleGetters(lazy, {
@@ -183,27 +182,6 @@ export class SpecialPowersParent extends JSWindowActorParent {
this._taskActors = new Map(); this._taskActors = new Map();
} }
static registerActor() {
ChromeUtils.registerWindowActor("SpecialPowers", {
allFrames: true,
includeChrome: true,
child: {
esModuleURI: "resource://testing-common/SpecialPowersChild.sys.mjs",
observers: [
"chrome-document-global-created",
"content-document-global-created",
],
},
parent: {
esModuleURI: "resource://testing-common/SpecialPowersParent.sys.mjs",
},
});
}
static unregisterActor() {
ChromeUtils.unregisterWindowActor("SpecialPowers");
}
init() { init() {
Services.obs.addObserver(this._observer, "http-on-modify-request"); Services.obs.addObserver(this._observer, "http-on-modify-request");

View File

@@ -28,7 +28,7 @@ const SANDBOX_GLOBALS = [
"URL", "URL",
]; ];
const EXTRA_IMPORTS = { const EXTRA_IMPORTS = {
EventUtils: "resource://testing-common/SpecialPowersEventUtils.sys.mjs", EventUtils: "resource://specialpowers/SpecialPowersEventUtils.sys.mjs",
}; };
let expectFail = false; let expectFail = false;

View File

@@ -15,12 +15,10 @@ FINAL_TARGET_FILES += [
] ]
FINAL_TARGET_FILES.content += [ FINAL_TARGET_FILES.content += [
"../modules/Assert.sys.mjs",
"content/AppTestDelegate.sys.mjs", "content/AppTestDelegate.sys.mjs",
"content/AppTestDelegateChild.sys.mjs", "content/AppTestDelegateChild.sys.mjs",
"content/AppTestDelegateParent.sys.mjs", "content/AppTestDelegateParent.sys.mjs",
]
TESTING_JS_MODULES += [
"content/MockColorPicker.sys.mjs", "content/MockColorPicker.sys.mjs",
"content/MockFilePicker.sys.mjs", "content/MockFilePicker.sys.mjs",
"content/MockPermissionPrompt.sys.mjs", "content/MockPermissionPrompt.sys.mjs",
@@ -31,5 +29,9 @@ TESTING_JS_MODULES += [
"content/WrapPrivileged.sys.mjs", "content/WrapPrivileged.sys.mjs",
] ]
TESTING_JS_MODULES += [
"content/MockFilePicker.sys.mjs",
]
with Files("**"): with Files("**"):
BUG_COMPONENT = ("Testing", "Mochitest") BUG_COMPONENT = ("Testing", "Mochitest")

View File

@@ -34,6 +34,7 @@ var _tests_pending = 0;
var _cleanupFunctions = []; var _cleanupFunctions = [];
var _pendingTimers = []; var _pendingTimers = [];
var _profileInitialized = false; var _profileInitialized = false;
var _fastShutdownDisabled = false;
// Assigned in do_load_child_test_harness. // Assigned in do_load_child_test_harness.
var _XPCSHELL_PROCESS; var _XPCSHELL_PROCESS;
@@ -723,6 +724,16 @@ function _execute_test() {
!_AppConstants.ASAN && !_AppConstants.ASAN &&
!_AppConstants.TSAN !_AppConstants.TSAN
) { ) {
if (_fastShutdownDisabled) {
_testLogger.info("fast shutdown disabled by the test.");
return;
}
// Setting this pref is required for Cu.isInAutomation to return true.
_Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
Cu.exitIfInAutomation(); Cu.exitIfInAutomation();
} }
} }
@@ -1223,6 +1234,14 @@ function registerCleanupFunction(aFunction) {
_cleanupFunctions.push(aFunction); _cleanupFunctions.push(aFunction);
} }
/**
* Ensure the test finishes with a normal shutdown even when it could have
* otherwise used the fast Cu.exitIfInAutomation shutdown.
*/
function do_disable_fast_shutdown() {
_fastShutdownDisabled = true;
}
/** /**
* Returns the directory for a temp dir, which is created by the * Returns the directory for a temp dir, which is created by the
* test harness. Every test gets its own temp dir. * test harness. Every test gets its own temp dir.

View File

@@ -179,7 +179,7 @@ add_task(async function test_blob_url() {
"http://example.org/empty" "http://example.org/empty"
); );
let blobUrl = await contentPage.spawn([], async () => { let blobUrl = await contentPage.spawn(null, async () => {
// Create a third-party iframe and create a blob url in there. // Create a third-party iframe and create a blob url in there.
let f = this.content.document.createElement("iframe"); let f = this.content.document.createElement("iframe");
f.src = "http://foo.com/iframe"; f.src = "http://foo.com/iframe";

View File

@@ -122,7 +122,7 @@ add_task(async () => {
"http://example.org/empty" "http://example.org/empty"
); );
await contentPage.spawn([], () => await contentPage.spawn(null, () =>
// eslint-disable-next-line no-undef // eslint-disable-next-line no-undef
content.windowUtils.clearSharedStyleSheetCache() content.windowUtils.clearSharedStyleSheetCache()
); );

View File

@@ -4,13 +4,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Disable `xpc::IsInAutomation()` so that we don't generate fatal
// Localization errors.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
false
);
async function doOne(resource, id) { async function doOne(resource, id) {
let l10n = new Localization([resource], true); let l10n = new Localization([resource], true);
let value = await l10n.formatValue(id); let value = await l10n.formatValue(id);

View File

@@ -669,7 +669,7 @@ var ExtensionTestUtils = {
profileDir: null, profileDir: null,
init(scope) { init(scope) {
XPCShellContentUtils.ensureInitialized(scope); XPCShellContentUtils.init(scope);
this.currentScope = scope; this.currentScope = scope;

View File

@@ -243,7 +243,7 @@ async function test_frame_matching(meta) {
]; ];
// matchesWindowGlobal tests against content frames // matchesWindowGlobal tests against content frames
await contentPage.spawn([{ tests, urls, meta }], args => { await contentPage.spawn({ tests, urls, meta }, args => {
let { manifestVersion = 2, allowedOrigins = [], expectMatches } = args.meta; let { manifestVersion = 2, allowedOrigins = [], expectMatches } = args.meta;
this.windows = new Map(); this.windows = new Map();

View File

@@ -15,8 +15,6 @@ ChromeUtils.defineModuleGetter(
// The test extension uses an insecure update url. // The test extension uses an insecure update url.
Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false);
Services.prefs.setBoolPref("preferences.force-disable.check.once.policy", true);
const SETTINGS_ID = "test_settings_staged_restart_webext@tests.mozilla.org"; const SETTINGS_ID = "test_settings_staged_restart_webext@tests.mozilla.org";
const { createAppInfo, promiseShutdownManager, promiseStartupManager } = const { createAppInfo, promiseShutdownManager, promiseStartupManager } =

View File

@@ -242,7 +242,7 @@ async function testPolicy({
); );
let contentCSP = await contentPage.spawn( let contentCSP = await contentPage.spawn(
[`${baseURL}/content.html`], `${baseURL}/content.html`,
async src => { async src => {
let doc = this.content.document; let doc = this.content.document;

View File

@@ -54,7 +54,7 @@ add_task(async function test_contentscript_context() {
await extension.awaitMessage("content-script-show"); await extension.awaitMessage("content-script-show");
// Get the content script context and check that it points to the correct window. // Get the content script context and check that it points to the correct window.
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import( const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm" "resource://gre/modules/ExtensionContent.jsm"
); );
@@ -78,7 +78,7 @@ add_task(async function test_contentscript_context() {
await extension.awaitMessage("content-script-hide"); await extension.awaitMessage("content-script-hide");
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
Assert.equal( Assert.equal(
this.context.contentWindow, this.context.contentWindow,
null, null,
@@ -91,7 +91,7 @@ add_task(async function test_contentscript_context() {
await extension.awaitMessage("content-script-show"); await extension.awaitMessage("content-script-show");
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
Assert.equal( Assert.equal(
this.context.contentWindow, this.context.contentWindow,
this.content, this.content,
@@ -150,7 +150,7 @@ add_task(async function test_contentscript_context_incognito_not_allowed() {
{ privateBrowsing: true } { privateBrowsing: true }
); );
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import( const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm" "resource://gre/modules/ExtensionContent.jsm"
); );
@@ -183,7 +183,7 @@ add_task(async function test_contentscript_context_unload_while_in_bfcache() {
await extension.awaitMessage("content-script-ready"); await extension.awaitMessage("content-script-ready");
// Get the content script context and check that it points to the correct window. // Get the content script context and check that it points to the correct window.
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import( const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm" "resource://gre/modules/ExtensionContent.jsm"
); );
@@ -224,7 +224,7 @@ add_task(async function test_contentscript_context_unload_while_in_bfcache() {
await extension.awaitMessage("content-script-hide"); await extension.awaitMessage("content-script-hide");
await extension.unload(); await extension.unload();
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
await this.contextUnloadedPromise; await this.contextUnloadedPromise;
Assert.equal(this.context.unloaded, true, "Context has been unloaded"); Assert.equal(this.context.unloaded, true, "Context has been unloaded");
@@ -314,7 +314,7 @@ add_task(async function test_contentscript_context_valid_during_execution() {
let contentPage = await ExtensionTestUtils.loadContentPage( let contentPage = await ExtensionTestUtils.loadContentPage(
"http://example.com/dummy?first" "http://example.com/dummy?first"
); );
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
let context; let context;
let checkContextIsValid = description => { let checkContextIsValid = description => {
if (!context) { if (!context) {
@@ -340,13 +340,13 @@ add_task(async function test_contentscript_context_valid_during_execution() {
await extension.startup(); await extension.startup();
await extension.awaitMessage("content-script-ready"); await extension.awaitMessage("content-script-ready");
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
// Navigate so that the content page is frozen in the bfcache. // Navigate so that the content page is frozen in the bfcache.
this.content.location = "http://example.org/dummy?second"; this.content.location = "http://example.org/dummy?second";
}); });
await extension.awaitMessage("content-script-hide"); await extension.awaitMessage("content-script-hide");
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
// Navigate back so the content page is resurrected from the bfcache. // Navigate back so the content page is resurrected from the bfcache.
this.content.history.back(); this.content.history.back();
}); });

View File

@@ -81,7 +81,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-ready"); await extension.awaitMessage("content-script-ready");
// Get the content script context and check that it points to the correct window. // Get the content script context and check that it points to the correct window.
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import( const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm" "resource://gre/modules/ExtensionContent.jsm"
); );
@@ -105,7 +105,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-hide"); await extension.awaitMessage("content-script-hide");
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
Assert.equal( Assert.equal(
this.context.contentWindow, this.context.contentWindow,
null, null,
@@ -120,7 +120,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-show"); await extension.awaitMessage("content-script-show");
async function testWithoutBfcache() { async function testWithoutBfcache() {
return contentPage.legacySpawn(null, async () => { return contentPage.spawn(null, async () => {
Assert.equal( Assert.equal(
this.context.contentWindow, this.context.contentWindow,
this.content, this.content,
@@ -155,7 +155,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-unload"); await extension.awaitMessage("content-script-unload");
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
Assert.equal( Assert.equal(
this.context.sandbox, this.context.sandbox,
null, null,

View File

@@ -120,7 +120,7 @@ add_task(async function test_contentscript_create_iframe() {
info("testing APIs availability once the extension is unloaded..."); info("testing APIs availability once the extension is unloaded...");
await contentPage.legacySpawn(null, () => { await contentPage.spawn(null, () => {
this.iframeWindow = this.content[0]; this.iframeWindow = this.content[0];
Assert.ok(this.iframeWindow, "content script enabled iframe found"); Assert.ok(this.iframeWindow, "content script enabled iframe found");
@@ -136,7 +136,7 @@ add_task(async function test_contentscript_create_iframe() {
"test content script APIs not accessible from the frame once the extension is unloaded" "test content script APIs not accessible from the frame once the extension is unloaded"
); );
await contentPage.legacySpawn(null, () => { await contentPage.spawn(null, () => {
let win = Cu.waiveXrays(this.iframeWindow); let win = Cu.waiveXrays(this.iframeWindow);
ok( ok(
!Cu.isDeadWrapper(win.browser), !Cu.isDeadWrapper(win.browser),

View File

@@ -36,12 +36,12 @@ add_task(async function test_content_script_css() {
return style.maxWidth; return style.maxWidth;
} }
let maxWidth = await contentPage.spawn([], task); let maxWidth = await contentPage.spawn(null, task);
equal(maxWidth, "42px", "Stylesheet correctly applied"); equal(maxWidth, "42px", "Stylesheet correctly applied");
await extension.unload(); await extension.unload();
maxWidth = await contentPage.spawn([], task); maxWidth = await contentPage.spawn(null, task);
equal(maxWidth, "none", "Stylesheet correctly removed"); equal(maxWidth, "none", "Stylesheet correctly removed");
await contentPage.close(); await contentPage.close();

View File

@@ -105,7 +105,7 @@ add_task(async function test_importMaps_not_supported() {
); );
await extension.awaitMessage("done"); await extension.awaitMessage("done");
await contentPage.spawn([], async () => { await contentPage.spawn(null, async () => {
// Import maps should work for documents. // Import maps should work for documents.
let promise = content.eval(`import("simple2")`); let promise = content.eval(`import("simple2")`);
let mod = (await promise.wrappedJSObject).wrappedJSObject; let mod = (await promise.wrappedJSObject).wrappedJSObject;

View File

@@ -127,7 +127,7 @@ add_task(async function test_normal_import() {
await extension.awaitMessage("done"); await extension.awaitMessage("done");
// Web page can not import non-web-accessible files. // Web page can not import non-web-accessible files.
await contentPage.spawn([extension.uuid], async uuid => { await contentPage.spawn(extension.uuid, async uuid => {
let files = ["main.js", "module1.js", "module2.js"]; let files = ["main.js", "module1.js", "module2.js"];
for (let file of files) { for (let file of files) {
@@ -176,7 +176,7 @@ add_task(async function test_import_web_accessible() {
// Web page can import web-accessible files, // Web page can import web-accessible files,
// even after WebExtension imported the same files. // even after WebExtension imported the same files.
await contentPage.spawn([extension.uuid], async uuid => { await contentPage.spawn(extension.uuid, async uuid => {
let base = `moz-extension://${uuid}`; let base = `moz-extension://${uuid}`;
await Assert.rejects( await Assert.rejects(
@@ -248,7 +248,7 @@ add_task(async function test_import_web_accessible_after_page() {
// The web page imports the web-accessible files first, // The web page imports the web-accessible files first,
// when the WebExtension imports the same file, they should // when the WebExtension imports the same file, they should
// not be shared. // not be shared.
await contentPage.spawn([extension.uuid], async uuid => { await contentPage.spawn(extension.uuid, async uuid => {
let base = `moz-extension://${uuid}`; let base = `moz-extension://${uuid}`;
await Assert.rejects( await Assert.rejects(

View File

@@ -62,7 +62,7 @@ add_task(async function test_contentscript_reload_and_unload() {
); );
equal(contextEvents[0].url, tabUrl, "ExtensionContext URL = page"); equal(contextEvents[0].url, tabUrl, "ExtensionContext URL = page");
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
this.content.location.reload(); this.content.location.reload();
}); });
await extension.awaitMessage("contentscript-run"); await extension.awaitMessage("contentscript-run");

View File

@@ -40,7 +40,7 @@ add_task(async function content_script_unregistered_during_loadContentScript() {
content_scripts.map(() => extension.awaitMessage("content-script-executed")) content_scripts.map(() => extension.awaitMessage("content-script-executed"))
); );
const promiseDone = contentPage.legacySpawn(extension.id, extensionId => { const promiseDone = contentPage.spawn([extension.id], extensionId => {
const { ExtensionProcessScript } = ChromeUtils.import( const { ExtensionProcessScript } = ChromeUtils.import(
"resource://gre/modules/ExtensionProcessScript.jsm" "resource://gre/modules/ExtensionProcessScript.jsm"
); );

View File

@@ -16,7 +16,7 @@ ExtensionTestUtils.mockAppInfo();
// 4. Force GC and check that the weak reference has been invalidated. // 4. Force GC and check that the weak reference has been invalidated.
async function reloadTopContext(contentPage) { async function reloadTopContext(contentPage) {
await contentPage.legacySpawn(null, async () => { await contentPage.spawn(null, async () => {
let { TestUtils } = ChromeUtils.importESModule( let { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs" "resource://testing-common/TestUtils.sys.mjs"
); );
@@ -29,7 +29,7 @@ async function reloadTopContext(contentPage) {
} }
async function assertContextReleased(contentPage, description) { async function assertContextReleased(contentPage, description) {
await contentPage.legacySpawn(description, async assertionDescription => { await contentPage.spawn(description, async assertionDescription => {
// Force GC, see https://searchfox.org/mozilla-central/rev/b0275bc977ad7fda615ef34b822bba938f2b16fd/testing/talos/talos/tests/devtools/addon/content/damp.js#84-98 // Force GC, see https://searchfox.org/mozilla-central/rev/b0275bc977ad7fda615ef34b822bba938f2b16fd/testing/talos/talos/tests/devtools/addon/content/damp.js#84-98
// and https://searchfox.org/mozilla-central/rev/33c21c060b7f3a52477a73d06ebcb2bf313c4431/xpcom/base/nsMemoryReporterManager.cpp#2574-2585,2591-2594 // and https://searchfox.org/mozilla-central/rev/33c21c060b7f3a52477a73d06ebcb2bf313c4431/xpcom/base/nsMemoryReporterManager.cpp#2574-2585,2591-2594
let gcCount = 0; let gcCount = 0;
@@ -83,7 +83,7 @@ add_task(async function test_ContentScriptContextChild_in_child_frame() {
); );
await extension.awaitMessage("contentScriptLoaded"); await extension.awaitMessage("contentScriptLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import( const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm" "resource://gre/modules/ExtensionContent.jsm"
); );
@@ -135,7 +135,7 @@ add_task(async function test_ContentScriptContextChild_in_toplevel() {
); );
await extension.awaitMessage("contentScriptLoaded"); await extension.awaitMessage("contentScriptLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import( const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm" "resource://gre/modules/ExtensionContent.jsm"
); );
@@ -187,7 +187,7 @@ add_task(async function test_ExtensionPageContextChild_in_child_frame() {
); );
await extension.awaitMessage("extensionPageLoaded"); await extension.awaitMessage("extensionPageLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
let { ExtensionPageChild } = ChromeUtils.import( let { ExtensionPageChild } = ChromeUtils.import(
"resource://gre/modules/ExtensionPageChild.jsm" "resource://gre/modules/ExtensionPageChild.jsm"
); );
@@ -237,7 +237,7 @@ add_task(async function test_ExtensionPageContextChild_in_toplevel() {
); );
await extension.awaitMessage("extensionPageLoaded"); await extension.awaitMessage("extensionPageLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => { await contentPage.spawn(extension.id, async extensionId => {
let { ExtensionPageChild } = ChromeUtils.import( let { ExtensionPageChild } = ChromeUtils.import(
"resource://gre/modules/ExtensionPageChild.jsm" "resource://gre/modules/ExtensionPageChild.jsm"
); );
@@ -254,7 +254,7 @@ add_task(async function test_ExtensionPageContextChild_in_toplevel() {
await extension.awaitMessage("extensionPageLoaded"); await extension.awaitMessage("extensionPageLoaded");
// For some unknown reason, the context cannot forcidbly be released by the // For some unknown reason, the context cannot forcidbly be released by the
// garbage collector unless we wait for a short while. // garbage collector unless we wait for a short while.
await contentPage.spawn([], async () => { await contentPage.spawn(null, async () => {
let start = Date.now(); let start = Date.now();
// The treshold was found after running this subtest only, 300 times // The treshold was found after running this subtest only, 300 times
// in a release build (100 of xpcshell, xpcshell-e10s and xpcshell-remote). // in a release build (100 of xpcshell, xpcshell-e10s and xpcshell-remote).

View File

@@ -370,7 +370,7 @@ add_task(async function test_ext_page_3rdparty_cookies() {
clearAllCookies(); clearAllCookies();
await extPage.spawn( await extPage.spawn(
["http://example.com/page-with-tracker.html"], "http://example.com/page-with-tracker.html",
async iframeURL => { async iframeURL => {
const iframe = this.content.document.createElement("iframe"); const iframe = this.content.document.createElement("iframe");
iframe.setAttribute("src", iframeURL); iframe.setAttribute("src", iframeURL);
@@ -424,7 +424,7 @@ add_task(
} }
); );
let results = await extensionPage.spawn([], async () => { let results = await extensionPage.spawn(null, async () => {
let extFrame = this.content.document.querySelector("iframe#ext"); let extFrame = this.content.document.querySelector("iframe#ext");
let webFrame = this.content.document.querySelector("iframe#web"); let webFrame = this.content.document.querySelector("iframe#web");
@@ -459,7 +459,7 @@ add_task(
); );
results.extSubFrameContent = await contentPage.spawn( results.extSubFrameContent = await contentPage.spawn(
[extension.uuid], extension.uuid,
uuid => { uuid => {
return new Promise(resolve => { return new Promise(resolve => {
let frame = this.content.document.createElement("iframe"); let frame = this.content.document.createElement("iframe");

View File

@@ -28,7 +28,7 @@ add_task(async function load_moz_extension_with_and_without_cors() {
let contentPage = await ExtensionTestUtils.loadContentPage( let contentPage = await ExtensionTestUtils.loadContentPage(
"http://example.com/dummy" "http://example.com/dummy"
); );
await contentPage.spawn([EXT_BASE_URL], async EXT_BASE_URL => { await contentPage.spawn(EXT_BASE_URL, async EXT_BASE_URL => {
const { document, window } = this.content; const { document, window } = this.content;
async function checkScriptLoad({ setupScript, expectLoad, description }) { async function checkScriptLoad({ setupScript, expectLoad, description }) {
const scriptElem = document.createElement("script"); const scriptElem = document.createElement("script");

View File

@@ -144,7 +144,7 @@ async function testLoadInFrame({
const mainFrameUrl = urlEchoHtml(mainFrameDomain, mainFrameHtml); const mainFrameUrl = urlEchoHtml(mainFrameDomain, mainFrameHtml);
let contentPage = await ExtensionTestUtils.loadContentPage(mainFrameUrl); let contentPage = await ExtensionTestUtils.loadContentPage(mainFrameUrl);
let result = await contentPage.spawn([], () => { let result = await contentPage.spawn(null, () => {
return content.wrappedJSObject.resultPromise; return content.wrappedJSObject.resultPromise;
}); });
await contentPage.close(); await contentPage.close();
@@ -216,13 +216,13 @@ add_task(async function allowAllRequests_allows_request() {
"http://example.com/" "http://example.com/"
); );
Assert.equal( Assert.equal(
await contentPage.spawn([], () => content.document.URL), await contentPage.spawn(null, () => content.document.URL),
"http://example.com/", "http://example.com/",
"main_frame request should have been allowed by allowAllRequests" "main_frame request should have been allowed by allowAllRequests"
); );
async function checkCanFetch(url) { async function checkCanFetch(url) {
return contentPage.spawn([url], async url => { return contentPage.spawn(url, async url => {
try { try {
return await (await content.fetch(url)).text(); return await (await content.fetch(url)).text();
} catch (e) { } catch (e) {
@@ -876,7 +876,7 @@ add_task(async function allowAllRequests_during_and_after_navigation() {
const contentPage = await ExtensionTestUtils.loadContentPage( const contentPage = await ExtensionTestUtils.loadContentPage(
"http://example.com/?dummy_see_iframe_for_interesting_stuff" "http://example.com/?dummy_see_iframe_for_interesting_stuff"
); );
await contentPage.spawn([], async () => { await contentPage.spawn(null, async () => {
let f = content.document.createElement("iframe"); let f = content.document.createElement("iframe");
f.id = "frame_to_navigate"; f.id = "frame_to_navigate";
f.src = "/?init_WITH_AAR"; // allowAllRequests initially applies. f.src = "/?init_WITH_AAR"; // allowAllRequests initially applies.
@@ -886,7 +886,7 @@ add_task(async function allowAllRequests_during_and_after_navigation() {
}); });
}); });
async function navigateIframe(url) { async function navigateIframe(url) {
await contentPage.spawn([url], url => { await contentPage.spawn(url, url => {
let f = content.document.getElementById("frame_to_navigate"); let f = content.document.getElementById("frame_to_navigate");
content.frameLoadedPromise = new Promise(resolve => { content.frameLoadedPromise = new Promise(resolve => {
f.addEventListener("load", resolve, { once: true }); f.addEventListener("load", resolve, { once: true });
@@ -895,7 +895,7 @@ add_task(async function allowAllRequests_during_and_after_navigation() {
}); });
} }
async function waitForNavigationCompleted(expectLoad = true) { async function waitForNavigationCompleted(expectLoad = true) {
await contentPage.spawn([expectLoad], async expectLoad => { await contentPage.spawn(expectLoad, async expectLoad => {
if (expectLoad) { if (expectLoad) {
info("Waiting for frame load - if stuck the load never happened\n"); info("Waiting for frame load - if stuck the load never happened\n");
return content.frameLoadedPromise.then(() => {}); return content.frameLoadedPromise.then(() => {});
@@ -913,13 +913,13 @@ add_task(async function allowAllRequests_during_and_after_navigation() {
}); });
} }
async function assertIframePath(expectedPath, description) { async function assertIframePath(expectedPath, description) {
let actualPath = await contentPage.spawn([], () => { let actualPath = await contentPage.spawn(null, () => {
return content.frames[0].location.pathname; return content.frames[0].location.pathname;
}); });
Assert.equal(actualPath, expectedPath, description); Assert.equal(actualPath, expectedPath, description);
} }
async function assertHasAAR(expected, description) { async function assertHasAAR(expected, description) {
let actual = await contentPage.spawn([], async () => { let actual = await contentPage.spawn(null, async () => {
try { try {
await (await content.frames[0].fetch("/allowed")).text(); await (await content.frames[0].fetch("/allowed")).text();
return true; // allowAllRequests overrides block rule. return true; // allowAllRequests overrides block rule.
@@ -1029,20 +1029,20 @@ add_task(
"http://example.com/bfcache_test?1_aar_no" "http://example.com/bfcache_test?1_aar_no"
); );
async function navigateBackInHistory(expectedUrl) { async function navigateBackInHistory(expectedUrl) {
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
content.history.back(); content.history.back();
}); });
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
() => contentPage.browsingContext.currentURI.spec === expectedUrl, () => contentPage.browsingContext.currentURI.spec === expectedUrl,
`Waiting for history.back() to trigger navigation to ${expectedUrl}` `Waiting for history.back() to trigger navigation to ${expectedUrl}`
); );
await contentPage.spawn([expectedUrl], async expectedUrl => { await contentPage.spawn(expectedUrl, async expectedUrl => {
Assert.equal(content.location.href, expectedUrl, "URL after back"); Assert.equal(content.location.href, expectedUrl, "URL after back");
Assert.equal(content.document.body.textContent, "true", "from bfcache"); Assert.equal(content.document.body.textContent, "true", "from bfcache");
}); });
} }
async function checkCanFetch(url) { async function checkCanFetch(url) {
return contentPage.spawn([url], async url => { return contentPage.spawn(url, async url => {
try { try {
return await (await content.fetch(url)).text(); return await (await content.fetch(url)).text();
} catch (e) { } catch (e) {
@@ -1118,7 +1118,7 @@ add_task(
"http://example.com/?do_get" "http://example.com/?do_get"
); );
async function checkCanFetch(url) { async function checkCanFetch(url) {
return contentPage.spawn([url], async url => { return contentPage.spawn(url, async url => {
try { try {
return await (await content.fetch(url)).text(); return await (await content.fetch(url)).text();
} catch (e) { } catch (e) {
@@ -1135,7 +1135,7 @@ add_task(
); );
// Check fetch() after POST navigation in main_frame. // Check fetch() after POST navigation in main_frame.
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
let form = content.document.createElement("form"); let form = content.document.createElement("form");
form.action = "/?do_post"; form.action = "/?do_post";
form.method = "POST"; form.method = "POST";
@@ -1154,7 +1154,7 @@ add_task(
// Navigate back to the beginning and verify that allowAllRequests does not // Navigate back to the beginning and verify that allowAllRequests does not
// match any more. // match any more.
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
content.history.back(); content.history.back();
}); });
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
@@ -1168,7 +1168,7 @@ add_task(
); );
// Now navigate forwards to verify that the POST method is still seen. // Now navigate forwards to verify that the POST method is still seen.
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
content.history.forward(); content.history.forward();
}); });
await TestUtils.waitForCondition( await TestUtils.waitForCondition(
@@ -1183,7 +1183,7 @@ add_task(
); );
// Now check that adding a new history entry drops the POST method. // Now check that adding a new history entry drops the POST method.
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
content.history.pushState(null, null, "/?hist_p"); content.history.pushState(null, null, "/?hist_p");
}); });
await TestUtils.waitForCondition( await TestUtils.waitForCondition(

View File

@@ -622,7 +622,7 @@ add_task(async function responseHeaders_set_content_security_policy_header() {
async function testFetchAndCSP(url) { async function testFetchAndCSP(url) {
info(`testFetchAndCSP: ${url}`); info(`testFetchAndCSP: ${url}`);
let contentPage = await ExtensionTestUtils.loadContentPage(url); let contentPage = await ExtensionTestUtils.loadContentPage(url);
let cspTestResults = await contentPage.spawn([], async () => { let cspTestResults = await contentPage.spawn(null, async () => {
const { document } = content; const { document } = content;
async function doFetchAndCheckCSP(url) { async function doFetchAndCheckCSP(url) {
const cspTestResult = { url, violatedCSP: [] }; const cspTestResult = { url, violatedCSP: [] };
@@ -852,7 +852,7 @@ add_task(async function requestHeaders_and_responseHeaders_cookies() {
const url = `http://cookietest${pathAndQuery}`; const url = `http://cookietest${pathAndQuery}`;
info(`loadPageAndGetCookies: ${url}`); info(`loadPageAndGetCookies: ${url}`);
let contentPage = await ExtensionTestUtils.loadContentPage(url); let contentPage = await ExtensionTestUtils.loadContentPage(url);
let res = await contentPage.spawn([], () => { let res = await contentPage.spawn(null, () => {
const { document } = content; const { document } = content;
const sortCookies = s => s.split("; ").sort().join("; "); const sortCookies = s => s.split("; ").sort().join("; ");
return { return {
@@ -991,7 +991,7 @@ add_task(async function modifyHeaders_multiple_extensions() {
); );
async function checkHeaderActionResult(query, expectedHeaders, description) { async function checkHeaderActionResult(query, expectedHeaders, description) {
const url = `/responseheadersFixture?${query}`; const url = `/responseheadersFixture?${query}`;
const result = await contentPage.spawn([url], async url => { const result = await contentPage.spawn(url, async url => {
const res = await content.fetch(url); const res = await content.fetch(url);
return { return {
a: res.headers.get("a"), a: res.headers.get("a"),

View File

@@ -36,7 +36,7 @@ async function testMatchedByDNR(privateBrowsing) {
"http://example.com/?page", "http://example.com/?page",
{ privateBrowsing } { privateBrowsing }
); );
let wasRequestBlocked = await contentPage.legacySpawn(null, async () => { let wasRequestBlocked = await contentPage.spawn(null, async () => {
try { try {
await content.fetch("http://example.com/?fetch"); await content.fetch("http://example.com/?fetch");
return false; return false;

View File

@@ -108,7 +108,7 @@ async function runAsDNRExtension({ background, manifest }) {
// The DNR rule does not redirect the main frame. // The DNR rule does not redirect the main frame.
let contentPage = await ExtensionTestUtils.loadContentPage("http://from/"); let contentPage = await ExtensionTestUtils.loadContentPage("http://from/");
info(`Loading ${url}`); info(`Loading ${url}`);
await contentPage.spawn([url], async url => { await contentPage.spawn(url, async url => {
let { document } = this.content; let { document } = this.content;
let frame = document.createElement("iframe"); let frame = document.createElement("iframe");
frame.src = url; frame.src = url;

View File

@@ -91,7 +91,7 @@ add_task(async function dnr_ignores_navigation_to_restrictedDomains() {
let contentPage = await ExtensionTestUtils.loadContentPage( let contentPage = await ExtensionTestUtils.loadContentPage(
"http://restricted/?blockme" "http://restricted/?blockme"
); );
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
const { document } = content; const { document } = content;
Assert.equal(document.URL, "http://restricted/?blockme", "Same URL"); Assert.equal(document.URL, "http://restricted/?blockme", "Same URL");
Assert.equal(document.body.textContent, "response from server", "body"); Assert.equal(document.body.textContent, "response from server", "body");
@@ -109,7 +109,7 @@ add_task(async function dnr_ignores_css_import_at_restrictedDomains() {
let contentPage = await ExtensionTestUtils.loadContentPage( let contentPage = await ExtensionTestUtils.loadContentPage(
"http://restricted/" "http://restricted/"
); );
await contentPage.spawn([], async () => { await contentPage.spawn(null, async () => {
// Use wrappedJSObject so that all operations below are with the principal // Use wrappedJSObject so that all operations below are with the principal
// of the content instead of the system principal (from this ContentTask). // of the content instead of the system principal (from this ContentTask).
const { document } = content.wrappedJSObject; const { document } = content.wrappedJSObject;
@@ -220,7 +220,7 @@ add_task(
let contentPage = await ExtensionTestUtils.loadContentPage( let contentPage = await ExtensionTestUtils.loadContentPage(
"about:logo?blockme" "about:logo?blockme"
); );
await contentPage.spawn([], async () => { await contentPage.spawn(null, async () => {
const { document } = content; const { document } = content;
// To make sure that the test does not pass trivially, we verify that it // To make sure that the test does not pass trivially, we verify that it
// is not the system principal (because dnr_ignores_system_requests // is not the system principal (because dnr_ignores_system_requests

View File

@@ -49,11 +49,11 @@ async function contentFetch(initiatorURL, url, options) {
let contentPage = await ExtensionTestUtils.loadContentPage(initiatorURL); let contentPage = await ExtensionTestUtils.loadContentPage(initiatorURL);
// Sanity check: that the initiator is as specified, and not redirected. // Sanity check: that the initiator is as specified, and not redirected.
Assert.equal( Assert.equal(
await contentPage.spawn([], () => content.document.URL), await contentPage.spawn(null, () => content.document.URL),
initiatorURL, initiatorURL,
`Expected document load at: ${initiatorURL}` `Expected document load at: ${initiatorURL}`
); );
let result = await contentPage.spawn([{ url, options }], async args => { let result = await contentPage.spawn({ url, options }, async args => {
try { try {
let req = await content.fetch(args.url, args.options); let req = await content.fetch(args.url, args.options);
return { return {

View File

@@ -56,7 +56,7 @@ function createTestExtPageScript(name) {
}})("${name}");`; }})("${name}");`;
} }
const getExtensionContextIdAndURL = extensionId => { const getExtensionContextIdAndURL = ([extensionId]) => {
const { ExtensionProcessScript } = ChromeUtils.import( const { ExtensionProcessScript } = ChromeUtils.import(
"resource://gre/modules/ExtensionProcessScript.jsm" "resource://gre/modules/ExtensionProcessScript.jsm"
); );
@@ -78,10 +78,10 @@ const getExtensionContextIdAndURL = extensionId => {
return { contextIds, contextURLs }; return { contextIds, contextURLs };
}; };
const getExtensionContextStatusByContextId = ( const getExtensionContextStatusByContextId = ([
extensionId, extensionId,
extPageContextId extPageContextId,
) => { ]) => {
const { ExtensionProcessScript } = ChromeUtils.import( const { ExtensionProcessScript } = ChromeUtils.import(
"resource://gre/modules/ExtensionProcessScript.jsm" "resource://gre/modules/ExtensionProcessScript.jsm"
); );

View File

@@ -29,7 +29,7 @@ const l10n = new Localization([
"branding/brand.ftl", "branding/brand.ftl",
]); ]);
// Localization resources need to be first iterated outside a test // Localization resources need to be first iterated outside a test
l10n.formatValue("webext-perms-sideload-text"); l10n.formatValue("webext-perms-add");
AddonTestUtils.init(this); AddonTestUtils.init(this);
AddonTestUtils.overrideCertDB(); AddonTestUtils.overrideCertDB();

View File

@@ -1,9 +1,20 @@
"use strict"; "use strict";
const PREF_DISABLE_SECURITY =
"security.turn_off_all_security_so_that_" +
"viruses_can_take_over_this_computer";
const { EnterprisePolicyTesting } = ChromeUtils.importESModule( const { EnterprisePolicyTesting } = ChromeUtils.importESModule(
"resource://testing-common/EnterprisePolicyTesting.sys.mjs" "resource://testing-common/EnterprisePolicyTesting.sys.mjs"
); );
// Setting PREF_DISABLE_SECURITY tells the policy engine that we are in testing
// mode and enables restarting the policy engine without restarting the browser.
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
});
// Load policy engine // Load policy engine
Services.policies; // eslint-disable-line no-unused-expressions Services.policies; // eslint-disable-line no-unused-expressions

View File

@@ -52,7 +52,7 @@ add_task(async function test_extension_page_tabs_create_reload_and_close() {
"ExtensionContext URL after tab creation should be tab URL" "ExtensionContext URL after tab creation should be tab URL"
); );
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
this.content.location.reload(); this.content.location.reload();
}); });
let extensionPageURL2 = await extension.awaitMessage("extension page loaded"); let extensionPageURL2 = await extension.awaitMessage("extension page loaded");

View File

@@ -147,7 +147,7 @@ add_task(async function testSendMessage_and_remove_frame() {
"http://example.com/dummy" "http://example.com/dummy"
); );
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
let { document } = this.content; let { document } = this.content;
let frame = document.createElement("iframe"); let frame = document.createElement("iframe");
frame.src = "/data/file_sample.html"; frame.src = "/data/file_sample.html";
@@ -171,7 +171,7 @@ add_task(async function testConnect_and_remove_frame() {
"http://example.com/dummy" "http://example.com/dummy"
); );
await contentPage.spawn([], () => { await contentPage.spawn(null, () => {
let { document } = this.content; let { document } = this.content;
let frame = document.createElement("iframe"); let frame = document.createElement("iframe");
frame.src = "/data/file_sample.html"; frame.src = "/data/file_sample.html";

View File

@@ -290,7 +290,7 @@ add_task(async function test_userScripts_no_webext_apis() {
url, url,
ExtensionTestUtils.remoteContentScripts ? { remote: true } : undefined ExtensionTestUtils.remoteContentScripts ? { remote: true } : undefined
); );
let result = await contentPage.spawn([], async () => { let result = await contentPage.spawn(undefined, async () => {
return { return {
textContent: this.content.document.body.textContent, textContent: this.content.document.body.textContent,
url: this.content.location.href, url: this.content.location.href,
@@ -325,7 +325,7 @@ add_task(async function test_userScripts_no_webext_apis() {
let contentPage2 = await ExtensionTestUtils.loadContentPage(url2, { let contentPage2 = await ExtensionTestUtils.loadContentPage(url2, {
remote: true, remote: true,
}); });
let result2 = await contentPage2.spawn([], async () => { let result2 = await contentPage2.spawn(undefined, async () => {
return { return {
textContent: this.content.document.body.textContent, textContent: this.content.document.body.textContent,
url: this.content.location.href, url: this.content.location.href,

View File

@@ -125,8 +125,8 @@ add_task(async function test_userscripts_register_cookieStoreId() {
await extension.awaitMessage("last-content-script"); await extension.awaitMessage("last-content-script");
let result = await contentPage.spawn([], () => { let result = await contentPage.spawn(null, () => {
let textContent = content.document.body.textContent; let textContent = this.content.document.body.textContent;
// Omit the default content from file_sample.html. // Omit the default content from file_sample.html.
return textContent.replace("\n\nSample text\n\n\n\n", ""); return textContent.replace("\n\nSample text\n\n\n\n", "");
}); });

View File

@@ -109,7 +109,7 @@ add_task(async function test_stream_encoding_data() {
"http://example.com/lorem.html.gz" "http://example.com/lorem.html.gz"
); );
let content = await contentPage.spawn([], () => { let content = await contentPage.spawn(null, () => {
return this.content.document.body.textContent; return this.content.document.body.textContent;
}); });

View File

@@ -115,7 +115,7 @@ async function test_csp({
let contentPage = await ExtensionTestUtils.loadContentPage( let contentPage = await ExtensionTestUtils.loadContentPage(
`http://example.net/?${csp_value}` `http://example.net/?${csp_value}`
); );
let results = await contentPage.spawn([], async () => { let results = await contentPage.spawn(null, async () => {
let img1 = this.content.document.getElementById("img1"); let img1 = this.content.document.getElementById("img1");
let img3 = this.content.document.getElementById("img3"); let img3 = this.content.document.getElementById("img3");
let cspJSON = JSON.parse(this.content.document.cspJSON); let cspJSON = JSON.parse(this.content.document.cspJSON);

View File

@@ -1,5 +1,9 @@
"use strict"; "use strict";
const PREF_DISABLE_SECURITY =
"security.turn_off_all_security_so_that_" +
"viruses_can_take_over_this_computer";
const HOSTS = new Set(["example.com", "example.org"]); const HOSTS = new Set(["example.com", "example.org"]);
const server = createHttpServer({ hosts: HOSTS }); const server = createHttpServer({ hosts: HOSTS });
@@ -14,10 +18,6 @@ server.registerPathHandler("/dummy", (request, response) => {
response.write("<!DOCTYPE html><html></html>"); response.write("<!DOCTYPE html><html></html>");
}); });
function sendMessage(page, msg, data) {
return MessageChannel.sendMessage(page.browser.messageManager, msg, data);
}
add_task(async function test_permissions() { add_task(async function test_permissions() {
function background() { function background() {
browser.webRequest.onBeforeRequest.addListener( browser.webRequest.onBeforeRequest.addListener(
@@ -82,7 +82,7 @@ add_task(async function test_permissions() {
); );
await contentPage.loadFrameScript(frameScript); await contentPage.loadFrameScript(frameScript);
let results = await sendMessage(contentPage, "Test:Check", {}); let results = await contentPage.sendMessage("Test:Check", {});
equal( equal(
results.page, results.page,
"redirected", "redirected",
@@ -94,10 +94,11 @@ add_task(async function test_permissions() {
"Regular webRequest redirect works from an unprivileged page" "Regular webRequest redirect works from an unprivileged page"
); );
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
Services.prefs.setBoolPref("extensions.webapi.testing", true); Services.prefs.setBoolPref("extensions.webapi.testing", true);
Services.prefs.setBoolPref("extensions.webapi.testing.http", true); Services.prefs.setBoolPref("extensions.webapi.testing.http", true);
results = await sendMessage(contentPage, "Test:Check", {}); results = await contentPage.sendMessage("Test:Check", {});
equal( equal(
results.page, results.page,
"original", "original",

View File

@@ -81,7 +81,7 @@ async function testViewSource(viewSourceUrl) {
} }
info("Awaiting completion of StreamFilter on request"); info("Awaiting completion of StreamFilter on request");
await extension.awaitFinish("filter_end"); await extension.awaitFinish("filter_end");
let contentText = await contentPage.spawn([], () => { let contentText = await contentPage.spawn(null, () => {
return this.content.document.body.textContent; return this.content.document.body.textContent;
}); });
equal(contentText, "PREFIX_ok_SUFFIX", "view-source response body"); equal(contentText, "PREFIX_ok_SUFFIX", "view-source response body");
@@ -135,7 +135,7 @@ add_task(async function test_StreamFilter_viewsource_cancel() {
`${BASE_URL}/dummy` `${BASE_URL}/dummy`
); );
await extension.awaitFinish("filter_end"); await extension.awaitFinish("filter_end");
let contentText = await contentPage.spawn([], () => { let contentText = await contentPage.spawn(null, () => {
return this.content.document.body.textContent; return this.content.document.body.textContent;
}); });
equal(contentText, "", "view-source request should have been canceled"); equal(contentText, "", "view-source request should have been canceled");

View File

@@ -113,7 +113,7 @@ add_task(async function test_web_accessible_resources_csp() {
let page = await ExtensionTestUtils.loadContentPage( let page = await ExtensionTestUtils.loadContentPage(
`http://example.com/data/file_sample.html` `http://example.com/data/file_sample.html`
); );
await page.legacySpawn(null, () => { await page.spawn(null, () => {
this.obs = { this.obs = {
events: [], events: [],
observe(subject, topic, data) { observe(subject, topic, data) {
@@ -134,7 +134,7 @@ add_task(async function test_web_accessible_resources_csp() {
extension.awaitMessage("script-ran"), extension.awaitMessage("script-ran"),
]); ]);
let events = await page.legacySpawn(null, () => this.obs.done()); let events = await page.spawn(null, () => this.obs.done());
equal(events.length, 2, "Two items were rejected by CSP"); equal(events.length, 2, "Two items were rejected by CSP");
for (let url of events) { for (let url of events) {
ok( ok(

View File

@@ -34,7 +34,7 @@ const l10n = new Localization([
"branding/brand.ftl", "branding/brand.ftl",
]); ]);
// Localization resources need to be first iterated outside a test // Localization resources need to be first iterated outside a test
l10n.formatValue("webext-perms-sideload-text"); l10n.formatValue("webext-perms-add");
// Lazily import ExtensionParent to allow AddonTestUtils.createAppInfo to // Lazily import ExtensionParent to allow AddonTestUtils.createAppInfo to
// override Services.appinfo. // override Services.appinfo.

View File

@@ -79,7 +79,7 @@ async function openAndCloseContentPage(url) {
// stylesheet with the same URI loaded from the same origin doesn't otherwise // stylesheet with the same URI loaded from the same origin doesn't otherwise
// guarantee that onBeforeRequest and so on happen, because it may not need // guarantee that onBeforeRequest and so on happen, because it may not need
// to go through necko at all. // to go through necko at all.
await contentPage.spawn([], () => await contentPage.spawn(null, () =>
content.windowUtils.clearSharedStyleSheetCache() content.windowUtils.clearSharedStyleSheetCache()
); );
await contentPage.close(); await contentPage.close();

View File

@@ -79,7 +79,7 @@ function mockHandleAPIRequest(extPage, mockHandleAPIRequest) {
}; };
}); });
return extPage.legacySpawn( return extPage.spawn(
[ExtensionTestCommon.serializeFunction(mockHandleAPIRequest)], [ExtensionTestCommon.serializeFunction(mockHandleAPIRequest)],
mockFnText => { mockFnText => {
const { ExtensionAPIRequestHandler } = ChromeUtils.import( const { ExtensionAPIRequestHandler } = ChromeUtils.import(
@@ -228,7 +228,7 @@ async function runExtensionAPITest(
async function runTestCaseInWorker({ page, extension }) { async function runTestCaseInWorker({ page, extension }) {
info(`*** Run test case in an extension service worker`); info(`*** Run test case in an extension service worker`);
const result = await page.legacySpawn([], async () => { const result = await page.spawn([], async () => {
const { active } = await content.navigator.serviceWorker.ready; const { active } = await content.navigator.serviceWorker.ready;
const { port1, port2 } = new MessageChannel(); const { port1, port2 } = new MessageChannel();

View File

@@ -128,7 +128,7 @@ async function submitFormAndGetResults(
) { ) {
async function contentSubmitForm([contentFormAction, contentSelectorValues]) { async function contentSubmitForm([contentFormAction, contentSelectorValues]) {
const { WrapPrivileged } = ChromeUtils.importESModule( const { WrapPrivileged } = ChromeUtils.importESModule(
"resource://testing-common/WrapPrivileged.sys.mjs" "resource://specialpowers/WrapPrivileged.sys.mjs"
); );
let doc = content.document; let doc = content.document;
let form = doc.querySelector("form"); let form = doc.querySelector("form");

View File

@@ -177,7 +177,7 @@ add_task(async function page_content_process() {
"privilegedabout" "privilegedabout"
); );
await contentPage.spawn([PAGE_ICON_TEST_URLS], async URLS => { await contentPage.spawn(PAGE_ICON_TEST_URLS, async URLS => {
// We expect each of these URLs to produce an error event when // We expect each of these URLs to produce an error event when
// we attempt to load them in this process type. // we attempt to load them in this process type.
/* global content */ /* global content */
@@ -218,7 +218,7 @@ add_task(async function page_privileged_about_content_process() {
"privilegedabout" "privilegedabout"
); );
await contentPage.spawn([PAGE_ICON_TEST_URLS], async URLS => { await contentPage.spawn(PAGE_ICON_TEST_URLS, async URLS => {
// We expect each of these URLs to load correctly in this process // We expect each of these URLs to load correctly in this process
// type. // type.
for (let url of URLS) { for (let url of URLS) {
@@ -226,7 +226,7 @@ add_task(async function page_privileged_about_content_process() {
img.src = url; img.src = url;
let imgPromise = new Promise((resolve, reject) => { let imgPromise = new Promise((resolve, reject) => {
img.addEventListener("error", e => { img.addEventListener("error", e => {
Assert.ok(false, "Did not expect an error. "); Assert.ok(false, "Did not expect an error.");
reject(); reject();
}); });
img.addEventListener("load", e => { img.addEventListener("load", e => {

View File

@@ -5,8 +5,6 @@
// Note: the order of the tests here matters, since we are emulating subsquent // Note: the order of the tests here matters, since we are emulating subsquent
// starts of the recalculator component with different initial conditions. // starts of the recalculator component with different initial conditions.
Services.prefs.setBoolPref("preferences.force-disable.check.once.policy", true);
const FEATURE_PREF = "places.frecency.pages.alternative.featureGate"; const FEATURE_PREF = "places.frecency.pages.alternative.featureGate";
async function restartRecalculator() { async function restartRecalculator() {

View File

@@ -52,6 +52,10 @@ XPCOMUtils.defineLazyServiceGetters(lazy, {
], ],
}); });
const PREF_DISABLE_SECURITY =
"security.turn_off_all_security_so_that_" +
"viruses_can_take_over_this_computer";
const ArrayBufferInputStream = Components.Constructor( const ArrayBufferInputStream = Components.Constructor(
"@mozilla.org/io/arraybuffer-input-stream;1", "@mozilla.org/io/arraybuffer-input-stream;1",
"nsIArrayBufferInputStream", "nsIArrayBufferInputStream",
@@ -1743,9 +1747,11 @@ var AddonTestUtils = {
/** /**
* Initializes the URLPreloader, which is required in order to load * Initializes the URLPreloader, which is required in order to load
* built_in_addons.json. * built_in_addons.json. This has the side-effect of setting
* preferences which flip Cu.isInAutomation to true.
*/ */
initializeURLPreloader() { initializeURLPreloader() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
lazy.aomStartup.initializeURLPreloader(); lazy.aomStartup.initializeURLPreloader();
}, },
@@ -1756,6 +1762,9 @@ var AddonTestUtils = {
* to load, for instance: { "system": ["id1", "..."] } * to load, for instance: { "system": ["id1", "..."] }
*/ */
async overrideBuiltIns(data) { async overrideBuiltIns(data) {
// We need to set this in order load the URL preloader service, which
// is only possible when running in automation.
let prevPrefVal = Services.prefs.getBoolPref(PREF_DISABLE_SECURITY, false);
this.initializeURLPreloader(); this.initializeURLPreloader();
let file = this.tempDir.clone(); let file = this.tempDir.clone();
@@ -1771,6 +1780,7 @@ var AddonTestUtils = {
Services.io.newFileURI(file).spec, Services.io.newFileURI(file).spec,
], ],
]); ]);
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, prevPrefVal);
}, },
// AMTelemetry events helpers. // AMTelemetry events helpers.

View File

@@ -17,6 +17,10 @@ const PREF_EM_STRICT_COMPATIBILITY = "extensions.strictCompatibility";
const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url"; const PREF_GETADDONS_BYIDS = "extensions.getAddons.get.url";
const PREF_XPI_SIGNATURES_REQUIRED = "xpinstall.signatures.required"; const PREF_XPI_SIGNATURES_REQUIRED = "xpinstall.signatures.required";
const PREF_DISABLE_SECURITY =
"security.turn_off_all_security_so_that_" +
"viruses_can_take_over_this_computer";
// Maximum error in file modification times. Some file systems don't store // Maximum error in file modification times. Some file systems don't store
// modification times exactly. As long as we are closer than this then it // modification times exactly. As long as we are closer than this then it
// still passes. // still passes.

View File

@@ -3,6 +3,11 @@
/* import-globals-from head_addons.js */ /* import-globals-from head_addons.js */
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
// Enable all scopes. // Enable all scopes.
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_ALL); Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_ALL);
// Setting this to all enables the same behavior as before disabling sideloading. // Setting this to all enables the same behavior as before disabling sideloading.

View File

@@ -7,7 +7,10 @@ const PREF_IS_EMBEDDED = "extensions.isembedded";
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
// Setting PREF_DISABLE_SECURITY tells the policy engine that we are in testing
// mode and enables restarting the policy engine without restarting the browser.
registerCleanupFunction(() => { registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
Services.prefs.clearUserPref(PREF_IS_EMBEDDED); Services.prefs.clearUserPref(PREF_IS_EMBEDDED);
}); });
@@ -20,6 +23,7 @@ async function installExtension() {
} }
add_task(async function test_setup() { add_task(async function test_setup() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
await promiseStartupManager(); await promiseStartupManager();
}); });

View File

@@ -1,6 +1,9 @@
/* Any copyright is dedicated to the Public Domain. /* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */ http://creativecommons.org/publicdomain/zero/1.0/ */
// turn on Cu.isInAutomation
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
const ID = "addon1@tests.mozilla.org"; const ID = "addon1@tests.mozilla.org";
add_task(async function run_test() { add_task(async function run_test() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");

View File

@@ -2,6 +2,12 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
// Make Cu.isInAutomation true.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
// Tests that extensions installed through the registry work as expected // Tests that extensions installed through the registry work as expected
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");

View File

@@ -6,6 +6,7 @@ const PREF_DB_SCHEMA = "extensions.databaseSchema";
const PREF_IS_EMBEDDED = "extensions.isembedded"; const PREF_IS_EMBEDDED = "extensions.isembedded";
registerCleanupFunction(() => { registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
Services.prefs.clearUserPref(PREF_IS_EMBEDDED); Services.prefs.clearUserPref(PREF_IS_EMBEDDED);
}); });
@@ -15,6 +16,7 @@ profileDir.append("extensions");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
add_task(async function test_setup() { add_task(async function test_setup() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
await promiseStartupManager(); await promiseStartupManager();
}); });

View File

@@ -2,6 +2,12 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
// Make Cu.isInAutomation true.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
const ID = "addon@tests.mozilla.org"; const ID = "addon@tests.mozilla.org";
let profileDir = gProfD.clone(); let profileDir = gProfD.clone();

View File

@@ -5,6 +5,9 @@
// extensions.strictCompatibility, and the strictCompatibility option in // extensions.strictCompatibility, and the strictCompatibility option in
// install.rdf // install.rdf
// turn on Cu.isInAutomation
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
PromiseTestUtils.allowMatchingRejectionsGlobally( PromiseTestUtils.allowMatchingRejectionsGlobally(
/IOUtils: Shutting down and refusing additional I\/O tasks/ /IOUtils: Shutting down and refusing additional I\/O tasks/
); );

View File

@@ -9,6 +9,13 @@ const { EnterprisePolicyTesting } = ChromeUtils.importESModule(
"resource://testing-common/EnterprisePolicyTesting.sys.mjs" "resource://testing-common/EnterprisePolicyTesting.sys.mjs"
); );
// Setting PREF_DISABLE_SECURITY tells the policy engine that we are in testing
// mode and enables restarting the policy engine without restarting the browser.
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
});
Services.policies; // Load policy engine Services.policies; // Load policy engine
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2"); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");

View File

@@ -2,9 +2,18 @@
* http://creativecommons.org/publicdomain/zero/1.0/ * http://creativecommons.org/publicdomain/zero/1.0/
*/ */
// Make Cu.isInAutomation true.
Services.prefs.setBoolPref(
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
true
);
// This verifies that app upgrades produce the expected behaviours, // This verifies that app upgrades produce the expected behaviours,
// with strict compatibility checking disabled. // with strict compatibility checking disabled.
// turn on Cu.isInAutomation
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false); Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
// Enable loading extensions from the application scope // Enable loading extensions from the application scope

View File

@@ -1,3 +1,6 @@
// turn on Cu.isInAutomation
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
// Tests that when an extension manifest that was previously valid becomes // Tests that when an extension manifest that was previously valid becomes
// unparseable after an application update, the extension becomes // unparseable after an application update, the extension becomes
// disabled. (See bug 1439600 for a concrete example of a situation where // disabled. (See bug 1439600 for a concrete example of a situation where

View File

@@ -62,6 +62,11 @@ const LOG_PARTIAL_SUCCESS = "partial_log_success" + COMPARE_LOG_SUFFIX;
const LOG_PARTIAL_FAILURE = "partial_log_failure" + COMPARE_LOG_SUFFIX; const LOG_PARTIAL_FAILURE = "partial_log_failure" + COMPARE_LOG_SUFFIX;
const LOG_REPLACE_SUCCESS = "replace_log_success"; const LOG_REPLACE_SUCCESS = "replace_log_success";
// xpcshell tests need this preference set to true for Cu.isInAutomation to be
// true.
const PREF_IS_IN_AUTOMATION =
"security.turn_off_all_security_so_that_viruses_can_take_over_this_computer";
const USE_EXECV = AppConstants.platform == "linux"; const USE_EXECV = AppConstants.platform == "linux";
const URL_HOST = "http://localhost"; const URL_HOST = "http://localhost";
@@ -1162,6 +1167,7 @@ function doTestFinish() {
* Sets the most commonly used preferences used by tests * Sets the most commonly used preferences used by tests
*/ */
function setDefaultPrefs() { function setDefaultPrefs() {
Services.prefs.setBoolPref(PREF_IS_IN_AUTOMATION, true);
Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false); Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
if (gDebugTest) { if (gDebugTest) {
// Enable Update logging // Enable Update logging