diff --git a/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js b/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js index 26e4ec971a66..bbfb6b1ef28a 100644 --- a/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js +++ b/browser/base/content/test/fullscreen/browser_fullscreen_permissions_prompt.js @@ -8,6 +8,10 @@ // same histogram ID) overlap. That causes TelemetryStopwatch to log an // error. SimpleTest.ignoreAllUncaughtExceptions(true); +const { PromiseTestUtils } = ChromeUtils.import( + "resource://testing-common/PromiseTestUtils.jsm" +); +PromiseTestUtils.whitelistRejectionsGlobally(/Not in fullscreen mode/); SimpleTest.requestCompleteLog(); diff --git a/browser/base/content/test/tabs/browser_tabSpinnerProbe.js b/browser/base/content/test/tabs/browser_tabSpinnerProbe.js index 8680b41144f5..0a27b6f3ea02 100644 --- a/browser/base/content/test/tabs/browser_tabSpinnerProbe.js +++ b/browser/base/content/test/tabs/browser_tabSpinnerProbe.js @@ -32,7 +32,7 @@ function sum(aArray) { * Resolves once the hang is done. */ function hangContentProcess(browser, aMs) { - return SpecialPowers.spawn(browser, [aMs], async function(ms) { + return ContentTask.spawn(browser, aMs, function(ms) { let then = Date.now(); while (Date.now() - then < ms) { // Let's burn some CPU... diff --git a/browser/components/extensions/test/browser/browser_ext_url_overrides_newtab.js b/browser/components/extensions/test/browser/browser_ext_url_overrides_newtab.js index 7b1493b4ee4a..5179fe88cf27 100644 --- a/browser/components/extensions/test/browser/browser_ext_url_overrides_newtab.js +++ b/browser/components/extensions/test/browser/browser_ext_url_overrides_newtab.js @@ -643,7 +643,7 @@ add_task(async function dontTemporarilyShowAboutExtensionPath() { gBrowser.removeProgressListener(wpl); is(gURLBar.value, "", "URL bar value should be empty."); - SpecialPowers.spawn(tab.linkedBrowser, [], function() { + await SpecialPowers.spawn(tab.linkedBrowser, [], function() { is( content.document.body.textContent, "New tab!", diff --git a/browser/components/search/test/browser/browser_searchEngine_behaviors.js b/browser/components/search/test/browser/browser_searchEngine_behaviors.js index 11e8125da395..7677051617c9 100644 --- a/browser/components/search/test/browser/browser_searchEngine_behaviors.js +++ b/browser/components/search/test/browser/browser_searchEngine_behaviors.js @@ -164,13 +164,13 @@ async function testSearchEngine(engineDetails) { searchURL: base.replace("{code}", engineDetails.codes.newTab), async preTest(tab) { let browser = tab.linkedBrowser; - await BrowserTestUtils.loadURI(browser, "about:newtab"); - await BrowserTestUtils.browserLoaded(browser); + BrowserTestUtils.loadURI(browser, "about:newtab"); + await BrowserTestUtils.browserLoaded(browser, false, "about:newtab"); await promiseContentSearchReady(browser); }, async run(tab) { - await SpecialPowers.spawn(tab.linkedBrowser, [], async function(args) { + await SpecialPowers.spawn(tab.linkedBrowser, [], async function() { let input = content.document.querySelector("input[id*=search-]"); input.focus(); input.value = "foo"; diff --git a/browser/components/sessionstore/test/browser_339445.js b/browser/components/sessionstore/test/browser_339445.js index cd0d91bf6c77..58a0f8dbb5cd 100644 --- a/browser/components/sessionstore/test/browser_339445.js +++ b/browser/components/sessionstore/test/browser_339445.js @@ -10,7 +10,7 @@ add_task(async function test() { "browser/components/sessionstore/test/browser_339445_sample.html"; let tab = BrowserTestUtils.addTab(gBrowser, testURL); - await promiseBrowserLoaded(tab.linkedBrowser); + await promiseBrowserLoaded(tab.linkedBrowser, true, testURL); await SpecialPowers.spawn(tab.linkedBrowser, [], function() { let doc = content.document; @@ -24,7 +24,7 @@ add_task(async function test() { let tab2 = gBrowser.duplicateTab(tab); await promiseTabRestored(tab2); - await SpecialPowers.spawn(tab2.linkedBrowser, [], function() { + await ContentTask.spawn(tab2.linkedBrowser, null, function() { let doc2 = content.document; is( doc2.getElementById("storageTestItem").textContent, diff --git a/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js b/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js index 506299b9033f..c2498d3dfd32 100644 --- a/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js +++ b/browser/components/urlbar/tests/browser/browser_urlbar_blanking.js @@ -34,12 +34,12 @@ add_task(async function() { ); // When reloading, the javascript: uri we're using will throw an exception. // That's deliberate, so we need to tell mochitest to ignore it: - SimpleTest.expectUncaughtException(true); await SpecialPowers.spawn(tab.linkedBrowser, [], async function() { // This is sync, so by the time we return we should have changed the URL bar. content.location.reload(); + }).catch(e => { + // Ignore expected exception. }); ok(!!gURLBar.value, "URL bar should not be blank."); BrowserTestUtils.removeTab(tab); - SimpleTest.expectUncaughtException(false); }); diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js index 76782229cc5b..2ad45ecdfb06 100644 --- a/browser/extensions/formautofill/test/browser/head.js +++ b/browser/extensions/formautofill/test/browser/head.js @@ -178,9 +178,9 @@ async function sleep(ms = 500) { async function focusAndWaitForFieldsIdentified(browser, selector) { info("expecting the target input being focused and identified"); /* eslint no-shadow: ["error", { "allow": ["selector", "previouslyFocused", "previouslyIdentified"] }] */ - const { previouslyFocused, previouslyIdentified } = await SpecialPowers.spawn( + const { previouslyFocused, previouslyIdentified } = await ContentTask.spawn( browser, - [{ selector }], + { selector }, async function({ selector }) { const { FormLikeFactory } = ChromeUtils.import( "resource://gre/modules/FormLikeFactory.jsm" diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm index 83d895ee833b..b679ab55bdd4 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm @@ -154,24 +154,17 @@ async function clickOn(selector, beforeContentFn) { URL ); + let { SpecialPowers } = lastTab.ownerGlobal; if (beforeContentFn) { - await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn( - lastTab.linkedBrowser, - [], - beforeContentFn - ); + await SpecialPowers.spawn(lastTab.linkedBrowser, [], beforeContentFn); } - await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn( - lastTab.linkedBrowser, - [selector], - async function(arg) { - E10SUtils.wrapHandlingUserInput(content, true, function() { - let element = content.document.querySelector(arg); - element.click(); - }); - } - ); + await SpecialPowers.spawn(lastTab.linkedBrowser, [selector], arg => { + E10SUtils.wrapHandlingUserInput(content, true, function() { + let element = content.document.querySelector(arg); + element.click(); + }); + }); // Wait for the popup to actually be shown before making the screenshot await BrowserTestUtils.waitForEvent( diff --git a/devtools/client/jsonview/test/head.js b/devtools/client/jsonview/test/head.js index b0500a156bdc..03850a96ebc1 100644 --- a/devtools/client/jsonview/test/head.js +++ b/devtools/client/jsonview/test/head.js @@ -80,7 +80,7 @@ async function addJsonViewTab( await Promise.race([ error, // eslint-disable-next-line no-shadow - SpecialPowers.spawn(browser, [data], async function(data) { + ContentTask.spawn(browser, data, async function(data) { // Check if there is a JSONView object. const { JSONView } = content.wrappedJSObject; if (!JSONView) { diff --git a/devtools/client/netmonitor/test/head.js b/devtools/client/netmonitor/test/head.js index 23164c911b80..6e9d27207e5e 100644 --- a/devtools/client/netmonitor/test/head.js +++ b/devtools/client/netmonitor/test/head.js @@ -984,7 +984,7 @@ async function selectIndexAndWaitForSourceEditor(monitor, index) { */ async function performRequests(monitor, tab, count) { const wait = waitForNetworkEvents(monitor, count); - await SpecialPowers.spawn(tab.linkedBrowser, [count], requestCount => { + await ContentTask.spawn(tab.linkedBrowser, count, requestCount => { content.wrappedJSObject.performRequests(requestCount); }); await wait; diff --git a/devtools/client/responsive/test/browser/browser.ini b/devtools/client/responsive/test/browser/browser.ini index dd43b7951e1d..f041d90fe25f 100644 --- a/devtools/client/responsive/test/browser/browser.ini +++ b/devtools/client/responsive/test/browser/browser.ini @@ -30,7 +30,6 @@ support-files = skip-if = fission [browser_contextmenu_inspect.js] [browser_contextual_identity.js] -fail-if = fission #Bug 1585437 [browser_device_change.js] [browser_device_custom_edit.js] [browser_device_custom_remove.js] @@ -46,7 +45,6 @@ fail-if = fission #Bug 1585437 [browser_ext_messaging.js] tags = devtools webextensions [browser_favicon.js] -fail-if = fission #Bug 1585437 [browser_frame_script_active.js] [browser_hide_container.js] [browser_in_rdm_pane.js] @@ -71,7 +69,6 @@ skip-if = fission [browser_state_restore.js] [browser_tab_close.js] [browser_tab_remoteness_change.js] -fail-if = fission #Bug 1585437 [browser_target_blank.js] [browser_telemetry_activate_rdm.js] [browser_toolbox_computed_view.js] diff --git a/devtools/client/responsive/test/browser/browser_contextual_identity.js b/devtools/client/responsive/test/browser/browser_contextual_identity.js index 8c9291b8cb1a..9b7ce19a2d2f 100644 --- a/devtools/client/responsive/test/browser/browser_contextual_identity.js +++ b/devtools/client/responsive/test/browser/browser_contextual_identity.js @@ -5,6 +5,13 @@ const TEST_URL = TEST_URI_ROOT + "contextual_identity.html"; +const { PromiseTestUtils } = ChromeUtils.import( + "resource://testing-common/PromiseTestUtils.jsm" +); +PromiseTestUtils.whitelistRejectionsGlobally( + /Permission denied to access property "document" on cross-origin object/ +); + // Opens `uri' in a new tab with the provided userContextId. // Returns the newly opened tab and browser. async function addTabInUserContext(uri, userContextId) { diff --git a/devtools/client/responsive/test/browser/browser_favicon.js b/devtools/client/responsive/test/browser/browser_favicon.js index 22660c5fed6e..9a5c73d600aa 100644 --- a/devtools/client/responsive/test/browser/browser_favicon.js +++ b/devtools/client/responsive/test/browser/browser_favicon.js @@ -5,6 +5,13 @@ // Test that favicons make it to the parent process. +const { PromiseTestUtils } = ChromeUtils.import( + "resource://testing-common/PromiseTestUtils.jsm" +); +PromiseTestUtils.whitelistRejectionsGlobally( + /Permission denied to access property "document" on cross-origin object/ +); + const TEST_URL = `${URL_ROOT}favicon.html`; function waitForLinkAvailable(browser) { diff --git a/devtools/client/responsive/test/browser/browser_tab_remoteness_change.js b/devtools/client/responsive/test/browser/browser_tab_remoteness_change.js index e7c7141d2ff2..a167eb30cfc4 100644 --- a/devtools/client/responsive/test/browser/browser_tab_remoteness_change.js +++ b/devtools/client/responsive/test/browser/browser_tab_remoteness_change.js @@ -5,6 +5,13 @@ // Verify RDM closes synchronously when tabs change remoteness. +const { PromiseTestUtils } = ChromeUtils.import( + "resource://testing-common/PromiseTestUtils.jsm" +); +PromiseTestUtils.whitelistRejectionsGlobally( + /Permission denied to access property "document" on cross-origin object/ +); + const TEST_URL = "http://example.com/"; add_task(async function() { diff --git a/devtools/client/styleeditor/test/head.js b/devtools/client/styleeditor/test/head.js index dde9b8e20fb5..ecd8c9dc3851 100644 --- a/devtools/client/styleeditor/test/head.js +++ b/devtools/client/styleeditor/test/head.js @@ -70,7 +70,7 @@ var reloadPageAndWaitForStyleSheets = async function(ui) { const onReset = ui.once("stylesheets-reset"); const browser = gBrowser.selectedBrowser; - await SpecialPowers.spawn(browser, [], "() => content.location.reload()"); + await SpecialPowers.spawn(browser, [], () => content.location.reload()); await onReset; }; diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js index 1d598c28e763..9d1481d37903 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_page_error.js @@ -75,9 +75,9 @@ async function generatePageErrorStubs() { expectUncaughtException(); } - await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function( - subCode - ) { + // Note: This needs to use ContentTask rather than SpecialPowers.spawn + // because the latter includes cross-process stack information. + await ContentTask.spawn(gBrowser.selectedBrowser, code, function(subCode) { const script = content.document.createElement("script"); script.append(content.document.createTextNode(subCode)); content.document.body.append(script); diff --git a/dom/base/test/browser_inputStream_structuredClone.js b/dom/base/test/browser_inputStream_structuredClone.js index 865c9c922636..e4a6f08b4cb9 100644 --- a/dom/base/test/browser_inputStream_structuredClone.js +++ b/dom/base/test/browser_inputStream_structuredClone.js @@ -27,8 +27,10 @@ async function runTest(input, url) { "The length of the inputStream matches: " + input.length ); + // FIXME: SpecialPowers.spawn currently crashes when trying to return + // values containing input streams. /* eslint-disable no-shadow */ - let dataBack = await SpecialPowers.spawn(browser, [data], function(data) { + let dataBack = await ContentTask.spawn(browser, data, function(data) { let dataBack = { inputStream: data.inputStream, check: true, diff --git a/dom/ipc/tests/browser_cancel_content_js.js b/dom/ipc/tests/browser_cancel_content_js.js index a44c9cef4947..ffaafb719b51 100644 --- a/dom/ipc/tests/browser_cancel_content_js.js +++ b/dom/ipc/tests/browser_cancel_content_js.js @@ -25,15 +25,13 @@ async function test_navigation(nextPage, cancelContentJSPref, shouldCancel) { opening: TEST_PAGE, }); - const loopEnded = SpecialPowers.spawn( - tab.linkedBrowser, - [], - async function() { - return new Promise(resolve => { - content.window.addEventListener("LongLoopEnded", resolve); + const loopEnded = ContentTask.spawn(tab.linkedBrowser, [], async function() { + await new Promise(resolve => { + content.addEventListener("LongLoopEnded", resolve, { + once: true, }); - } - ); + }); + }); // Wait for the test page's long-running JS loop to start; it happens ~500ms // after load. diff --git a/security/sandbox/test/browser_content_sandbox_fs.js b/security/sandbox/test/browser_content_sandbox_fs.js index 6fd7ab2df087..967f98c856e3 100644 --- a/security/sandbox/test/browser_content_sandbox_fs.js +++ b/security/sandbox/test/browser_content_sandbox_fs.js @@ -617,9 +617,9 @@ async function testFileAccess() { ok(test.file.exists(), `${test.file.path} exists`); } - let result = await SpecialPowers.spawn( + let result = await ContentTask.spawn( test.browser, - [test.file.path], + test.file.path, test.func ); diff --git a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm index 872257588ec0..6851a018bf0b 100644 --- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm +++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm @@ -278,11 +278,7 @@ class ContentPage { } spawn(params, task) { - return this.browser.ownerGlobal.SpecialPowers.spawn( - this.browser, - [params], - task - ); + return ContentTask.spawn(this.browser, params, task); } async close() { diff --git a/toolkit/components/pictureinpicture/tests/head.js b/toolkit/components/pictureinpicture/tests/head.js index 5d9d8f0e8779..eb592c8c83cb 100644 --- a/toolkit/components/pictureinpicture/tests/head.js +++ b/toolkit/components/pictureinpicture/tests/head.js @@ -450,5 +450,5 @@ async function testToggleHelper(browser, videoID, canToggle) { // Click on the very top-left pixel of the document and ensure that we // see all of the mouse events for it. await BrowserTestUtils.synthesizeMouseAtPoint(1, 1, {}, browser); - assertSawMouseEvents(browser, true); + await assertSawMouseEvents(browser, true); } diff --git a/toolkit/content/tests/browser/browser_datetime_datepicker.js b/toolkit/content/tests/browser/browser_datetime_datepicker.js index 86bd6e435248..76546682094f 100644 --- a/toolkit/content/tests/browser/browser_datetime_datepicker.js +++ b/toolkit/content/tests/browser/browser_datetime_datepicker.js @@ -337,18 +337,17 @@ add_task(async function test_datepicker_clicked() { `data:text/html, ` ); // Click the first item (top-left corner) of the calendar + let promise = BrowserTestUtils.waitForContentEvent( + helper.tab.linkedBrowser, + "input" + ); helper.click(helper.getElement(DAYS_VIEW).children[0]); - await SpecialPowers.spawn(helper.tab.linkedBrowser, [], async function() { - let inputEl = content.document.querySelector("input"); - await ContentTaskUtils.waitForEvent(inputEl, "input"); - }); + await promise; let value = await SpecialPowers.spawn( - gBrowser.selectedBrowser, + helper.tab.linkedBrowser, [], - async () => { - return content.document.querySelector("input").value; - } + () => content.document.querySelector("input").value ); Assert.equal(value, firstDayOnCalendar); diff --git a/toolkit/content/tests/chrome/bug263683_window.xhtml b/toolkit/content/tests/chrome/bug263683_window.xhtml index 3afe38f59b58..94f741a1a8a3 100644 --- a/toolkit/content/tests/chrome/bug263683_window.xhtml +++ b/toolkit/content/tests/chrome/bug263683_window.xhtml @@ -19,8 +19,6 @@