зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1648545: Part 4 - Move ContentPage.spawn to use SpecialPowers rather than ContentTask. r=ahal
Differential Revision: https://phabricator.services.mozilla.com/D119451
This commit is contained in:
Родитель
05d13811b2
Коммит
f3218c1a70
|
@ -3,9 +3,6 @@
|
|||
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"
|
||||
);
|
||||
|
@ -19,6 +16,10 @@ 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");
|
||||
|
@ -94,21 +95,16 @@ async function checkContentMaps(expected, parentOnly = false) {
|
|||
|
||||
if (!parentOnly) {
|
||||
info("Checking out-of-process content map");
|
||||
let contents = await contentPage.spawn(undefined, getContents);
|
||||
let contents = await contentPage.spawn([], getContents);
|
||||
checkMap(contents, expected);
|
||||
}
|
||||
}
|
||||
|
||||
async function loadContentPage() {
|
||||
let page = await XPCShellContentUtils.loadContentPage("about:blank", {
|
||||
let page = await XPCShellContentUtils.loadContentPage("data:text/html,", {
|
||||
remote,
|
||||
});
|
||||
registerCleanupFunction(() => page.close());
|
||||
|
||||
page.addFrameScriptHelper(`
|
||||
var {ExtensionUtils} = ChromeUtils.import("resource://gre/modules/ExtensionUtils.jsm");
|
||||
Cu.importGlobalProperties(["FileReader"]);
|
||||
`);
|
||||
return page;
|
||||
}
|
||||
|
||||
|
@ -232,7 +228,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"
|
||||
);
|
||||
|
@ -240,7 +236,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"
|
||||
);
|
||||
|
@ -293,12 +289,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"
|
||||
);
|
||||
|
@ -309,12 +305,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"
|
||||
);
|
||||
|
@ -352,29 +348,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"
|
||||
);
|
||||
|
|
|
@ -348,15 +348,15 @@ add_task(async function test_sharedMap_prefs() {
|
|||
contentPage.addFrameScriptHelper(getPref);
|
||||
|
||||
let prefNames = Object.keys(TESTS);
|
||||
prefValues = await contentPage.spawn(prefNames, getPrefs);
|
||||
prefValues = await contentPage.legacySpawn(prefNames, getPrefs);
|
||||
|
||||
await runChecks("contentStartup");
|
||||
|
||||
prefValues = await contentPage.spawn(prefNames, getPrefs);
|
||||
prefValues = await contentPage.legacySpawn(prefNames, getPrefs);
|
||||
|
||||
await runChecks("contentUpdate1");
|
||||
|
||||
prefValues = await contentPage.spawn(prefNames, getPrefs);
|
||||
prefValues = await contentPage.legacySpawn(prefNames, getPrefs);
|
||||
|
||||
await runChecks("contentUpdate2");
|
||||
});
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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)
|
||||
);
|
||||
|
|
|
@ -154,10 +154,12 @@ 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 => {
|
||||
|
|
|
@ -28,7 +28,6 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
|||
|
||||
XPCOMUtils.defineLazyModuleGetters(lazy, {
|
||||
HttpServer: "resource://testing-common/httpd.js",
|
||||
MessageChannel: "resource://testing-common/MessageChannel.jsm",
|
||||
});
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetters(lazy, {
|
||||
|
@ -44,22 +43,11 @@ 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();
|
||||
|
||||
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);
|
||||
Services.obs.notifyObservers(this, "tab-content-frameloader-created");
|
||||
|
||||
// eslint-disable-next-line mozilla/balanced-listeners, no-undef
|
||||
addEventListener(
|
||||
|
@ -239,14 +227,6 @@ class ContentPage {
|
|||
return this.browser.ownerGlobal.SpecialPowers;
|
||||
}
|
||||
|
||||
sendMessage(msg, data) {
|
||||
return lazy.MessageChannel.sendMessage(
|
||||
this.browser.messageManager,
|
||||
msg,
|
||||
data
|
||||
);
|
||||
}
|
||||
|
||||
loadFrameScript(func) {
|
||||
let frameScript = `data:text/javascript,(${encodeURI(func)}).call(this)`;
|
||||
this.browser.messageManager.loadFrameScript(frameScript, true, true);
|
||||
|
@ -272,11 +252,26 @@ class ContentPage {
|
|||
return promiseBrowserLoaded(this.browser, url, redirectUrl);
|
||||
}
|
||||
|
||||
async fetch(url, options) {
|
||||
return this.sendMessage("Test:Fetch", { url, options });
|
||||
async fetch(...args) {
|
||||
return this.spawn(args, async (url, options) => {
|
||||
let resp = await this.content.fetch(url, options);
|
||||
return resp.text();
|
||||
});
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -446,7 +441,7 @@ export var XPCShellContentUtils = {
|
|||
}
|
||||
|
||||
let fetchScope = await fetchScopePromise;
|
||||
return fetchScope.sendMessage("Test:Fetch", { url, options });
|
||||
return fetchScope.fetch(url, options);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -481,8 +476,6 @@ export var XPCShellContentUtils = {
|
|||
userContextId = undefined,
|
||||
} = {}
|
||||
) {
|
||||
lazy.ContentTask.setTestScope(this.currentScope);
|
||||
|
||||
let contentPage = new ContentPage(
|
||||
remote,
|
||||
remoteSubframes,
|
||||
|
|
|
@ -122,7 +122,7 @@ add_task(async () => {
|
|||
"http://example.org/empty"
|
||||
);
|
||||
|
||||
await contentPage.spawn(null, () =>
|
||||
await contentPage.spawn([], () =>
|
||||
// eslint-disable-next-line no-undef
|
||||
content.windowUtils.clearSharedStyleSheetCache()
|
||||
);
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(null, async () => {
|
||||
// Navigate back so the content page is resurrected from the bfcache.
|
||||
this.content.history.back();
|
||||
});
|
||||
|
|
|
@ -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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
return contentPage.legacySpawn(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.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(null, async () => {
|
||||
Assert.equal(
|
||||
this.context.sandbox,
|
||||
null,
|
||||
|
|
|
@ -120,7 +120,7 @@ add_task(async function test_contentscript_create_iframe() {
|
|||
|
||||
info("testing APIs availability once the extension is unloaded...");
|
||||
|
||||
await contentPage.spawn(null, () => {
|
||||
await contentPage.legacySpawn(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.spawn(null, () => {
|
||||
await contentPage.legacySpawn(null, () => {
|
||||
let win = Cu.waiveXrays(this.iframeWindow);
|
||||
ok(
|
||||
!Cu.isDeadWrapper(win.browser),
|
||||
|
|
|
@ -36,12 +36,12 @@ add_task(async function test_content_script_css() {
|
|||
return style.maxWidth;
|
||||
}
|
||||
|
||||
let maxWidth = await contentPage.spawn(null, task);
|
||||
let maxWidth = await contentPage.spawn([], task);
|
||||
equal(maxWidth, "42px", "Stylesheet correctly applied");
|
||||
|
||||
await extension.unload();
|
||||
|
||||
maxWidth = await contentPage.spawn(null, task);
|
||||
maxWidth = await contentPage.spawn([], task);
|
||||
equal(maxWidth, "none", "Stylesheet correctly removed");
|
||||
|
||||
await contentPage.close();
|
||||
|
|
|
@ -105,7 +105,7 @@ add_task(async function test_importMaps_not_supported() {
|
|||
);
|
||||
await extension.awaitMessage("done");
|
||||
|
||||
await contentPage.spawn(null, async () => {
|
||||
await contentPage.spawn([], async () => {
|
||||
// Import maps should work for documents.
|
||||
let promise = content.eval(`import("simple2")`);
|
||||
let mod = (await promise.wrappedJSObject).wrappedJSObject;
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -62,7 +62,7 @@ add_task(async function test_contentscript_reload_and_unload() {
|
|||
);
|
||||
equal(contextEvents[0].url, tabUrl, "ExtensionContext URL = page");
|
||||
|
||||
await contentPage.spawn(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
this.content.location.reload();
|
||||
});
|
||||
await extension.awaitMessage("contentscript-run");
|
||||
|
|
|
@ -40,7 +40,7 @@ add_task(async function content_script_unregistered_during_loadContentScript() {
|
|||
content_scripts.map(() => extension.awaitMessage("content-script-executed"))
|
||||
);
|
||||
|
||||
const promiseDone = contentPage.spawn([extension.id], extensionId => {
|
||||
const promiseDone = contentPage.legacySpawn(extension.id, extensionId => {
|
||||
const { ExtensionProcessScript } = ChromeUtils.import(
|
||||
"resource://gre/modules/ExtensionProcessScript.jsm"
|
||||
);
|
||||
|
|
|
@ -16,7 +16,7 @@ ExtensionTestUtils.mockAppInfo();
|
|||
// 4. Force GC and check that the weak reference has been invalidated.
|
||||
|
||||
async function reloadTopContext(contentPage) {
|
||||
await contentPage.spawn(null, async () => {
|
||||
await contentPage.legacySpawn(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.spawn(description, async assertionDescription => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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.spawn(extension.id, async extensionId => {
|
||||
await contentPage.legacySpawn(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(null, async () => {
|
||||
await contentPage.spawn([], 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).
|
||||
|
|
|
@ -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(null, async () => {
|
||||
let results = await extensionPage.spawn([], 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");
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -144,7 +144,7 @@ async function testLoadInFrame({
|
|||
const mainFrameUrl = urlEchoHtml(mainFrameDomain, mainFrameHtml);
|
||||
|
||||
let contentPage = await ExtensionTestUtils.loadContentPage(mainFrameUrl);
|
||||
let result = await contentPage.spawn(null, () => {
|
||||
let result = await contentPage.spawn([], () => {
|
||||
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(null, () => content.document.URL),
|
||||
await contentPage.spawn([], () => 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(null, async () => {
|
||||
await contentPage.spawn([], 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(null, () => {
|
||||
let actualPath = await contentPage.spawn([], () => {
|
||||
return content.frames[0].location.pathname;
|
||||
});
|
||||
Assert.equal(actualPath, expectedPath, description);
|
||||
}
|
||||
async function assertHasAAR(expected, description) {
|
||||
let actual = await contentPage.spawn(null, async () => {
|
||||
let actual = await contentPage.spawn([], 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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
content.history.pushState(null, null, "/?hist_p");
|
||||
});
|
||||
await TestUtils.waitForCondition(
|
||||
|
|
|
@ -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(null, async () => {
|
||||
let cspTestResults = await contentPage.spawn([], 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(null, () => {
|
||||
let res = await contentPage.spawn([], () => {
|
||||
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"),
|
||||
|
|
|
@ -36,7 +36,7 @@ async function testMatchedByDNR(privateBrowsing) {
|
|||
"http://example.com/?page",
|
||||
{ privateBrowsing }
|
||||
);
|
||||
let wasRequestBlocked = await contentPage.spawn(null, async () => {
|
||||
let wasRequestBlocked = await contentPage.legacySpawn(null, async () => {
|
||||
try {
|
||||
await content.fetch("http://example.com/?fetch");
|
||||
return false;
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -91,7 +91,7 @@ add_task(async function dnr_ignores_navigation_to_restrictedDomains() {
|
|||
let contentPage = await ExtensionTestUtils.loadContentPage(
|
||||
"http://restricted/?blockme"
|
||||
);
|
||||
await contentPage.spawn(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
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(null, async () => {
|
||||
await contentPage.spawn([], 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(null, async () => {
|
||||
await contentPage.spawn([], 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
|
||||
|
|
|
@ -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(null, () => content.document.URL),
|
||||
await contentPage.spawn([], () => 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 {
|
||||
|
|
|
@ -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"
|
||||
);
|
||||
|
|
|
@ -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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
this.content.location.reload();
|
||||
});
|
||||
let extensionPageURL2 = await extension.awaitMessage("extension page loaded");
|
||||
|
|
|
@ -147,7 +147,7 @@ add_task(async function testSendMessage_and_remove_frame() {
|
|||
"http://example.com/dummy"
|
||||
);
|
||||
|
||||
await contentPage.spawn(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
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(null, () => {
|
||||
await contentPage.spawn([], () => {
|
||||
let { document } = this.content;
|
||||
let frame = document.createElement("iframe");
|
||||
frame.src = "/data/file_sample.html";
|
||||
|
|
|
@ -290,7 +290,7 @@ add_task(async function test_userScripts_no_webext_apis() {
|
|||
url,
|
||||
ExtensionTestUtils.remoteContentScripts ? { remote: true } : undefined
|
||||
);
|
||||
let result = await contentPage.spawn(undefined, async () => {
|
||||
let result = await contentPage.spawn([], 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(undefined, async () => {
|
||||
let result2 = await contentPage2.spawn([], async () => {
|
||||
return {
|
||||
textContent: this.content.document.body.textContent,
|
||||
url: this.content.location.href,
|
||||
|
|
|
@ -125,8 +125,8 @@ add_task(async function test_userscripts_register_cookieStoreId() {
|
|||
|
||||
await extension.awaitMessage("last-content-script");
|
||||
|
||||
let result = await contentPage.spawn(null, () => {
|
||||
let textContent = this.content.document.body.textContent;
|
||||
let result = await contentPage.spawn([], () => {
|
||||
let textContent = content.document.body.textContent;
|
||||
// Omit the default content from file_sample.html.
|
||||
return textContent.replace("\n\nSample text\n\n\n\n", "");
|
||||
});
|
||||
|
|
|
@ -109,7 +109,7 @@ add_task(async function test_stream_encoding_data() {
|
|||
"http://example.com/lorem.html.gz"
|
||||
);
|
||||
|
||||
let content = await contentPage.spawn(null, () => {
|
||||
let content = await contentPage.spawn([], () => {
|
||||
return this.content.document.body.textContent;
|
||||
});
|
||||
|
||||
|
|
|
@ -115,7 +115,7 @@ async function test_csp({
|
|||
let contentPage = await ExtensionTestUtils.loadContentPage(
|
||||
`http://example.net/?${csp_value}`
|
||||
);
|
||||
let results = await contentPage.spawn(null, async () => {
|
||||
let results = await contentPage.spawn([], async () => {
|
||||
let img1 = this.content.document.getElementById("img1");
|
||||
let img3 = this.content.document.getElementById("img3");
|
||||
let cspJSON = JSON.parse(this.content.document.cspJSON);
|
||||
|
|
|
@ -14,6 +14,10 @@ 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(
|
||||
|
@ -78,7 +82,7 @@ add_task(async function test_permissions() {
|
|||
);
|
||||
await contentPage.loadFrameScript(frameScript);
|
||||
|
||||
let results = await contentPage.sendMessage("Test:Check", {});
|
||||
let results = await sendMessage(contentPage, "Test:Check", {});
|
||||
equal(
|
||||
results.page,
|
||||
"redirected",
|
||||
|
@ -93,7 +97,7 @@ add_task(async function test_permissions() {
|
|||
Services.prefs.setBoolPref("extensions.webapi.testing", true);
|
||||
Services.prefs.setBoolPref("extensions.webapi.testing.http", true);
|
||||
|
||||
results = await contentPage.sendMessage("Test:Check", {});
|
||||
results = await sendMessage(contentPage, "Test:Check", {});
|
||||
equal(
|
||||
results.page,
|
||||
"original",
|
||||
|
|
|
@ -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(null, () => {
|
||||
let contentText = await contentPage.spawn([], () => {
|
||||
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(null, () => {
|
||||
let contentText = await contentPage.spawn([], () => {
|
||||
return this.content.document.body.textContent;
|
||||
});
|
||||
equal(contentText, "", "view-source request should have been canceled");
|
||||
|
|
|
@ -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.spawn(null, () => {
|
||||
await page.legacySpawn(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.spawn(null, () => this.obs.done());
|
||||
let events = await page.legacySpawn(null, () => this.obs.done());
|
||||
equal(events.length, 2, "Two items were rejected by CSP");
|
||||
for (let url of events) {
|
||||
ok(
|
||||
|
|
|
@ -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(null, () =>
|
||||
await contentPage.spawn([], () =>
|
||||
content.windowUtils.clearSharedStyleSheetCache()
|
||||
);
|
||||
await contentPage.close();
|
||||
|
|
|
@ -79,7 +79,7 @@ function mockHandleAPIRequest(extPage, mockHandleAPIRequest) {
|
|||
};
|
||||
});
|
||||
|
||||
return extPage.spawn(
|
||||
return extPage.legacySpawn(
|
||||
[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.spawn([], async () => {
|
||||
const result = await page.legacySpawn([], async () => {
|
||||
const { active } = await content.navigator.serviceWorker.ready;
|
||||
const { port1, port2 } = new MessageChannel();
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче