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 e56011d5e2
commit 06b68d0d45
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/ContentEventListenerChild.sys.mjs",
"resource://specialpowers/AppTestDelegateChild.sys.mjs",
"resource://testing-common/SpecialPowersChild.sys.mjs",
"resource://testing-common/WrapPrivileged.sys.mjs",
"resource://specialpowers/SpecialPowersChild.sys.mjs",
"resource://specialpowers/WrapPrivileged.sys.mjs",
]),
frameScripts: new Set([]),
processScripts: new Set([

View File

@ -72,9 +72,9 @@ const intermittently_loaded_scripts = {
"chrome://remote/content/shared/Log.sys.mjs",
"resource://testing-common/BrowserTestUtilsChild.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://testing-common/WrapPrivileged.sys.mjs",
"resource://specialpowers/WrapPrivileged.sys.mjs",
]),
processScripts: new Set([]),
};

View File

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

View File

@ -155,7 +155,10 @@ async function clickOn(selector, beforeContentFn) {
}
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);
return EventUtils.synthesizeClick(element);
});

View File

@ -7,13 +7,6 @@
const URL_FOUND = "resource://devtools/shared/DevToolsUtils.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.
*/

View File

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

View File

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

View File

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

View File

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

View File

@ -3,13 +3,6 @@
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() {
strictEqual(typeof Localization.prototype.formatValues, "function");
strictEqual(typeof Localization.prototype.formatMessages, "function");

View File

@ -3,13 +3,6 @@
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() {
const l10nReg = new L10nRegistry();

View File

@ -9,7 +9,10 @@ add_task(async function test_explicit_object_prototype() {
const url =
"http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_promise_userInteractionHandling.html";
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);
is(
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.
var stack = SpecialPowers.wrap(SpecialPowers.Components).stack;
while (/testing-common/.test(stack)) {
while (/specialpowers/.test(stack)) {
stack = stack.caller;
}
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);
let prefNames = Object.keys(TESTS);
prefValues = await contentPage.legacySpawn(prefNames, getPrefs);
prefValues = await contentPage.spawn(prefNames, getPrefs);
await runChecks("contentStartup");
prefValues = await contentPage.legacySpawn(prefNames, getPrefs);
prefValues = await contentPage.spawn(prefNames, getPrefs);
await runChecks("contentUpdate1");
prefValues = await contentPage.legacySpawn(prefNames, getPrefs);
prefValues = await contentPage.spawn(prefNames, getPrefs);
await runChecks("contentUpdate2");
});

View File

@ -66,7 +66,7 @@ add_task(async function test_sharedMap_static_prefs() {
registerCleanupFunction(() => contentPage.close());
/* 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));
});
/* eslint-enable no-shadow */

View File

@ -37,7 +37,7 @@ export const CookieXPCShellUtils = {
async getCookieStringFromDocument(uri, options = {}) {
const contentPage = await this.loadContentPage(uri, options);
const cookies = await contentPage.spawn(
[],
null,
// eslint-disable-next-line no-undef
() => content.document.cookie
);
@ -48,7 +48,7 @@ export const CookieXPCShellUtils = {
async setCookieToDocument(uri, set, options = {}) {
const contentPage = await this.loadContentPage(uri, options);
await contentPage.spawn(
[set],
set,
// eslint-disable-next-line no-undef
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 contentPage = await CookieXPCShellUtils.loadContentPage(thirdPartyUrl);
await contentPage.spawn(
[
{
cookie: "can=has" + suffix,
url: uri.spec,
},
],
{
cookie: "can=has" + suffix,
url: uri.spec,
},
async obj => {
// eslint-disable-next-line no-undef
await new content.Promise(resolve => {

View File

@ -34,7 +34,11 @@ AddonTestUtils.createAppInfo(
);
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() {
_("Test fixtures.");

View File

@ -8,7 +8,11 @@ const { Service } = ChromeUtils.importESModule(
"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() {
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"]
XPCSHELL_TESTS_MANIFESTS += ["Harness_sanity/xpcshell.ini"]
BROWSER_CHROME_MANIFESTS += ["browser/browser.ini"]

View File

@ -22,12 +22,12 @@ const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
ContentTask: "resource://testing-common/ContentTask.sys.mjs",
SpecialPowersParent: "resource://testing-common/SpecialPowersParent.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
HttpServer: "resource://testing-common/httpd.js",
MessageChannel: "resource://testing-common/MessageChannel.jsm",
});
XPCOMUtils.defineLazyServiceGetters(lazy, {
@ -43,11 +43,22 @@ var gRemoteContentScripts = Services.appinfo.browserTabsRemoteAutostart;
const REMOTE_CONTENT_SUBFRAMES = Services.appinfo.fissionAutostart;
function frameScript() {
const { MessageChannel } = ChromeUtils.import(
"resource://testing-common/MessageChannel.jsm"
);
// We need to make sure that the ExtensionPolicy service has been initialized
// as it sets up the observers that inject extension content scripts.
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
addEventListener(
@ -165,10 +176,6 @@ class ContentPage {
let chromeDoc = await promiseDocumentLoaded(chromeShell.document);
let { SpecialPowers } = chromeDoc.ownerGlobal;
SpecialPowers.xpcshellScope = XPCShellContentUtils.currentScope;
SpecialPowers.setAsDefaultAssertHandler();
let browser = chromeDoc.createXULElement("browser");
browser.setAttribute("type", "content");
browser.setAttribute("disableglobalhistory", "true");
@ -223,8 +230,12 @@ class ContentPage {
return this.browser.browsingContext;
}
get SpecialPowers() {
return this.browser.ownerGlobal.SpecialPowers;
sendMessage(msg, data) {
return lazy.MessageChannel.sendMessage(
this.browser.messageManager,
msg,
data
);
}
loadFrameScript(func) {
@ -252,26 +263,11 @@ class ContentPage {
return promiseBrowserLoaded(this.browser, url, redirectUrl);
}
async fetch(...args) {
return this.spawn(args, async (url, options) => {
let resp = await this.content.fetch(url, options);
return resp.text();
});
async fetch(url, options) {
return this.sendMessage("Test:Fetch", { url, options });
}
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);
}
@ -327,8 +323,6 @@ export var XPCShellContentUtils = {
scope.do_get_profile();
this.initCommon(scope);
lazy.SpecialPowersParent.registerActor();
},
initMochitest(scope) {
@ -441,7 +435,7 @@ export var XPCShellContentUtils = {
}
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,
} = {}
) {
lazy.ContentTask.setTestScope(this.currentScope);
let contentPage = new ContentPage(
remote,
remoteSubframes,

View File

@ -33,4 +33,3 @@ user_pref("gfx.color_management.force_srgb", true);
user_pref("gfx.color_management.mode", 1);
// Don't enable remote tiles on new-tab pages in xpcshell
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 */
ChromeUtils.defineESModuleGetters(this, {
SpecialPowersParent: "resource://testing-common/SpecialPowersParent.sys.mjs",
});
XPCOMUtils.defineLazyServiceGetter(
this,
"resProto",
@ -31,7 +27,20 @@ this.specialpowers = class extends ExtensionAPI {
.QueryInterface(Ci.nsIComponentRegistrar)
.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", {
parent: {
@ -50,7 +59,7 @@ this.specialpowers = class extends ExtensionAPI {
}
onShutdown() {
SpecialPowersParent.unregisterActor();
ChromeUtils.unregisterWindowActor("SpecialPowers");
ChromeUtils.unregisterWindowActor("AppTestDelegate");
resProto.setSubstitution("specialpowers", null);
}

View File

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

View File

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

View File

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

View File

@ -11,8 +11,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
HiddenFrame: "resource://gre/modules/HiddenFrame.sys.mjs",
PerTestCoverageUtils:
"resource://testing-common/PerTestCoverageUtils.sys.mjs",
SpecialPowersSandbox:
"resource://testing-common/SpecialPowersSandbox.sys.mjs",
SpecialPowersSandbox: "resource://specialpowers/SpecialPowersSandbox.sys.mjs",
});
XPCOMUtils.defineLazyModuleGetters(lazy, {
@ -183,27 +182,6 @@ export class SpecialPowersParent extends JSWindowActorParent {
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() {
Services.obs.addObserver(this._observer, "http-on-modify-request");

View File

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

View File

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

View File

@ -34,6 +34,7 @@ var _tests_pending = 0;
var _cleanupFunctions = [];
var _pendingTimers = [];
var _profileInitialized = false;
var _fastShutdownDisabled = false;
// Assigned in do_load_child_test_harness.
var _XPCSHELL_PROCESS;
@ -723,6 +724,16 @@ function _execute_test() {
!_AppConstants.ASAN &&
!_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();
}
}
@ -1223,6 +1234,14 @@ function registerCleanupFunction(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
* 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"
);
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.
let f = this.content.document.createElement("iframe");
f.src = "http://foo.com/iframe";

View File

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

View File

@ -4,13 +4,6 @@
* 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/. */
// 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) {
let l10n = new Localization([resource], true);
let value = await l10n.formatValue(id);

View File

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

View File

@ -243,7 +243,7 @@ async function test_frame_matching(meta) {
];
// 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;
this.windows = new Map();

View File

@ -15,8 +15,6 @@ ChromeUtils.defineModuleGetter(
// The test extension uses an insecure update url.
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 { createAppInfo, promiseShutdownManager, promiseStartupManager } =

View File

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

View File

@ -54,7 +54,7 @@ add_task(async function test_contentscript_context() {
await extension.awaitMessage("content-script-show");
// 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(
"resource://gre/modules/ExtensionContent.jsm"
);
@ -78,7 +78,7 @@ add_task(async function test_contentscript_context() {
await extension.awaitMessage("content-script-hide");
await contentPage.legacySpawn(null, async () => {
await contentPage.spawn(null, async () => {
Assert.equal(
this.context.contentWindow,
null,
@ -91,7 +91,7 @@ add_task(async function test_contentscript_context() {
await extension.awaitMessage("content-script-show");
await contentPage.legacySpawn(null, async () => {
await contentPage.spawn(null, async () => {
Assert.equal(
this.context.contentWindow,
this.content,
@ -150,7 +150,7 @@ add_task(async function test_contentscript_context_incognito_not_allowed() {
{ privateBrowsing: true }
);
await contentPage.legacySpawn(extension.id, async extensionId => {
await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import(
"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");
// 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(
"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.unload();
await contentPage.legacySpawn(null, async () => {
await contentPage.spawn(null, async () => {
await this.contextUnloadedPromise;
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(
"http://example.com/dummy?first"
);
await contentPage.legacySpawn(extension.id, async extensionId => {
await contentPage.spawn(extension.id, async extensionId => {
let context;
let checkContextIsValid = description => {
if (!context) {
@ -340,13 +340,13 @@ add_task(async function test_contentscript_context_valid_during_execution() {
await extension.startup();
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.
this.content.location = "http://example.org/dummy?second";
});
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.
this.content.history.back();
});

View File

@ -81,7 +81,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-ready");
// 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(
"resource://gre/modules/ExtensionContent.jsm"
);
@ -105,7 +105,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-hide");
await contentPage.legacySpawn(null, async () => {
await contentPage.spawn(null, async () => {
Assert.equal(
this.context.contentWindow,
null,
@ -120,7 +120,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-show");
async function testWithoutBfcache() {
return contentPage.legacySpawn(null, async () => {
return contentPage.spawn(null, async () => {
Assert.equal(
this.context.contentWindow,
this.content,
@ -155,7 +155,7 @@ add_task(async function test_contentscript_context_isolation() {
await extension.awaitMessage("content-script-unload");
await contentPage.legacySpawn(null, async () => {
await contentPage.spawn(null, async () => {
Assert.equal(
this.context.sandbox,
null,

View File

@ -120,7 +120,7 @@ add_task(async function test_contentscript_create_iframe() {
info("testing APIs availability once the extension is unloaded...");
await contentPage.legacySpawn(null, () => {
await contentPage.spawn(null, () => {
this.iframeWindow = this.content[0];
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"
);
await contentPage.legacySpawn(null, () => {
await contentPage.spawn(null, () => {
let win = Cu.waiveXrays(this.iframeWindow);
ok(
!Cu.isDeadWrapper(win.browser),

View File

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

View File

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

View File

@ -127,7 +127,7 @@ add_task(async function test_normal_import() {
await extension.awaitMessage("done");
// 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"];
for (let file of files) {
@ -176,7 +176,7 @@ add_task(async function test_import_web_accessible() {
// Web page can import web-accessible 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}`;
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,
// when the WebExtension imports the same file, they should
// not be shared.
await contentPage.spawn([extension.uuid], async uuid => {
await contentPage.spawn(extension.uuid, async uuid => {
let base = `moz-extension://${uuid}`;
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");
await contentPage.spawn([], () => {
await contentPage.spawn(null, () => {
this.content.location.reload();
});
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"))
);
const promiseDone = contentPage.legacySpawn(extension.id, extensionId => {
const promiseDone = contentPage.spawn([extension.id], extensionId => {
const { ExtensionProcessScript } = ChromeUtils.import(
"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.
async function reloadTopContext(contentPage) {
await contentPage.legacySpawn(null, async () => {
await contentPage.spawn(null, async () => {
let { TestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TestUtils.sys.mjs"
);
@ -29,7 +29,7 @@ async function reloadTopContext(contentPage) {
}
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
// and https://searchfox.org/mozilla-central/rev/33c21c060b7f3a52477a73d06ebcb2bf313c4431/xpcom/base/nsMemoryReporterManager.cpp#2574-2585,2591-2594
let gcCount = 0;
@ -83,7 +83,7 @@ add_task(async function test_ContentScriptContextChild_in_child_frame() {
);
await extension.awaitMessage("contentScriptLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => {
await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm"
);
@ -135,7 +135,7 @@ add_task(async function test_ContentScriptContextChild_in_toplevel() {
);
await extension.awaitMessage("contentScriptLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => {
await contentPage.spawn(extension.id, async extensionId => {
const { ExtensionContent } = ChromeUtils.import(
"resource://gre/modules/ExtensionContent.jsm"
);
@ -187,7 +187,7 @@ add_task(async function test_ExtensionPageContextChild_in_child_frame() {
);
await extension.awaitMessage("extensionPageLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => {
await contentPage.spawn(extension.id, async extensionId => {
let { ExtensionPageChild } = ChromeUtils.import(
"resource://gre/modules/ExtensionPageChild.jsm"
);
@ -237,7 +237,7 @@ add_task(async function test_ExtensionPageContextChild_in_toplevel() {
);
await extension.awaitMessage("extensionPageLoaded");
await contentPage.legacySpawn(extension.id, async extensionId => {
await contentPage.spawn(extension.id, async extensionId => {
let { ExtensionPageChild } = ChromeUtils.import(
"resource://gre/modules/ExtensionPageChild.jsm"
);
@ -254,7 +254,7 @@ add_task(async function test_ExtensionPageContextChild_in_toplevel() {
await extension.awaitMessage("extensionPageLoaded");
// For some unknown reason, the context cannot forcidbly be released by the
// garbage collector unless we wait for a short while.
await contentPage.spawn([], async () => {
await contentPage.spawn(null, async () => {
let start = Date.now();
// The treshold was found after running this subtest only, 300 times
// 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();
await extPage.spawn(
["http://example.com/page-with-tracker.html"],
"http://example.com/page-with-tracker.html",
async iframeURL => {
const iframe = this.content.document.createElement("iframe");
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 webFrame = this.content.document.querySelector("iframe#web");
@ -459,7 +459,7 @@ add_task(
);
results.extSubFrameContent = await contentPage.spawn(
[extension.uuid],
extension.uuid,
uuid => {
return new Promise(resolve => {
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(
"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;
async function checkScriptLoad({ setupScript, expectLoad, description }) {
const scriptElem = document.createElement("script");

View File

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

View File

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

View File

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

View File

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

View File

@ -91,7 +91,7 @@ add_task(async function dnr_ignores_navigation_to_restrictedDomains() {
let contentPage = await ExtensionTestUtils.loadContentPage(
"http://restricted/?blockme"
);
await contentPage.spawn([], () => {
await contentPage.spawn(null, () => {
const { document } = content;
Assert.equal(document.URL, "http://restricted/?blockme", "Same URL");
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(
"http://restricted/"
);
await contentPage.spawn([], async () => {
await contentPage.spawn(null, async () => {
// Use wrappedJSObject so that all operations below are with the principal
// of the content instead of the system principal (from this ContentTask).
const { document } = content.wrappedJSObject;
@ -220,7 +220,7 @@ add_task(
let contentPage = await ExtensionTestUtils.loadContentPage(
"about:logo?blockme"
);
await contentPage.spawn([], async () => {
await contentPage.spawn(null, async () => {
const { document } = content;
// To make sure that the test does not pass trivially, we verify that it
// 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);
// Sanity check: that the initiator is as specified, and not redirected.
Assert.equal(
await contentPage.spawn([], () => content.document.URL),
await contentPage.spawn(null, () => content.document.URL),
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 {
let req = await content.fetch(args.url, args.options);
return {

View File

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

View File

@ -29,7 +29,7 @@ const l10n = new Localization([
"branding/brand.ftl",
]);
// 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.overrideCertDB();

View File

@ -1,9 +1,20 @@
"use strict";
const PREF_DISABLE_SECURITY =
"security.turn_off_all_security_so_that_" +
"viruses_can_take_over_this_computer";
const { EnterprisePolicyTesting } = ChromeUtils.importESModule(
"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
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"
);
await contentPage.spawn([], () => {
await contentPage.spawn(null, () => {
this.content.location.reload();
});
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"
);
await contentPage.spawn([], () => {
await contentPage.spawn(null, () => {
let { document } = this.content;
let frame = document.createElement("iframe");
frame.src = "/data/file_sample.html";
@ -171,7 +171,7 @@ add_task(async function testConnect_and_remove_frame() {
"http://example.com/dummy"
);
await contentPage.spawn([], () => {
await contentPage.spawn(null, () => {
let { document } = this.content;
let frame = document.createElement("iframe");
frame.src = "/data/file_sample.html";

View File

@ -290,7 +290,7 @@ add_task(async function test_userScripts_no_webext_apis() {
url,
ExtensionTestUtils.remoteContentScripts ? { remote: true } : undefined
);
let result = await contentPage.spawn([], async () => {
let result = await contentPage.spawn(undefined, async () => {
return {
textContent: this.content.document.body.textContent,
url: this.content.location.href,
@ -325,7 +325,7 @@ add_task(async function test_userScripts_no_webext_apis() {
let contentPage2 = await ExtensionTestUtils.loadContentPage(url2, {
remote: true,
});
let result2 = await contentPage2.spawn([], async () => {
let result2 = await contentPage2.spawn(undefined, async () => {
return {
textContent: this.content.document.body.textContent,
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");
let result = await contentPage.spawn([], () => {
let textContent = content.document.body.textContent;
let result = await contentPage.spawn(null, () => {
let textContent = this.content.document.body.textContent;
// Omit the default content from file_sample.html.
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"
);
let content = await contentPage.spawn([], () => {
let content = await contentPage.spawn(null, () => {
return this.content.document.body.textContent;
});

View File

@ -115,7 +115,7 @@ async function test_csp({
let contentPage = await ExtensionTestUtils.loadContentPage(
`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 img3 = this.content.document.getElementById("img3");
let cspJSON = JSON.parse(this.content.document.cspJSON);

View File

@ -1,5 +1,9 @@
"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 server = createHttpServer({ hosts: HOSTS });
@ -14,10 +18,6 @@ server.registerPathHandler("/dummy", (request, response) => {
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() {
function background() {
browser.webRequest.onBeforeRequest.addListener(
@ -82,7 +82,7 @@ add_task(async function test_permissions() {
);
await contentPage.loadFrameScript(frameScript);
let results = await sendMessage(contentPage, "Test:Check", {});
let results = await contentPage.sendMessage("Test:Check", {});
equal(
results.page,
"redirected",
@ -94,10 +94,11 @@ add_task(async function test_permissions() {
"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.http", true);
results = await sendMessage(contentPage, "Test:Check", {});
results = await contentPage.sendMessage("Test:Check", {});
equal(
results.page,
"original",

View File

@ -81,7 +81,7 @@ async function testViewSource(viewSourceUrl) {
}
info("Awaiting completion of StreamFilter on request");
await extension.awaitFinish("filter_end");
let contentText = await contentPage.spawn([], () => {
let contentText = await contentPage.spawn(null, () => {
return this.content.document.body.textContent;
});
equal(contentText, "PREFIX_ok_SUFFIX", "view-source response body");
@ -135,7 +135,7 @@ add_task(async function test_StreamFilter_viewsource_cancel() {
`${BASE_URL}/dummy`
);
await extension.awaitFinish("filter_end");
let contentText = await contentPage.spawn([], () => {
let contentText = await contentPage.spawn(null, () => {
return this.content.document.body.textContent;
});
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(
`http://example.com/data/file_sample.html`
);
await page.legacySpawn(null, () => {
await page.spawn(null, () => {
this.obs = {
events: [],
observe(subject, topic, data) {
@ -134,7 +134,7 @@ add_task(async function test_web_accessible_resources_csp() {
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");
for (let url of events) {
ok(

View File

@ -34,7 +34,7 @@ const l10n = new Localization([
"branding/brand.ftl",
]);
// 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
// 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
// guarantee that onBeforeRequest and so on happen, because it may not need
// to go through necko at all.
await contentPage.spawn([], () =>
await contentPage.spawn(null, () =>
content.windowUtils.clearSharedStyleSheetCache()
);
await contentPage.close();

View File

@ -79,7 +79,7 @@ function mockHandleAPIRequest(extPage, mockHandleAPIRequest) {
};
});
return extPage.legacySpawn(
return extPage.spawn(
[ExtensionTestCommon.serializeFunction(mockHandleAPIRequest)],
mockFnText => {
const { ExtensionAPIRequestHandler } = ChromeUtils.import(
@ -228,7 +228,7 @@ async function runExtensionAPITest(
async function runTestCaseInWorker({ page, extension }) {
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 { port1, port2 } = new MessageChannel();

View File

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

View File

@ -177,7 +177,7 @@ add_task(async function page_content_process() {
"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 attempt to load them in this process type.
/* global content */
@ -218,7 +218,7 @@ add_task(async function page_privileged_about_content_process() {
"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
// type.
for (let url of URLS) {
@ -226,7 +226,7 @@ add_task(async function page_privileged_about_content_process() {
img.src = url;
let imgPromise = new Promise((resolve, reject) => {
img.addEventListener("error", e => {
Assert.ok(false, "Did not expect an error. ");
Assert.ok(false, "Did not expect an error.");
reject();
});
img.addEventListener("load", e => {

View File

@ -5,8 +5,6 @@
// Note: the order of the tests here matters, since we are emulating subsquent
// 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";
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(
"@mozilla.org/io/arraybuffer-input-stream;1",
"nsIArrayBufferInputStream",
@ -1743,9 +1747,11 @@ var AddonTestUtils = {
/**
* 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() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
lazy.aomStartup.initializeURLPreloader();
},
@ -1756,6 +1762,9 @@ var AddonTestUtils = {
* to load, for instance: { "system": ["id1", "..."] }
*/
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();
let file = this.tempDir.clone();
@ -1771,6 +1780,7 @@ var AddonTestUtils = {
Services.io.newFileURI(file).spec,
],
]);
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, prevPrefVal);
},
// 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_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
// modification times exactly. As long as we are closer than this then it
// still passes.

View File

@ -3,6 +3,11 @@
/* 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.
Services.prefs.setIntPref("extensions.enabledScopes", AddonManager.SCOPE_ALL);
// 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");
// 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(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
Services.prefs.clearUserPref(PREF_IS_EMBEDDED);
});
@ -20,6 +23,7 @@ async function installExtension() {
}
add_task(async function test_setup() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
await promiseStartupManager();
});

View File

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

View File

@ -2,6 +2,12 @@
* 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
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";
registerCleanupFunction(() => {
Services.prefs.clearUserPref(PREF_DISABLE_SECURITY);
Services.prefs.clearUserPref(PREF_IS_EMBEDDED);
});
@ -15,6 +16,7 @@ profileDir.append("extensions");
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "49");
add_task(async function test_setup() {
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
await promiseStartupManager();
});

View File

@ -2,6 +2,12 @@
* 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";
let profileDir = gProfD.clone();

View File

@ -5,6 +5,9 @@
// extensions.strictCompatibility, and the strictCompatibility option in
// install.rdf
// turn on Cu.isInAutomation
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
PromiseTestUtils.allowMatchingRejectionsGlobally(
/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"
);
// 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
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "2");

View File

@ -2,9 +2,18 @@
* 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,
// with strict compatibility checking disabled.
// turn on Cu.isInAutomation
Services.prefs.setBoolPref(PREF_DISABLE_SECURITY, true);
Services.prefs.setBoolPref(PREF_EM_STRICT_COMPATIBILITY, false);
// 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
// unparseable after an application update, the extension becomes
// 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_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 URL_HOST = "http://localhost";
@ -1162,6 +1167,7 @@ function doTestFinish() {
* Sets the most commonly used preferences used by tests
*/
function setDefaultPrefs() {
Services.prefs.setBoolPref(PREF_IS_IN_AUTOMATION, true);
Services.prefs.setBoolPref(PREF_APP_UPDATE_DISABLEDFORTESTING, false);
if (gDebugTest) {
// Enable Update logging