diff --git a/browser/base/content/test/about/browser_aboutCertError_exception.js b/browser/base/content/test/about/browser_aboutCertError_exception.js index 3e1b8ac4926c..b8f33433e6d0 100644 --- a/browser/base/content/test/about/browser_aboutCertError_exception.js +++ b/browser/base/content/test/about/browser_aboutCertError_exception.js @@ -53,7 +53,9 @@ add_task(async function checkPermanentExceptionPref() { let loaded = BrowserTestUtils.browserLoaded(browser, false, BAD_CERT); info("Clicking the exceptionDialogButton in advanced panel"); let securityInfoAsString = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let doc = content.document; let exceptionButton = doc.getElementById("exceptionDialogButton"); exceptionButton.click(); @@ -128,7 +130,9 @@ add_task(async function checkBadStsCert() { }); let message = await SpecialPowers.spawn( - browser, [{ frame: useFrame }], async function({ frame }) { + browser, + [{ frame: useFrame }], + async function({ frame }) { let doc = frame ? content.document.querySelector("iframe").contentDocument : content.document; diff --git a/browser/base/content/test/about/browser_aboutCertError_noSubjectAltName.js b/browser/base/content/test/about/browser_aboutCertError_noSubjectAltName.js index bde181b2f8c3..1a2add1c9673 100644 --- a/browser/base/content/test/about/browser_aboutCertError_noSubjectAltName.js +++ b/browser/base/content/test/about/browser_aboutCertError_noSubjectAltName.js @@ -58,7 +58,9 @@ add_task(async function checkUntrustedCertError() { let browser = tab.linkedBrowser; info("Clicking the exceptionDialogButton in advanced panel"); let badCertTechnicalInfoText = await SpecialPowers.spawn( - browser, [], checkAdvancedAndGetTechnicalInfoText + browser, + [], + checkAdvancedAndGetTechnicalInfoText ); checkCorrectMessages(badCertTechnicalInfoText, browser); BrowserTestUtils.removeTab(gBrowser.selectedTab); diff --git a/browser/base/content/test/about/browser_aboutHome_search_telemetry.js b/browser/base/content/test/about/browser_aboutHome_search_telemetry.js index 938c8a3a5946..89c892e511bb 100644 --- a/browser/base/content/test/about/browser_aboutHome_search_telemetry.js +++ b/browser/base/content/test/about/browser_aboutHome_search_telemetry.js @@ -25,7 +25,9 @@ add_task(async function() { ]); await SpecialPowers.spawn( - browser, [{ expectedName: engine.name }], async function(args) { + browser, + [{ expectedName: engine.name }], + async function(args) { let engineName = content.wrappedJSObject.gContentSearchController.defaultEngine.name; is( diff --git a/browser/base/content/test/about/browser_aboutSupport.js b/browser/base/content/test/about/browser_aboutSupport.js index 5f3505aabc41..8ea27a7c8881 100644 --- a/browser/base/content/test/about/browser_aboutSupport.js +++ b/browser/base/content/test/about/browser_aboutSupport.js @@ -8,7 +8,9 @@ add_task(async function() { { gBrowser, url: "about:support" }, async function(browser) { let keyLocationServiceGoogleStatus = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let textBox = content.document.getElementById( "key-location-service-google-box" ); @@ -25,7 +27,9 @@ add_task(async function() { ); let keySafebrowsingGoogleStatus = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let textBox = content.document.getElementById( "key-safebrowsing-google-box" ); @@ -42,7 +46,9 @@ add_task(async function() { ); let keyMozillaStatus = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let textBox = content.document.getElementById("key-mozilla-box"); await ContentTaskUtils.waitForCondition( () => content.document.l10n.getAttributes(textBox).id, diff --git a/browser/base/content/test/about/head.js b/browser/base/content/test/about/head.js index a60eb53675b9..1ca560ac63ab 100644 --- a/browser/base/content/test/about/head.js +++ b/browser/base/content/test/about/head.js @@ -161,7 +161,9 @@ function promiseTabLoadEvent(tab, url) { * Wait for the search engine to change. */ function promiseContentSearchChange(browser, newEngineName) { - return SpecialPowers.spawn(browser, [{ newEngineName }], async function(args) { + return SpecialPowers.spawn(browser, [{ newEngineName }], async function( + args + ) { return new Promise(resolve => { content.addEventListener("ContentSearchService", function listener( aEvent diff --git a/browser/base/content/test/contextMenu/browser_contextmenu.js b/browser/base/content/test/contextMenu/browser_contextmenu.js index e0bdb1eb91a4..df1f89869caf 100644 --- a/browser/base/content/test/contextMenu/browser_contextmenu.js +++ b/browser/base/content/test/contextMenu/browser_contextmenu.js @@ -1243,7 +1243,9 @@ add_task(async function test_pagemenu() { ok(item, "Got generated XUL menu item"); item.doCommand(); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let pagemenu = content.document.getElementById("test-pagemenu"); Assert.ok( !pagemenu.hasAttribute("hopeless"), @@ -1312,7 +1314,9 @@ add_task(async function test_dom_full_screen() { ["full-screen-api.transition-duration.leave", "0 0"] ); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let doc = content.document; let win = doc.defaultView; let full_screen_element = doc.getElementById( @@ -1329,7 +1333,9 @@ add_task(async function test_dom_full_screen() { }, async postCheckContextMenuFn() { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let win = content.document.defaultView; let awaitFullScreenChange = ContentTaskUtils.waitForEvent( win, @@ -1465,7 +1471,9 @@ add_task(async function test_select_text_link() { }, async postCheckContextMenuFn() { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let win = content.document.defaultView; win.getSelection().removeAllRanges(); } @@ -1968,18 +1976,20 @@ add_task(async function test_cleanup_html() { * the element that will be referenced. */ async function selectText(selector) { - await SpecialPowers.spawn(gBrowser.selectedBrowser, [selector], async function( - contentSelector - ) { - info(`Selecting text of ${contentSelector}`); - let doc = content.document; - let win = doc.defaultView; - win.getSelection().removeAllRanges(); - let div = doc.createRange(); - let element = doc.querySelector(contentSelector); - Assert.ok(element, "Found element to select text from"); - div.setStartBefore(element); - div.setEndAfter(element); - win.getSelection().addRange(div); - }); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [selector], + async function(contentSelector) { + info(`Selecting text of ${contentSelector}`); + let doc = content.document; + let win = doc.defaultView; + win.getSelection().removeAllRanges(); + let div = doc.createRange(); + let element = doc.querySelector(contentSelector); + Assert.ok(element, "Found element to select text from"); + div.setStartBefore(element); + div.setEndAfter(element); + win.getSelection().addRange(div); + } + ); } diff --git a/browser/base/content/test/contextMenu/browser_contextmenu_input.js b/browser/base/content/test/contextMenu/browser_contextmenu_input.js index b93018d3a8b8..05fefaf85b4f 100644 --- a/browser/base/content/test/contextMenu/browser_contextmenu_input.js +++ b/browser/base/content/test/contextMenu/browser_contextmenu_input.js @@ -88,7 +88,9 @@ add_task(async function test_text_input_spellcheck() { // and will add fill-login context menu items. async preCheckContextMenuFn() { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let doc = content.document; let input = doc.getElementById("input_spellcheck_no_value"); input.setAttribute("spellcheck", "true"); @@ -264,7 +266,9 @@ add_task(async function test_password_input() { // and will add fill-login context menu items. async preCheckContextMenuFn() { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let doc = content.document; let input = doc.getElementById("input_password"); input.type = "password"; @@ -274,7 +278,9 @@ add_task(async function test_password_input() { }, async postCheckContextMenuFn() { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let doc = content.document; let input = doc.getElementById("input_password"); input.type = "text"; diff --git a/browser/base/content/test/contextMenu/contextmenu_common.js b/browser/base/content/test/contextMenu/contextmenu_common.js index 81d2cee72172..f89ffc97e828 100644 --- a/browser/base/content/test/contextMenu/contextmenu_common.js +++ b/browser/base/content/test/contextMenu/contextmenu_common.js @@ -362,7 +362,9 @@ async function test_contextmenu(selector, menuItems, options = {}) { if (!options.skipFocusChange) { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[lastElementSelector, selector]], async function([contentLastElementSelector, contentSelector]) { + gBrowser.selectedBrowser, + [[lastElementSelector, selector]], + async function([contentLastElementSelector, contentSelector]) { if (contentLastElementSelector) { let contentLastElement = content.document.querySelector( contentLastElementSelector @@ -384,16 +386,18 @@ async function test_contextmenu(selector, menuItems, options = {}) { if (options.waitForSpellCheck) { info("Waiting for spell check"); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [selector], async function( - contentSelector - ) { - let { onSpellCheck } = ChromeUtils.import( - "resource://testing-common/AsyncSpellCheckTestHelper.jsm" - ); - let element = content.document.querySelector(contentSelector); - await new Promise(resolve => onSpellCheck(element, resolve)); - info("Spell check running"); - }); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [selector], + async function(contentSelector) { + let { onSpellCheck } = ChromeUtils.import( + "resource://testing-common/AsyncSpellCheckTestHelper.jsm" + ); + let element = content.document.querySelector(contentSelector); + await new Promise(resolve => onSpellCheck(element, resolve)); + info("Spell check running"); + } + ); } let awaitPopupShown = BrowserTestUtils.waitForEvent( diff --git a/browser/base/content/test/favicons/browser_icon_discovery.js b/browser/base/content/test/favicons/browser_icon_discovery.js index c04354f5a5b3..81efe07d508c 100644 --- a/browser/base/content/test/favicons/browser_icon_discovery.js +++ b/browser/base/content/test/favicons/browser_icon_discovery.js @@ -97,7 +97,9 @@ add_task(async function() { let iconPromise = waitForFaviconMessage(!testCase.richIcon, expectedIcon); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[testCase.icons, ROOTURI + ICON]], ([icons, defaultIcon]) => { + gBrowser.selectedBrowser, + [[testCase.icons, ROOTURI + ICON]], + ([icons, defaultIcon]) => { let doc = content.document; let head = doc.head; diff --git a/browser/base/content/test/forms/browser_selectpopup.js b/browser/base/content/test/forms/browser_selectpopup.js index 13f43b00e545..02bf5642386b 100644 --- a/browser/base/content/test/forms/browser_selectpopup.js +++ b/browser/base/content/test/forms/browser_selectpopup.js @@ -551,7 +551,9 @@ add_task(async function test_event_order() { ); let eventsPromise = SpecialPowers.spawn( - browser, [[mode, expected]], async function([contentMode, contentExpected]) { + browser, + [[mode, expected]], + async function([contentMode, contentExpected]) { return new Promise(resolve => { function onEvent(event) { select.removeEventListener(event.type, onEvent); @@ -827,7 +829,9 @@ async function performLargePopupTests(win) { browser, "MozAfterPaint" ); - await SpecialPowers.spawn(browser, [position], async function(contentPosition) { + await SpecialPowers.spawn(browser, [position], async function( + contentPosition + ) { let select = content.document.getElementById("one"); select.setAttribute("style", contentPosition || ""); select.getBoundingClientRect(); diff --git a/browser/base/content/test/fullscreen/head.js b/browser/base/content/test/fullscreen/head.js index be1319019857..2618ba34d725 100644 --- a/browser/base/content/test/fullscreen/head.js +++ b/browser/base/content/test/fullscreen/head.js @@ -1,8 +1,6 @@ const { ContentTaskUtils } = ChromeUtils.import( "resource://testing-common/ContentTaskUtils.jsm" ); -; - function waitForFullScreenState(browser, state) { info("inside waitforfullscreenstate"); return new Promise(resolve => { diff --git a/browser/base/content/test/general/browser_addKeywordSearch.js b/browser/base/content/test/general/browser_addKeywordSearch.js index 89aa04f9117a..3e0b7b203554 100644 --- a/browser/base/content/test/general/browser_addKeywordSearch.js +++ b/browser/base/content/test/general/browser_addKeywordSearch.js @@ -30,7 +30,9 @@ add_task(async function() { ); await SpecialPowers.spawn( - tab.linkedBrowser, [{ action, param, method, id }], async function(args) { + tab.linkedBrowser, + [{ action, param, method, id }], + async function(args) { let doc = content.document; let form = doc.createElement("form"); form.id = args.id; diff --git a/browser/base/content/test/general/browser_bug1297539.js b/browser/base/content/test/general/browser_bug1297539.js index fa8f50fdda10..b81bd60602bd 100644 --- a/browser/base/content/test/general/browser_bug1297539.js +++ b/browser/base/content/test/general/browser_bug1297539.js @@ -41,7 +41,9 @@ async function cutCurrentSelection(elementQueryString, property, browser) { // The editor should be empty after cut. await SpecialPowers.spawn( - browser, [[elementQueryString, property]], async function([contentElementQueryString, contentProperty]) { + browser, + [[elementQueryString, property]], + async function([contentElementQueryString, contentProperty]) { let element = content.document.querySelector(contentElementQueryString); is( element[contentProperty], diff --git a/browser/base/content/test/general/browser_bug424101.js b/browser/base/content/test/general/browser_bug424101.js index 54a747dbaee0..df76720382d6 100644 --- a/browser/base/content/test/general/browser_bug424101.js +++ b/browser/base/content/test/general/browser_bug424101.js @@ -26,7 +26,9 @@ add_task(async function() { let test = tests[index]; await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ element: test.element, type: test.type, index }], async function(arg) { + gBrowser.selectedBrowser, + [{ element: test.element, type: test.type, index }], + async function(arg) { let element = content.document.createElement(arg.element); element.id = "element" + arg.index; if (arg.type) { diff --git a/browser/base/content/test/general/browser_bug575561.js b/browser/base/content/test/general/browser_bug575561.js index 23e6fc4916cc..ec4b7a109e58 100644 --- a/browser/base/content/test/general/browser_bug575561.js +++ b/browser/base/content/test/general/browser_bug575561.js @@ -95,7 +95,9 @@ async function testLink( href = link.href; } else { href = await SpecialPowers.spawn( - browser, [[testSubFrame, aLinkIndexOrFunction]], function([subFrame, index]) { + browser, + [[testSubFrame, aLinkIndexOrFunction]], + function([subFrame, index]) { let doc = subFrame ? content.document.querySelector("iframe").contentDocument : content.document; diff --git a/browser/base/content/test/general/browser_bug734076.js b/browser/base/content/test/general/browser_bug734076.js index 28a2d5573cf9..8684a4b4029a 100644 --- a/browser/base/content/test/general/browser_bug734076.js +++ b/browser/base/content/test/general/browser_bug734076.js @@ -24,7 +24,9 @@ add_task(async function() { element: "body", go() { return SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ writeDomainURL }], async function(arg) { + gBrowser.selectedBrowser, + [{ writeDomainURL }], + async function(arg) { let contentBody = content.document.body; contentBody.style.backgroundImage = "url('" + arg.writeDomainURL + "')"; @@ -50,7 +52,9 @@ add_task(async function() { element: "img", go() { return SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ writeDomainURL }], async function(arg) { + gBrowser.selectedBrowser, + [{ writeDomainURL }], + async function(arg) { let doc = content.document; let img = doc.createElement("img"); img.height = 100; @@ -80,7 +84,9 @@ add_task(async function() { frameIndex: 0, go() { return SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ writeDomainURL }], async function(arg) { + gBrowser.selectedBrowser, + [{ writeDomainURL }], + async function(arg) { let doc = content.document; let iframe = doc.createElement("iframe"); iframe.setAttribute("src", arg.writeDomainURL); diff --git a/browser/base/content/test/general/browser_bug763468_perwindowpb.js b/browser/base/content/test/general/browser_bug763468_perwindowpb.js index 0433dc4616d2..dff1f31da01e 100644 --- a/browser/base/content/test/general/browser_bug763468_perwindowpb.js +++ b/browser/base/content/test/general/browser_bug763468_perwindowpb.js @@ -52,10 +52,14 @@ async function openNewTab(aWindow, aExpectedURL) { false, aExpectedURL ); - let alreadyLoaded = await SpecialPowers.spawn(browser, [aExpectedURL], url => { - let doc = content.document; - return doc && doc.readyState === "complete" && doc.location.href == url; - }); + let alreadyLoaded = await SpecialPowers.spawn( + browser, + [aExpectedURL], + url => { + let doc = content.document; + return doc && doc.readyState === "complete" && doc.location.href == url; + } + ); if (!alreadyLoaded) { await loadPromise; } diff --git a/browser/base/content/test/general/browser_bug767836_perwindowpb.js b/browser/base/content/test/general/browser_bug767836_perwindowpb.js index e018323f8ddc..2d13059d4cc9 100644 --- a/browser/base/content/test/general/browser_bug767836_perwindowpb.js +++ b/browser/base/content/test/general/browser_bug767836_perwindowpb.js @@ -71,10 +71,14 @@ async function openNewTab(aWindow, aExpectedURL) { false, aExpectedURL ); - let alreadyLoaded = await SpecialPowers.spawn(browser, [aExpectedURL], url => { - let doc = content.document; - return doc && doc.readyState === "complete" && doc.location.href == url; - }); + let alreadyLoaded = await SpecialPowers.spawn( + browser, + [aExpectedURL], + url => { + let doc = content.document; + return doc && doc.readyState === "complete" && doc.location.href == url; + } + ); if (!alreadyLoaded) { await loadPromise; } diff --git a/browser/base/content/test/general/browser_fullscreen-window-open.js b/browser/base/content/test/general/browser_fullscreen-window-open.js index c451142b717b..60116b954e48 100644 --- a/browser/base/content/test/general/browser_fullscreen-window-open.js +++ b/browser/base/content/test/general/browser_fullscreen-window-open.js @@ -277,7 +277,9 @@ function waitForWindowOpen(aOptions) { function executeWindowOpenInContent(aParam) { SpecialPowers.spawn( - newBrowser.selectedBrowser, [JSON.stringify(aParam)], async function(dataTestParam) { + newBrowser.selectedBrowser, + [JSON.stringify(aParam)], + async function(dataTestParam) { let testElm = content.document.getElementById("test"); testElm.setAttribute("data-test-param", dataTestParam); testElm.click(); diff --git a/browser/base/content/test/general/browser_page_style_menu.js b/browser/base/content/test/general/browser_page_style_menu.js index f2400d9baff3..162495a85620 100644 --- a/browser/base/content/test/general/browser_page_style_menu.js +++ b/browser/base/content/test/general/browser_page_style_menu.js @@ -33,7 +33,9 @@ add_task(async function() { })); let validLinks = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [items], function(contentItems) { + gBrowser.selectedBrowser, + [items], + function(contentItems) { let contentValidLinks = 0; Array.prototype.forEach.call( content.document.querySelectorAll("link, style"), diff --git a/browser/base/content/test/general/browser_plainTextLinks.js b/browser/base/content/test/general/browser_plainTextLinks.js index a7f7211ae47e..f27e803da058 100644 --- a/browser/base/content/test/general/browser_plainTextLinks.js +++ b/browser/base/content/test/general/browser_plainTextLinks.js @@ -174,7 +174,9 @@ add_task(async function() { for (let testid = 0; testid < checks.length; testid++) { let menuPosition = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ testid }], async function(arg) { + gBrowser.selectedBrowser, + [{ testid }], + async function(arg) { let range = content.tests[arg.testid](); // Get the range of the selection and determine its coordinates. These diff --git a/browser/base/content/test/permissions/browser_canvas_fingerprinting_resistance.js b/browser/base/content/test/permissions/browser_canvas_fingerprinting_resistance.js index 321daba891ad..4fc0c25c6577 100644 --- a/browser/base/content/test/permissions/browser_canvas_fingerprinting_resistance.js +++ b/browser/base/content/test/permissions/browser_canvas_fingerprinting_resistance.js @@ -240,7 +240,11 @@ async function withNewTabInput(grantPermission, browser) { await popupHidden; is(testPermission(), Services.perms.DENY_ACTION, "permission denied"); } - await SpecialPowers.spawn(browser, [grantPermission], extractCanvasDataUserInput); + await SpecialPowers.spawn( + browser, + [grantPermission], + extractCanvasDataUserInput + ); await SpecialPowers.popPrefEnv(); } diff --git a/browser/base/content/test/permissions/browser_reservedkey.js b/browser/base/content/test/permissions/browser_reservedkey.js index 14b350ba47ed..afd2dd228000 100644 --- a/browser/base/content/test/permissions/browser_reservedkey.js +++ b/browser/base/content/test/permissions/browser_reservedkey.js @@ -189,7 +189,9 @@ add_task(async function test_backspace() { EventUtils.synthesizeKey("KEY_Backspace", {}); let fieldValue = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { return content.keysPromise; } ); diff --git a/browser/base/content/test/permissions/browser_temporary_permissions_navigation.js b/browser/base/content/test/permissions/browser_temporary_permissions_navigation.js index 72749c2eea5e..e706fdf91fc4 100644 --- a/browser/base/content/test/permissions/browser_temporary_permissions_navigation.js +++ b/browser/base/content/test/permissions/browser_temporary_permissions_navigation.js @@ -182,7 +182,9 @@ add_task(async function testTempPermissionOnNavigation() { // Navigate to another domain. await SpecialPowers.spawn( - browser, [], () => (content.document.location = "https://example.org/") + browser, + [], + () => (content.document.location = "https://example.org/") ); await loaded; @@ -200,7 +202,9 @@ add_task(async function testTempPermissionOnNavigation() { // Navigate to the original domain. await SpecialPowers.spawn( - browser, [], () => (content.document.location = "https://example.com/") + browser, + [], + () => (content.document.location = "https://example.com/") ); await loaded; diff --git a/browser/base/content/test/plugins/browser_CTP_drag_drop.js b/browser/base/content/test/plugins/browser_CTP_drag_drop.js index f4fcf7e44362..836a5cc33419 100644 --- a/browser/base/content/test/plugins/browser_CTP_drag_drop.js +++ b/browser/base/content/test/plugins/browser_CTP_drag_drop.js @@ -125,7 +125,9 @@ add_task(async function() { ok(!pluginInfo.activated, "plugin should not be activated"); await SpecialPowers.spawn( - gNewWindow.gBrowser.selectedBrowser, [], async function() { + gNewWindow.gBrowser.selectedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("test"); let bounds = plugin.getBoundingClientRect(); diff --git a/browser/base/content/test/plugins/browser_CTP_favorfallback.js b/browser/base/content/test/plugins/browser_CTP_favorfallback.js index ca3b88884844..30d68de0b994 100644 --- a/browser/base/content/test/plugins/browser_CTP_favorfallback.js +++ b/browser/base/content/test/plugins/browser_CTP_favorfallback.js @@ -68,7 +68,9 @@ add_task(async function() { ); await SpecialPowers.spawn( - tab.linkedBrowser, [testcase.name], async function testPlugins(name) { + tab.linkedBrowser, + [testcase.name], + async function testPlugins(name) { let testcaseDiv = content.document.getElementById(`testcase_${name}`); let ctpPlugins = testcaseDiv.querySelectorAll(".expected_ctp"); diff --git a/browser/base/content/test/plugins/browser_CTP_overlay_styles.js b/browser/base/content/test/plugins/browser_CTP_overlay_styles.js index 179566400157..d193e2180a20 100644 --- a/browser/base/content/test/plugins/browser_CTP_overlay_styles.js +++ b/browser/base/content/test/plugins/browser_CTP_overlay_styles.js @@ -80,7 +80,9 @@ add_task(async function() { // Work around for delayed PluginBindingAttached await promiseUpdatePluginBindings(gTestBrowser); - await SpecialPowers.spawn(gTestBrowser, [gTestcases], async function(testcases) { + await SpecialPowers.spawn(gTestBrowser, [gTestcases], async function( + testcases + ) { let doc = content.document; for (let testcaseId of Object.keys(testcases)) { diff --git a/browser/base/content/test/plugins/browser_private_browsing_eme_persistent_state.js b/browser/base/content/test/plugins/browser_private_browsing_eme_persistent_state.js index c406a91a1152..9a0b91119b43 100644 --- a/browser/base/content/test/plugins/browser_private_browsing_eme_persistent_state.js +++ b/browser/base/content/test/plugins/browser_private_browsing_eme_persistent_state.js @@ -18,7 +18,9 @@ async function isEmePersistentStateSupported(mode) { let win = await BrowserTestUtils.openNewBrowserWindow(mode); let tab = await BrowserTestUtils.openNewForegroundTab(win.gBrowser, TEST_URL); let persistentStateSupported = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { try { let config = [ { diff --git a/browser/base/content/test/plugins/browser_subframe_access_hidden_plugins.js b/browser/base/content/test/plugins/browser_subframe_access_hidden_plugins.js index 6766de3f586d..3ac79bcc4cb9 100644 --- a/browser/base/content/test/plugins/browser_subframe_access_hidden_plugins.js +++ b/browser/base/content/test/plugins/browser_subframe_access_hidden_plugins.js @@ -52,7 +52,9 @@ add_task(async function test_plugin_accessible_in_subframe() { }, async function(browser) { await SpecialPowers.spawn( - browser, [[TEST_PLUGIN_NAME, DOMAIN_2]], async function([pluginName, domain2]) { + browser, + [[TEST_PLUGIN_NAME, DOMAIN_2]], + async function([pluginName, domain2]) { Assert.ok( content.navigator.plugins[pluginName], "Top-level document should find Test Plugin" @@ -71,7 +73,11 @@ add_task(async function test_plugin_accessible_in_subframe() { "HiddenPlugin", function onHiddenPlugin(e) { sawEvent = true; - docShell.chromeEventHandler.removeEventListener("HiddenPlugin", onHiddenPlugin, true); + docShell.chromeEventHandler.removeEventListener( + "HiddenPlugin", + onHiddenPlugin, + true + ); }, true ); diff --git a/browser/base/content/test/popups/browser_popup_frames.js b/browser/base/content/test/popups/browser_popup_frames.js index c585b9fa9599..986a196d83e0 100644 --- a/browser/base/content/test/popups/browser_popup_frames.js +++ b/browser/base/content/test/popups/browser_popup_frames.js @@ -20,7 +20,9 @@ add_task(async function test_opening_blocked_popups() { ); await SpecialPowers.spawn( - tab.linkedBrowser, [baseURL + "popup_blocker.html"], uri => { + tab.linkedBrowser, + [baseURL + "popup_blocker.html"], + uri => { let iframe = content.document.createElement("iframe"); iframe.id = "popupframe"; iframe.src = uri; @@ -80,7 +82,9 @@ add_task(async function test_opening_blocked_popups() { // Remove the frame and add another one: await SpecialPowers.spawn( - tab.linkedBrowser, [baseURL + "popup_blocker.html"], uri => { + tab.linkedBrowser, + [baseURL + "popup_blocker.html"], + uri => { content.document.getElementById("popupframe").remove(); let iframe = content.document.createElement("iframe"); iframe.id = "popupframe"; diff --git a/browser/base/content/test/siteIdentity/browser_bug906190.js b/browser/base/content/test/siteIdentity/browser_bug906190.js index d522b6338f50..9bc42df9bbbc 100644 --- a/browser/base/content/test/siteIdentity/browser_bug906190.js +++ b/browser/base/content/test/siteIdentity/browser_bug906190.js @@ -50,7 +50,9 @@ async function doTest( // Wait for the script in the page to update the contents of the test div. await SpecialPowers.spawn( - browser, [childTabSpec], async childTabSpecContent => { + browser, + [childTabSpec], + async childTabSpecContent => { let testDiv = content.document.getElementById("mctestdiv"); await ContentTaskUtils.waitForCondition( () => testDiv.innerHTML == "Mixed Content Blocker disabled" diff --git a/browser/base/content/test/siteIdentity/browser_no_mcb_on_http_site.js b/browser/base/content/test/siteIdentity/browser_no_mcb_on_http_site.js index 2a8966e4bc5d..d1463a31e9e5 100644 --- a/browser/base/content/test/siteIdentity/browser_no_mcb_on_http_site.js +++ b/browser/base/content/test/siteIdentity/browser_no_mcb_on_http_site.js @@ -54,7 +54,9 @@ add_task(async function test1() { "Verifying MCB does not trigger warning/error for an http page "; expected += "with https css that includes http image"; - await SpecialPowers.spawn(gTestBrowser, [expected], async function(condition) { + await SpecialPowers.spawn(gTestBrowser, [expected], async function( + condition + ) { await ContentTaskUtils.waitForCondition( () => content.document.getElementById("testDiv").innerHTML == condition, "Waited too long for status in Test 1!" @@ -77,7 +79,9 @@ add_task(async function test2() { "Verifying MCB does not trigger warning/error for an http page "; expected += "with https css that includes http font"; - await SpecialPowers.spawn(gTestBrowser, [expected], async function(condition) { + await SpecialPowers.spawn(gTestBrowser, [expected], async function( + condition + ) { await ContentTaskUtils.waitForCondition( () => content.document.getElementById("testDiv").innerHTML == condition, "Waited too long for status in Test 2!" @@ -100,7 +104,9 @@ add_task(async function test3() { expected += "with https css that imports another http css which includes http font"; - await SpecialPowers.spawn(gTestBrowser, [expected], async function(condition) { + await SpecialPowers.spawn(gTestBrowser, [expected], async function( + condition + ) { await ContentTaskUtils.waitForCondition( () => content.document.getElementById("testDiv").innerHTML == condition, "Waited too long for status in Test 3!" diff --git a/browser/base/content/test/tabs/browser_viewsource_of_data_URI_in_file_process.js b/browser/base/content/test/tabs/browser_viewsource_of_data_URI_in_file_process.js index cf20d88bc957..d7f9398e16ff 100644 --- a/browser/base/content/test/tabs/browser_viewsource_of_data_URI_in_file_process.js +++ b/browser/base/content/test/tabs/browser_viewsource_of_data_URI_in_file_process.js @@ -39,7 +39,9 @@ add_task(async function() { BrowserTestUtils.removeTab(viewSourceTab); }); await SpecialPowers.spawn( - viewSourceTab.linkedBrowser, [DATA_URI_SOURCE], uri => { + viewSourceTab.linkedBrowser, + [DATA_URI_SOURCE], + uri => { is( content.document.documentURI, uri, diff --git a/browser/base/content/test/webextensions/browser_permissions_installTrigger.js b/browser/base/content/test/webextensions/browser_permissions_installTrigger.js index 86de5dec272f..143d252d11d9 100644 --- a/browser/base/content/test/webextensions/browser_permissions_installTrigger.js +++ b/browser/base/content/test/webextensions/browser_permissions_installTrigger.js @@ -7,7 +7,9 @@ async function installTrigger(filename) { await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); SpecialPowers.spawn( - gBrowser.selectedBrowser, [`${BASE}/${filename}`], async function(url) { + gBrowser.selectedBrowser, + [`${BASE}/${filename}`], + async function(url) { content.wrappedJSObject.installTrigger(url); } ); diff --git a/browser/base/content/test/webextensions/browser_permissions_mozAddonManager.js b/browser/base/content/test/webextensions/browser_permissions_mozAddonManager.js index 0f77d6cbece5..d66996c5b800 100644 --- a/browser/base/content/test/webextensions/browser_permissions_mozAddonManager.js +++ b/browser/base/content/test/webextensions/browser_permissions_mozAddonManager.js @@ -7,7 +7,9 @@ async function installMozAM(filename) { await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [`${BASE}/${filename}`], async function(url) { + gBrowser.selectedBrowser, + [`${BASE}/${filename}`], + async function(url) { await content.wrappedJSObject.installMozAM(url); } ); diff --git a/browser/base/content/test/webextensions/browser_permissions_unsigned.js b/browser/base/content/test/webextensions/browser_permissions_unsigned.js index 867ca59b73b1..ecb488f85a79 100644 --- a/browser/base/content/test/webextensions/browser_permissions_unsigned.js +++ b/browser/base/content/test/webextensions/browser_permissions_unsigned.js @@ -24,7 +24,9 @@ add_task(async function test_unsigned() { await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); SpecialPowers.spawn( - gBrowser.selectedBrowser, [`${BASE}/browser_webext_unsigned.xpi`], async function(url) { + gBrowser.selectedBrowser, + [`${BASE}/browser_webext_unsigned.xpi`], + async function(url) { content.wrappedJSObject.installTrigger(url); } ); diff --git a/browser/base/content/test/webrtc/browser_devices_get_user_media_paused.js b/browser/base/content/test/webrtc/browser_devices_get_user_media_paused.js index 330f8b47b124..c6e9fe4ed1f2 100644 --- a/browser/base/content/test/webrtc/browser_devices_get_user_media_paused.js +++ b/browser/base/content/test/webrtc/browser_devices_get_user_media_paused.js @@ -2,55 +2,61 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ function setTrackEnabled(audio, video) { - return SpecialPowers.spawn(gBrowser.selectedBrowser, [{ audio, video }], function( - args - ) { - let stream = content.wrappedJSObject.gStreams[0]; - if (args.audio != null) { - stream.getAudioTracks()[0].enabled = args.audio; + return SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ audio, video }], + function(args) { + let stream = content.wrappedJSObject.gStreams[0]; + if (args.audio != null) { + stream.getAudioTracks()[0].enabled = args.audio; + } + if (args.video != null) { + stream.getVideoTracks()[0].enabled = args.video; + } } - if (args.video != null) { - stream.getVideoTracks()[0].enabled = args.video; - } - }); + ); } function cloneTracks(audio, video) { - return SpecialPowers.spawn(gBrowser.selectedBrowser, [{ audio, video }], function( - args - ) { - if (!content.wrappedJSObject.gClones) { - content.wrappedJSObject.gClones = []; + return SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ audio, video }], + function(args) { + if (!content.wrappedJSObject.gClones) { + content.wrappedJSObject.gClones = []; + } + let clones = content.wrappedJSObject.gClones; + let stream = content.wrappedJSObject.gStreams[0]; + if (args.audio != null) { + clones.push(stream.getAudioTracks()[0].clone()); + } + if (args.video != null) { + clones.push(stream.getVideoTracks()[0].clone()); + } } - let clones = content.wrappedJSObject.gClones; - let stream = content.wrappedJSObject.gStreams[0]; - if (args.audio != null) { - clones.push(stream.getAudioTracks()[0].clone()); - } - if (args.video != null) { - clones.push(stream.getVideoTracks()[0].clone()); - } - }); + ); } function stopClonedTracks(audio, video) { - return SpecialPowers.spawn(gBrowser.selectedBrowser, [{ audio, video }], function( - args - ) { - let clones = content.wrappedJSObject.gClones || []; - if (args.audio != null) { - clones.filter(t => t.kind == "audio").forEach(t => t.stop()); + return SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ audio, video }], + function(args) { + let clones = content.wrappedJSObject.gClones || []; + if (args.audio != null) { + clones.filter(t => t.kind == "audio").forEach(t => t.stop()); + } + if (args.video != null) { + clones.filter(t => t.kind == "video").forEach(t => t.stop()); + } + let liveClones = clones.filter(t => t.readyState == "live"); + if (!liveClones.length) { + delete content.wrappedJSObject.gClones; + } else { + content.wrappedJSObject.gClones = liveClones; + } } - if (args.video != null) { - clones.filter(t => t.kind == "video").forEach(t => t.stop()); - } - let liveClones = clones.filter(t => t.readyState == "live"); - if (!liveClones.length) { - delete content.wrappedJSObject.gClones; - } else { - content.wrappedJSObject.gClones = liveClones; - } - }); + ); } var gTests = [ diff --git a/browser/base/content/test/webrtc/head.js b/browser/base/content/test/webrtc/head.js index 987b391e64bf..7bec3b04a975 100644 --- a/browser/base/content/test/webrtc/head.js +++ b/browser/base/content/test/webrtc/head.js @@ -276,7 +276,9 @@ function expectObserverCalledOnClose( function promiseMessage(aMessage, aAction, aCount = 1) { let promise = SpecialPowers.spawn( - gBrowser.selectedBrowser, [[aMessage, aCount]], async function([expectedMessage, expectedCount]) { + gBrowser.selectedBrowser, + [[aMessage, aCount]], + async function([expectedMessage, expectedCount]) { return new Promise(resolve => { function listenForMessage({ data }) { if ( @@ -444,7 +446,9 @@ function promiseRequestDevice( ) { info("requesting devices"); return SpecialPowers.spawn( - aBrowser, [{ aRequestAudio, aRequestVideo, aFrameId, aType, aBadDevice }], async function(args) { + aBrowser, + [{ aRequestAudio, aRequestVideo, aFrameId, aType, aBadDevice }], + async function(args) { let global = content.wrappedJSObject; if (args.aFrameId) { global = global.document.getElementById(args.aFrameId).contentWindow; @@ -479,15 +483,17 @@ async function closeStream( } info("closing the stream"); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [aFrameId], async function( - contentFrameId - ) { - let global = content.wrappedJSObject; - if (contentFrameId) { - global = global.document.getElementById(contentFrameId).contentWindow; + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [aFrameId], + async function(contentFrameId) { + let global = content.wrappedJSObject; + if (contentFrameId) { + global = global.document.getElementById(contentFrameId).contentWindow; + } + global.closeStream(); } - global.closeStream(); - }); + ); await Promise.all(observerPromises); @@ -503,7 +509,9 @@ async function reloadAndAssertClosedStreams() { let loadedPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], "() => content.location.reload()" + gBrowser.selectedBrowser, + [], + "() => content.location.reload()" ); await loadedPromise; diff --git a/browser/components/aboutlogins/tests/browser/browser_breachAlertShowingForAddedLogin.js b/browser/components/aboutlogins/tests/browser/browser_breachAlertShowingForAddedLogin.js index 3196e474a498..9808c6cdfb0c 100644 --- a/browser/components/aboutlogins/tests/browser/browser_breachAlertShowingForAddedLogin.js +++ b/browser/components/aboutlogins/tests/browser/browser_breachAlertShowingForAddedLogin.js @@ -37,24 +37,30 @@ add_task(async function test_added_login_shows_breach_warning() { }); TEST_LOGIN3 = await addLogin(TEST_LOGIN3); - await SpecialPowers.spawn(browser, [TEST_LOGIN3.guid], async aTestLogin3Guid => { - let loginList = Cu.waiveXrays(content.document.querySelector("login-list")); - is( - loginList._loginGuidsSortedOrder.length, - 1, - "one login should be in the list" - ); - let breachedLoginListItems; - await ContentTaskUtils.waitForCondition(() => { - breachedLoginListItems = loginList._list.querySelectorAll( - ".login-list-item[data-guid].breached" + await SpecialPowers.spawn( + browser, + [TEST_LOGIN3.guid], + async aTestLogin3Guid => { + let loginList = Cu.waiveXrays( + content.document.querySelector("login-list") ); - return breachedLoginListItems.length == 1; - }, "waiting for the login to get marked as breached"); - is( - breachedLoginListItems[0].dataset.guid, - aTestLogin3Guid, - "the breached login should be login3" - ); - }); + is( + loginList._loginGuidsSortedOrder.length, + 1, + "one login should be in the list" + ); + let breachedLoginListItems; + await ContentTaskUtils.waitForCondition(() => { + breachedLoginListItems = loginList._list.querySelectorAll( + ".login-list-item[data-guid].breached" + ); + return breachedLoginListItems.length == 1; + }, "waiting for the login to get marked as breached"); + is( + breachedLoginListItems[0].dataset.guid, + aTestLogin3Guid, + "the breached login should be login3" + ); + } + ); }); diff --git a/browser/components/aboutlogins/tests/browser/browser_contextmenuFillLogins.js b/browser/components/aboutlogins/tests/browser/browser_contextmenuFillLogins.js index 6e59416a5664..687a7a7f2380 100644 --- a/browser/components/aboutlogins/tests/browser/browser_contextmenuFillLogins.js +++ b/browser/components/aboutlogins/tests/browser/browser_contextmenuFillLogins.js @@ -31,7 +31,9 @@ const gTests = [ async setup(browser) { // load up the edit login view await SpecialPowers.spawn( - browser, [LoginHelper.loginToVanillaObject(TEST_LOGIN1)], async login => { + browser, + [LoginHelper.loginToVanillaObject(TEST_LOGIN1)], + async login => { let loginList = content.document.querySelector("login-list"); let loginListItem = loginList.shadowRoot.querySelector( ".login-list-item[data-guid]:not([hidden])" diff --git a/browser/components/aboutlogins/tests/browser/browser_copyToClipboardButton.js b/browser/components/aboutlogins/tests/browser/browser_copyToClipboardButton.js index 44249e4e09dd..6aabd5104d3e 100644 --- a/browser/components/aboutlogins/tests/browser/browser_copyToClipboardButton.js +++ b/browser/components/aboutlogins/tests/browser/browser_copyToClipboardButton.js @@ -50,7 +50,9 @@ add_task(async function test() { await SimpleTest.promiseClipboardChange( testObj.expectedValue, async () => { - await SpecialPowers.spawn(browser, [testObj], async function(aTestObj) { + await SpecialPowers.spawn(browser, [testObj], async function( + aTestObj + ) { let loginItem = content.document.querySelector("login-item"); let copyButton = loginItem.shadowRoot.querySelector( aTestObj.copyButtonSelector diff --git a/browser/components/aboutlogins/tests/browser/browser_createLogin.js b/browser/components/aboutlogins/tests/browser/browser_createLogin.js index 7c1ffbb6a20c..c28d32c403cd 100644 --- a/browser/components/aboutlogins/tests/browser/browser_createLogin.js +++ b/browser/components/aboutlogins/tests/browser/browser_createLogin.js @@ -52,7 +52,9 @@ add_task(async function test_create_login() { ); await SpecialPowers.spawn( - browser, [[originTuple, i]], async ([aOriginTuple, index]) => { + browser, + [[originTuple, i]], + async ([aOriginTuple, index]) => { let loginList = Cu.waiveXrays( content.document.querySelector("login-list") ); @@ -239,14 +241,20 @@ add_task(async function test_create_login() { }); } - await SpecialPowers.spawn(browser, [testCases.length], async testCasesLength => { - let loginList = Cu.waiveXrays(content.document.querySelector("login-list")); - is( - loginList._loginGuidsSortedOrder.length, - 5, - "login list should have a login per testcase" - ); - }); + await SpecialPowers.spawn( + browser, + [testCases.length], + async testCasesLength => { + let loginList = Cu.waiveXrays( + content.document.querySelector("login-list") + ); + is( + loginList._loginGuidsSortedOrder.length, + 5, + "login list should have a login per testcase" + ); + } + ); }); add_task(async function test_cancel_create_login() { diff --git a/browser/components/aboutlogins/tests/browser/browser_deleteLogin.js b/browser/components/aboutlogins/tests/browser/browser_deleteLogin.js index c384c3a0fa50..92e24a46d8a5 100644 --- a/browser/components/aboutlogins/tests/browser/browser_deleteLogin.js +++ b/browser/components/aboutlogins/tests/browser/browser_deleteLogin.js @@ -17,7 +17,9 @@ add_task(async function test_show_logins() { let browser = gBrowser.selectedBrowser; await SpecialPowers.spawn( - browser, [[TEST_LOGIN1.guid, TEST_LOGIN2.guid]], async loginGuids => { + browser, + [[TEST_LOGIN1.guid, TEST_LOGIN2.guid]], + async loginGuids => { let loginList = Cu.waiveXrays( content.document.querySelector("login-list") ); diff --git a/browser/components/aboutlogins/tests/browser/browser_fxAccounts.js b/browser/components/aboutlogins/tests/browser/browser_fxAccounts.js index c52921adb9b7..4df8e19d09ff 100644 --- a/browser/components/aboutlogins/tests/browser/browser_fxAccounts.js +++ b/browser/components/aboutlogins/tests/browser/browser_fxAccounts.js @@ -131,7 +131,9 @@ add_task(async function test_login_syncing_enabled() { let browser = gBrowser.selectedBrowser; await SpecialPowers.spawn( - browser, [[TEST_EMAIL, TEST_AVATAR_URL]], async ([expectedEmail, expectedAvatarURL]) => { + browser, + [[TEST_EMAIL, TEST_AVATAR_URL]], + async ([expectedEmail, expectedAvatarURL]) => { let fxAccountsButton = content.document.querySelector( "fxaccounts-button" ); diff --git a/browser/components/aboutlogins/tests/browser/browser_loginItemErrors.js b/browser/components/aboutlogins/tests/browser/browser_loginItemErrors.js index 6c532e6e1712..233601f7c518 100644 --- a/browser/components/aboutlogins/tests/browser/browser_loginItemErrors.js +++ b/browser/components/aboutlogins/tests/browser/browser_loginItemErrors.js @@ -25,7 +25,9 @@ add_task(async function test_showLoginItemErrors() { EXPECTED_ERROR_MESSAGE = "This login already exists."; await SpecialPowers.spawn( - browser, [LoginHelper.loginToVanillaObject(LOGIN_TO_UPDATE)], async loginToUpdate => { + browser, + [LoginHelper.loginToVanillaObject(LOGIN_TO_UPDATE)], + async loginToUpdate => { const loginItem = Cu.waiveXrays( content.document.querySelector("login-item") ); diff --git a/browser/components/aboutlogins/tests/browser/browser_loginSortOrderRestored.js b/browser/components/aboutlogins/tests/browser/browser_loginSortOrderRestored.js index 8e251787b8ca..25f416871c12 100644 --- a/browser/components/aboutlogins/tests/browser/browser_loginSortOrderRestored.js +++ b/browser/components/aboutlogins/tests/browser/browser_loginSortOrderRestored.js @@ -24,7 +24,9 @@ add_task(async function test_sort_order_persisted() { }, async function(browser) { await SpecialPowers.spawn( - browser, [[TEST_LOGIN1, TEST_LOGIN2]], async function([testLogin1, testLogin2]) { + browser, + [[TEST_LOGIN1, TEST_LOGIN2]], + async function([testLogin1, testLogin2]) { let loginList = Cu.waiveXrays( content.document.querySelector("login-list") ); @@ -63,7 +65,9 @@ add_task(async function test_sort_order_persisted() { url: "about:logins", }, async function(browser) { - await SpecialPowers.spawn(browser, [TEST_LOGIN1], async function(testLogin1) { + await SpecialPowers.spawn(browser, [TEST_LOGIN1], async function( + testLogin1 + ) { let loginList = Cu.waiveXrays( content.document.querySelector("login-list") ); diff --git a/browser/components/aboutlogins/tests/browser/browser_masterPassword.js b/browser/components/aboutlogins/tests/browser/browser_masterPassword.js index 6531db8c8c81..c18349e485cc 100644 --- a/browser/components/aboutlogins/tests/browser/browser_masterPassword.js +++ b/browser/components/aboutlogins/tests/browser/browser_masterPassword.js @@ -30,13 +30,19 @@ function waitForMPDialog(action) { } function waitForLoginCountToReach(browser, loginCount) { - return SpecialPowers.spawn(browser, [loginCount], async expectedLoginCount => { - let loginList = Cu.waiveXrays(content.document.querySelector("login-list")); - await ContentTaskUtils.waitForCondition(() => { - return loginList._loginGuidsSortedOrder.length == expectedLoginCount; - }); - return loginList._loginGuidsSortedOrder.length; - }); + return SpecialPowers.spawn( + browser, + [loginCount], + async expectedLoginCount => { + let loginList = Cu.waiveXrays( + content.document.querySelector("login-list") + ); + await ContentTaskUtils.waitForCondition(() => { + return loginList._loginGuidsSortedOrder.length == expectedLoginCount; + }); + return loginList._loginGuidsSortedOrder.length; + } + ); } add_task(async function test() { diff --git a/browser/components/aboutlogins/tests/browser/browser_noLoginsView.js b/browser/components/aboutlogins/tests/browser/browser_noLoginsView.js index 75dc8857c316..487eb93b38be 100644 --- a/browser/components/aboutlogins/tests/browser/browser_noLoginsView.js +++ b/browser/components/aboutlogins/tests/browser/browser_noLoginsView.js @@ -14,7 +14,9 @@ add_task(async function setup() { add_task(async function test_no_logins_class() { let { platform } = AppConstants; await SpecialPowers.spawn( - gBrowser.selectedBrowser, [platform], async aPlatform => { + gBrowser.selectedBrowser, + [platform], + async aPlatform => { let loginList = content.document.querySelector("login-list"); ok( @@ -130,7 +132,9 @@ add_task( TEST_LOGIN1 = await addLogin(TEST_LOGIN1); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [TEST_LOGIN1.guid], async testLogin1Guid => { + gBrowser.selectedBrowser, + [TEST_LOGIN1.guid], + async testLogin1Guid => { let loginList = content.document.querySelector("login-list"); let loginItem = content.document.querySelector("login-item"); let loginIntro = content.document.querySelector("login-intro"); diff --git a/browser/components/aboutlogins/tests/browser/browser_openPreferencesExternal.js b/browser/components/aboutlogins/tests/browser/browser_openPreferencesExternal.js index f42e22beeec1..d1e6d232f4c2 100644 --- a/browser/components/aboutlogins/tests/browser/browser_openPreferencesExternal.js +++ b/browser/components/aboutlogins/tests/browser/browser_openPreferencesExternal.js @@ -59,7 +59,9 @@ add_task(async function test_open_feedback() { // when trying to call element.ownerGlobal on the targeted shadow DOM node. This is // on file as bug 1557489. As a workaround, this manually calculates the position to click. let { x, y } = await SpecialPowers.spawn( - browser, [selector], async menuItemSelector => { + browser, + [selector], + async menuItemSelector => { let menuButton = Cu.waiveXrays( content.document.querySelector("menu-button") ); diff --git a/browser/components/aboutlogins/tests/browser/browser_updateLogin.js b/browser/components/aboutlogins/tests/browser/browser_updateLogin.js index 7069f190a9cf..3b90ec0e9faf 100644 --- a/browser/components/aboutlogins/tests/browser/browser_updateLogin.js +++ b/browser/components/aboutlogins/tests/browser/browser_updateLogin.js @@ -30,7 +30,9 @@ add_task(async function test_show_logins() { add_task(async function test_login_item() { let browser = gBrowser.selectedBrowser; await SpecialPowers.spawn( - browser, [LoginHelper.loginToVanillaObject(TEST_LOGIN1)], async login => { + browser, + [LoginHelper.loginToVanillaObject(TEST_LOGIN1)], + async login => { let loginList = Cu.waiveXrays( content.document.querySelector("login-list") ); diff --git a/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js b/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js index 9f3e5b32bf85..e4c4fae7f653 100644 --- a/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js +++ b/browser/components/contextualidentity/test/browser/browser_broadcastchannel.js @@ -83,7 +83,9 @@ async function runTestForReceiver(receiver) { // then send a message from a tab in the same user context for (let sender of [sender1, sender2]) { await SpecialPowers.spawn( - sender.browser, [{ name: channelName, message: sender.message }], function(opts) { + sender.browser, + [{ name: channelName, message: sender.message }], + function(opts) { let bc = new content.window.BroadcastChannel(opts.name); bc.postMessage(opts.message); } diff --git a/browser/components/contextualidentity/test/browser/browser_eme.js b/browser/components/contextualidentity/test/browser/browser_eme.js index 9140c1773fe2..4c6111e08783 100644 --- a/browser/components/contextualidentity/test/browser/browser_eme.js +++ b/browser/components/contextualidentity/test/browser/browser_eme.js @@ -114,7 +114,9 @@ add_task(async function test() { // Update the media key for the default container. let result = await SpecialPowers.spawn( - defaultContainer.browser, [keyInfo], async function(aKeyInfo) { + defaultContainer.browser, + [keyInfo], + async function(aKeyInfo) { let access = await content.navigator.requestMediaKeySystemAccess( "org.w3.clearkey", [ @@ -180,32 +182,38 @@ add_task(async function test() { USER_ID_PERSONAL ); - await SpecialPowers.spawn(personalContainer.browser, [keyInfo], async function( - aKeyInfo - ) { - let access = await content.navigator.requestMediaKeySystemAccess( - "org.w3.clearkey", - [ - { - initDataTypes: [aKeyInfo.initDataType], - videoCapabilities: [{ contentType: "video/webm" }], - sessionTypes: ["persistent-license"], - persistentState: "required", - }, - ] - ); - let mediaKeys = await access.createMediaKeys(); - let session = mediaKeys.createSession(aKeyInfo.sessionType); + await SpecialPowers.spawn( + personalContainer.browser, + [keyInfo], + async function(aKeyInfo) { + let access = await content.navigator.requestMediaKeySystemAccess( + "org.w3.clearkey", + [ + { + initDataTypes: [aKeyInfo.initDataType], + videoCapabilities: [{ contentType: "video/webm" }], + sessionTypes: ["persistent-license"], + persistentState: "required", + }, + ] + ); + let mediaKeys = await access.createMediaKeys(); + let session = mediaKeys.createSession(aKeyInfo.sessionType); - // First, load the session to check that mediakeys do not share with - // default container. - await session.load(aKeyInfo.sessionId); + // First, load the session to check that mediakeys do not share with + // default container. + await session.load(aKeyInfo.sessionId); - let map = session.keyStatuses; + let map = session.keyStatuses; - // Check that there is no media key here. - is(map.size, 0, "No media key should be here for the personal container."); - }); + // Check that there is no media key here. + is( + map.size, + 0, + "No media key should be here for the personal container." + ); + } + ); // Close default container tab. BrowserTestUtils.removeTab(defaultContainer.tab); diff --git a/browser/components/contextualidentity/test/browser/browser_favicon.js b/browser/components/contextualidentity/test/browser/browser_favicon.js index fa205a308f58..151f40861e39 100644 --- a/browser/components/contextualidentity/test/browser/browser_favicon.js +++ b/browser/components/contextualidentity/test/browser/browser_favicon.js @@ -120,7 +120,9 @@ add_task(async function test() { // Write a cookie according to the userContext. await SpecialPowers.spawn( - tabInfo.browser, [{ userContext: USER_CONTEXTS[userContextId] }], function(arg) { + tabInfo.browser, + [{ userContext: USER_CONTEXTS[userContextId] }], + function(arg) { content.document.cookie = "userContext=" + arg.userContext; } ); diff --git a/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js b/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js index 5d11f6f202da..ac1eee178b0b 100644 --- a/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js +++ b/browser/components/contextualidentity/test/browser/browser_forgetAPI_quota_clearStoragesForPrincipal.js @@ -31,50 +31,52 @@ async function openTabInUserContext(uri, userContextId) { // Setup an entry for the indexedDB. async function setupIndexedDB(browser) { - await SpecialPowers.spawn(browser, [{ input: "TestForgetAPIs" }], async function( - arg - ) { - let request = content.indexedDB.open("idb", 1); + await SpecialPowers.spawn( + browser, + [{ input: "TestForgetAPIs" }], + async function(arg) { + let request = content.indexedDB.open("idb", 1); - request.onerror = function() { - throw new Error("error opening db connection"); - }; - - request.onupgradeneeded = event => { - let db = event.target.result; - let store = db.createObjectStore("obj", { keyPath: "id" }); - store.createIndex("userContext", "userContext", { unique: false }); - }; - - let db = await new Promise(resolve => { - request.onsuccess = event => { - resolve(event.target.result); + request.onerror = function() { + throw new Error("error opening db connection"); }; - }); - // Add an entry into the indexedDB. - let transaction = db.transaction(["obj"], "readwrite"); - let store = transaction.objectStore("obj"); - store.add({ id: 1, userContext: arg.input }); - - await new Promise(resolve => { - transaction.oncomplete = () => { - resolve(); + request.onupgradeneeded = event => { + let db = event.target.result; + let store = db.createObjectStore("obj", { keyPath: "id" }); + store.createIndex("userContext", "userContext", { unique: false }); }; - }); - // Check the indexedDB has been set properly. - transaction = db.transaction(["obj"], "readonly"); - store = transaction.objectStore("obj"); - let getRequest = store.get(1); - await new Promise(resolve => { - getRequest.onsuccess = () => { - let res = getRequest.result; - is(res.userContext, arg.input, "Check the indexedDB value"); - resolve(); - }; - }); - }); + let db = await new Promise(resolve => { + request.onsuccess = event => { + resolve(event.target.result); + }; + }); + + // Add an entry into the indexedDB. + let transaction = db.transaction(["obj"], "readwrite"); + let store = transaction.objectStore("obj"); + store.add({ id: 1, userContext: arg.input }); + + await new Promise(resolve => { + transaction.oncomplete = () => { + resolve(); + }; + }); + + // Check the indexedDB has been set properly. + transaction = db.transaction(["obj"], "readonly"); + store = transaction.objectStore("obj"); + let getRequest = store.get(1); + await new Promise(resolve => { + getRequest.onsuccess = () => { + let res = getRequest.result; + is(res.userContext, arg.input, "Check the indexedDB value"); + resolve(); + }; + }); + } + ); } // Check whether the indexedDB has been cleared. diff --git a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js index d20284a98157..e6951cf9a00f 100644 --- a/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js +++ b/browser/components/contextualidentity/test/browser/browser_forgetaboutsite.js @@ -295,7 +295,9 @@ async function test_storage_cleared() { // Check that the storages has been set correctly. await SpecialPowers.spawn( - tabInfo.browser, [{ userContext: USER_CONTEXTS[userContextId] }], async function(arg) { + tabInfo.browser, + [{ userContext: USER_CONTEXTS[userContextId] }], + async function(arg) { // Check that the local storage has been set correctly. Assert.equal( content.localStorage.getItem("userContext"), diff --git a/browser/components/contextualidentity/test/browser/browser_windowName.js b/browser/components/contextualidentity/test/browser/browser_windowName.js index f80062815661..55ff0084fa5a 100644 --- a/browser/components/contextualidentity/test/browser/browser_windowName.js +++ b/browser/components/contextualidentity/test/browser/browser_windowName.js @@ -40,16 +40,18 @@ add_task(async function test() { // Let's try to open a window from tab1 with a name 'tab-2'. info("Opening a window from the first tab..."); - await SpecialPowers.spawn(browser1, [{ url: BASE_URI + "?new" }], async function( - opts - ) { - await new content.window.wrappedJSObject.Promise(resolve => { - let w = content.window.wrappedJSObject.open(opts.url, "tab-2"); - w.onload = function() { - resolve(); - }; - }); - }); + await SpecialPowers.spawn( + browser1, + [{ url: BASE_URI + "?new" }], + async function(opts) { + await new content.window.wrappedJSObject.Promise(resolve => { + let w = content.window.wrappedJSObject.open(opts.url, "tab-2"); + w.onload = function() { + resolve(); + }; + }); + } + ); is(browser1.contentTitle, "?old", "Tab1 title must be 'old'"); is(browser1.contentPrincipal.userContextId, 1, "Tab1 UCI must be 1"); diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js index a143e810b461..00f00811193b 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_cookie_settings.js @@ -126,7 +126,9 @@ async function test_cookie_settings({ ); await tab.linkedBrowser.contentWindow.gotoPref("panePrivacy"); await SpecialPowers.spawn( - tab.linkedBrowser, [{ cookiesEnabled, cookieSettingsLocked }], async function({ cookiesEnabled, cookieSettingsLocked }) { + tab.linkedBrowser, + [{ cookiesEnabled, cookieSettingsLocked }], + async function({ cookiesEnabled, cookieSettingsLocked }) { let deleteOnCloseCheckbox = content.document.getElementById( "deleteOnClose" ); diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_popup_blocker.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_popup_blocker.js index f11f7cba418e..2132a38dad1c 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_popup_blocker.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_popup_blocker.js @@ -34,7 +34,9 @@ async function test_popup_blocker_disabled({ disabled, locked }) { "about:preferences#privacy" ); await SpecialPowers.spawn( - tab.linkedBrowser, [{ disabled, locked }], async function({ disabled, locked }) { + tab.linkedBrowser, + [{ disabled, locked }], + async function({ disabled, locked }) { let checkbox = content.document.getElementById("popupPolicy"); is( checkbox.checked, diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_extensionsettings.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_extensionsettings.js index 6b4500f9365b..cd98cbf07564 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_extensionsettings.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_extensionsettings.js @@ -131,7 +131,9 @@ add_task(async function test_install_source_blocked_direct() { }); await SpecialPowers.spawn( - tab.linkedBrowser, [{ baseUrl: BASE_URL }], async function({ baseUrl }) { + tab.linkedBrowser, + [{ baseUrl: BASE_URL }], + async function({ baseUrl }) { content.document.location.href = baseUrl + "policytest_v0.1.xpi"; } ); @@ -229,7 +231,9 @@ add_task(async function test_install_source_allowed_direct() { }); await SpecialPowers.spawn( - tab.linkedBrowser, [{ baseUrl: BASE_URL }], async function({ baseUrl }) { + tab.linkedBrowser, + [{ baseUrl: BASE_URL }], + async function({ baseUrl }) { content.document.location.href = baseUrl + "policytest_v0.1.xpi"; } ); diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_search_engine.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_search_engine.js index 012815b1fb31..98a616e82bc6 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser_policy_search_engine.js +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_search_engine.js @@ -281,7 +281,9 @@ add_task(async function test_AddSearchProvider() { "http://example.com" ); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ engineURL }], async function(args) { + gBrowser.selectedBrowser, + [{ engineURL }], + async function(args) { content.window.external.AddSearchProvider(args.engineURL); } ); diff --git a/browser/components/enterprisepolicies/tests/browser/head.js b/browser/components/enterprisepolicies/tests/browser/head.js index baa2ad3957e4..61681fd0cc51 100644 --- a/browser/components/enterprisepolicies/tests/browser/head.js +++ b/browser/components/enterprisepolicies/tests/browser/head.js @@ -53,7 +53,9 @@ async function checkBlockedPage(url, expectedBlocked) { async function() { await BrowserTestUtils.waitForCondition(async function() { let blocked = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { return content.document.documentURI.startsWith("about:neterror"); } ); diff --git a/browser/components/extensions/test/browser/browser_ext_menus_events.js b/browser/components/extensions/test/browser/browser_ext_menus_events.js index dfde64adb843..e0d71176b967 100644 --- a/browser/components/extensions/test/browser/browser_ext_menus_events.js +++ b/browser/components/extensions/test/browser/browser_ext_menus_events.js @@ -455,7 +455,9 @@ add_task(async function test_show_hide_frame() { }, async doOpenMenu() { frameId = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { const { WebNavigationFrames } = ChromeUtils.import( "resource://gre/modules/WebNavigationFrames.jsm" ); @@ -594,7 +596,9 @@ add_task(async function test_show_hide_editable_selection() { async doOpenMenu() { // Select lots of text in the test page before opening the menu. selectionText = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { let node = content.document.getElementById("editabletext"); node.select(); node.focus(); diff --git a/browser/components/extensions/test/browser/browser_ext_menus_replace_menu_permissions.js b/browser/components/extensions/test/browser/browser_ext_menus_replace_menu_permissions.js index b63a1061a107..7e1cc93f70ca 100644 --- a/browser/components/extensions/test/browser/browser_ext_menus_replace_menu_permissions.js +++ b/browser/components/extensions/test/browser/browser_ext_menus_replace_menu_permissions.js @@ -188,7 +188,9 @@ add_task(async function overrideContext_permissions() { // permissions.request requires user input, export helper. await SpecialPowers.spawn( - SidebarUI.browser.contentDocument.getElementById("webext-panels-browser"), [], () => { + SidebarUI.browser.contentDocument.getElementById("webext-panels-browser"), + [], + () => { let { withHandlingUserInput } = ChromeUtils.import( "resource://gre/modules/ExtensionCommon.jsm", {} diff --git a/browser/components/extensions/test/browser/browser_ext_pageAction_simple.js b/browser/components/extensions/test/browser/browser_ext_pageAction_simple.js index 11983d4b6608..83e816f01a71 100644 --- a/browser/components/extensions/test/browser/browser_ext_pageAction_simple.js +++ b/browser/components/extensions/test/browser/browser_ext_pageAction_simple.js @@ -166,18 +166,22 @@ add_task(async function test_pageAction_icon_on_subframe_navigation() { info("Create a sub-frame"); let subframeURL = `${BASE}#subframe-url-1`; - await SpecialPowers.spawn(gBrowser.selectedBrowser, [subframeURL], async url => { - const iframe = this.content.document.createElement("iframe"); - iframe.setAttribute("id", "test-subframe"); - iframe.setAttribute("src", url); - iframe.setAttribute("style", "height: 200px; width: 200px"); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [subframeURL], + async url => { + const iframe = this.content.document.createElement("iframe"); + iframe.setAttribute("id", "test-subframe"); + iframe.setAttribute("src", url); + iframe.setAttribute("style", "height: 200px; width: 200px"); - // Await the initial url to be loaded in the subframe. - await new Promise(resolve => { - iframe.onload = resolve; - this.content.document.body.appendChild(iframe); - }); - }); + // Await the initial url to be loaded in the subframe. + await new Promise(resolve => { + iframe.onload = resolve; + this.content.document.body.appendChild(iframe); + }); + } + ); await BrowserTestUtils.waitForCondition(() => { return document.getElementById(pageActionId); @@ -186,15 +190,21 @@ add_task(async function test_pageAction_icon_on_subframe_navigation() { info("Navigating the sub-frame"); subframeURL = `${BASE}/file_dummy.html#subframe-url-2`; - await SpecialPowers.spawn(gBrowser.selectedBrowser, [subframeURL], async url => { - const iframe = this.content.document.querySelector("iframe#test-subframe"); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [subframeURL], + async url => { + const iframe = this.content.document.querySelector( + "iframe#test-subframe" + ); - // Await the subframe navigation. - await new Promise(resolve => { - iframe.onload = resolve; - iframe.setAttribute("src", url); - }); - }); + // Await the subframe navigation. + await new Promise(resolve => { + iframe.onload = resolve; + iframe.setAttribute("src", url); + }); + } + ); info("Subframe location changed"); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js index f537c2998864..4c9c84d329b1 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js @@ -194,7 +194,9 @@ add_task(async function testInsertCSS_cleanup() { }; const appliedStyles = await SpecialPowers.spawn( - tab.linkedBrowser, [], getTabContentComputedStyle + tab.linkedBrowser, + [], + getTabContentComputedStyle ); is( @@ -211,7 +213,9 @@ add_task(async function testInsertCSS_cleanup() { await extension.unload(); const unloadedStyles = await SpecialPowers.spawn( - tab.linkedBrowser, [], getTabContentComputedStyle + tab.linkedBrowser, + [], + getTabContentComputedStyle ); is( diff --git a/browser/components/newtab/test/browser/browser_aboutwelcome.js b/browser/components/newtab/test/browser/browser_aboutwelcome.js index 0567d049e0f6..4bd7a381ee0c 100644 --- a/browser/components/newtab/test/browser/browser_aboutwelcome.js +++ b/browser/components/newtab/test/browser/browser_aboutwelcome.js @@ -39,7 +39,9 @@ async function test_trailhead_branch( let browser = tab.linkedBrowser; await SpecialPowers.spawn( - browser, [{ expectedSelectors, branchName, unexpectedSelectors }], async ({ + browser, + [{ expectedSelectors, branchName, unexpectedSelectors }], + async ({ expectedSelectors: expected, branchName: branch, unexpectedSelectors: unexpected, diff --git a/browser/components/newtab/test/browser/browser_as_load_location.js b/browser/components/newtab/test/browser/browser_as_load_location.js index 6e380598cf19..e31870e88475 100644 --- a/browser/components/newtab/test/browser/browser_as_load_location.js +++ b/browser/components/newtab/test/browser/browser_as_load_location.js @@ -16,7 +16,9 @@ async function checkNewtabLoads(selector, message) { // check what the content task thinks has been loaded. let found = await SpecialPowers.spawn( - browser, [selector], arg => content.document.querySelector(arg) !== null + browser, + [selector], + arg => content.document.querySelector(arg) !== null ); ok(found, message); diff --git a/browser/components/newtab/test/browser/head.js b/browser/components/newtab/test/browser/head.js index 9927eb372b9e..6f1299f0b1e2 100644 --- a/browser/components/newtab/test/browser/head.js +++ b/browser/components/newtab/test/browser/head.js @@ -48,7 +48,9 @@ async function clearHistoryAndBookmarks() { */ async function waitForPreloaded(browser) { let readyState = await SpecialPowers.spawn( - browser, [], () => content.document.readyState + browser, + [], + () => content.document.readyState ); if (readyState !== "complete") { await BrowserTestUtils.browserLoaded(browser); @@ -178,7 +180,9 @@ function test_newtab(testInfo) { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => content.document.getElementById("root").children.length + browser, + [], + () => content.document.getElementById("root").children.length ), "Should render activity stream content" ); @@ -187,7 +191,9 @@ function test_newtab(testInfo) { try { let contentArg = await before({ pushPrefs: scopedPushPrefs, tab }); let contentResult = await SpecialPowers.spawn( - browser, [contentArg], contentTask + browser, + [contentArg], + contentTask ); await after(contentResult); } finally { diff --git a/browser/components/payments/test/browser/browser_address_edit.js b/browser/components/payments/test/browser/browser_address_edit.js index ee3100b213e5..08d9eb40df96 100644 --- a/browser/components/payments/test/browser/browser_address_edit.js +++ b/browser/components/payments/test/browser/browser_address_edit.js @@ -78,9 +78,13 @@ add_task(async function test_add_link() { for (let options of testOptions) { let shippingAddressChangePromise = SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await manuallyAddShippingAddress(frame, newAddress, options); @@ -147,9 +151,13 @@ add_task(async function test_edit_link() { }); let shippingAddressChangePromise = SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); const EXPECTED_ADDRESS = { @@ -788,9 +796,13 @@ add_task(async function test_private_persist_addresses() { info("awaiting the shippingaddresschange event"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await spawnPaymentDialogTask( @@ -854,7 +866,9 @@ add_task(async function test_private_persist_addresses() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); // Verify response has the expected properties diff --git a/browser/components/payments/test/browser/browser_address_edit_hidden_fields.js b/browser/components/payments/test/browser/browser_address_edit_hidden_fields.js index 4fc6d4c09084..859bde1b108a 100644 --- a/browser/components/payments/test/browser/browser_address_edit_hidden_fields.js +++ b/browser/components/payments/test/browser/browser_address_edit_hidden_fields.js @@ -49,9 +49,13 @@ add_task(async function test_hiddenFieldNotSaved() { newAddress["given-name"] = "hiddenFields"; let shippingAddressChangePromise = SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); let options = { @@ -138,9 +142,13 @@ add_task(async function test_hiddenFieldRemovedWhenCountryChanged() { }); let shippingAddressChangePromise = SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await spawnPaymentDialogTask(frame, async args => { diff --git a/browser/components/payments/test/browser/browser_card_edit.js b/browser/components/payments/test/browser/browser_card_edit.js index f5f45e963abc..2afa8add6ec8 100644 --- a/browser/components/payments/test/browser/browser_card_edit.js +++ b/browser/components/payments/test/browser/browser_card_edit.js @@ -345,9 +345,13 @@ async function add_link(aOptions = {}) { ); SpecialPowers.spawn( - browser, [{ - eventName: "paymentmethodchange", - }], PTU.ContentTasks.promisePaymentRequestEvent + browser, + [ + { + eventName: "paymentmethodchange", + }, + ], + PTU.ContentTasks.promisePaymentRequestEvent ); info("added paymentmethodchange handler"); @@ -358,9 +362,13 @@ async function add_link(aOptions = {}) { info("waiting for paymentmethodchange event"); await SpecialPowers.spawn( - browser, [{ - eventName: "paymentmethodchange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "paymentmethodchange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await spawnPaymentDialogTask(frame, async function waitForSummaryPage( @@ -467,7 +475,9 @@ async function add_link(aOptions = {}) { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); // Verify response has the expected properties diff --git a/browser/components/payments/test/browser/browser_change_shipping.js b/browser/components/payments/test/browser/browser_change_shipping.js index 2a2112053cec..ec6a389fe71a 100644 --- a/browser/components/payments/test/browser/browser_change_shipping.js +++ b/browser/components/payments/test/browser/browser_change_shipping.js @@ -98,10 +98,14 @@ add_task(async function test_change_shipping() { PTU.Details.additionalDisplayItemsEUR ); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: paymentDetails, - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingaddresschange", + details: paymentDetails, + }, + ], + PTU.ContentTasks.updateWith ); info("added shipping change handler to change to EUR"); @@ -109,9 +113,13 @@ add_task(async function test_change_shipping() { info("changed shipping address to DE country"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); info("got shippingaddresschange event"); @@ -198,7 +206,9 @@ add_task(async function test_change_shipping() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); is(result.response.methodName, "basic-card", "Check methodName"); @@ -279,13 +289,17 @@ add_task(async function test_default_shippingOptions_noneSelected() { ); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: Object.assign( - shippingOptionDetailsEUR, - PTU.Details.total1pt75EUR - ), - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingaddresschange", + details: Object.assign( + shippingOptionDetailsEUR, + PTU.Details.total1pt75EUR + ), + }, + ], + PTU.ContentTasks.updateWith ); info("added shipping change handler to change to EUR"); @@ -293,9 +307,13 @@ add_task(async function test_default_shippingOptions_noneSelected() { info("changed shipping address to DE country"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); info("got shippingaddresschange event"); @@ -378,13 +396,17 @@ add_task(async function test_default_shippingOptions_allSelected() { }); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: Object.assign( - shippingOptionDetailsEUR, - PTU.Details.total1pt75EUR - ), - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingaddresschange", + details: Object.assign( + shippingOptionDetailsEUR, + PTU.Details.total1pt75EUR + ), + }, + ], + PTU.ContentTasks.updateWith ); info("added shipping change handler to change to EUR"); @@ -392,9 +414,13 @@ add_task(async function test_default_shippingOptions_allSelected() { info("changed shipping address to DE country"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); info("got shippingaddresschange event"); @@ -465,9 +491,13 @@ add_task(async function test_no_shippingchange_without_shipping() { ); SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.ensureNoPaymentRequestEvent + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.ensureNoPaymentRequestEvent ); info("added shipping change handler"); @@ -485,7 +515,9 @@ add_task(async function test_no_shippingchange_without_shipping() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); is(result.response.methodName, "basic-card", "Check methodName"); @@ -540,18 +572,26 @@ add_task(async function test_address_edit() { is(selectedIndex, -1, "No address should be selected initially"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.promisePaymentRequestEvent + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.promisePaymentRequestEvent ); info("selecting the US address"); await selectPaymentDialogShippingAddressByCountry(frame, "US"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); addressOptions = await spawnPaymentDialogTask( @@ -657,9 +697,13 @@ add_task(async function test_address_removal() { await formAutofillStorage.addresses.remove(selectedAddressGuid); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.promisePaymentRequestEvent + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.promisePaymentRequestEvent ); addressOptions = await spawnPaymentDialogTask( diff --git a/browser/components/payments/test/browser/browser_payment_completion.js b/browser/components/payments/test/browser/browser_payment_completion.js index fd54306cfc60..66807d65e6fb 100644 --- a/browser/components/payments/test/browser/browser_payment_completion.js +++ b/browser/components/payments/test/browser/browser_payment_completion.js @@ -59,7 +59,9 @@ add_task(async function test_complete_success() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let { completeException } = await SpecialPowers.spawn( - browser, [{ result: "success" }], PTU.ContentTasks.addCompletionHandler + browser, + [{ result: "success" }], + PTU.ContentTasks.addCompletionHandler ); ok( @@ -120,7 +122,9 @@ add_task(async function test_complete_fail() { info("acknowledging the completion from the merchant page"); let { completeException } = await SpecialPowers.spawn( - browser, [{ result: "fail" }], PTU.ContentTasks.addCompletionHandler + browser, + [{ result: "fail" }], + PTU.ContentTasks.addCompletionHandler ); ok( !completeException, @@ -186,7 +190,9 @@ add_task(async function test_complete_timeout() { info("acknowledging the completion from the merchant page after a delay"); let { completeException } = await SpecialPowers.spawn( - browser, [{ result: "fail", delayMs: 1000 }], PTU.ContentTasks.addCompletionHandler + browser, + [{ result: "fail", delayMs: 1000 }], + PTU.ContentTasks.addCompletionHandler ); ok( completeException, diff --git a/browser/components/payments/test/browser/browser_retry.js b/browser/components/payments/test/browser/browser_retry.js index 219f22988cdf..6998bac874fd 100644 --- a/browser/components/payments/test/browser/browser_retry.js +++ b/browser/components/payments/test/browser/browser_retry.js @@ -116,12 +116,16 @@ add_task(async function test_retry_with_genericError() { // Add a handler to retry the payment above. info("Tell merchant page to retry with an error string"); let retryPromise = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - error: "My generic error", + browser, + [ + { + delayMs: 1000, + validationErrors: { + error: "My generic error", + }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await retryUpdatePromise; @@ -137,7 +141,9 @@ add_task(async function test_retry_with_genericError() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); // Verify response has the expected properties diff --git a/browser/components/payments/test/browser/browser_retry_fieldErrors.js b/browser/components/payments/test/browser/browser_retry_fieldErrors.js index 83afdb72c48e..12bbee2c1d95 100644 --- a/browser/components/payments/test/browser/browser_retry_fieldErrors.js +++ b/browser/components/payments/test/browser/browser_retry_fieldErrors.js @@ -147,14 +147,18 @@ add_task(async function test_retry_with_shippingAddressErrors() { // Add a handler to retry the payment above. info("Tell merchant page to retry with a country error string"); let retryPromise = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - shippingAddress: { - country: "Can only ship to USA", + browser, + [ + { + delayMs: 1000, + validationErrors: { + shippingAddress: { + country: "Can only ship to USA", + }, }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await retryUpdatePromise; @@ -164,14 +168,18 @@ add_task(async function test_retry_with_shippingAddressErrors() { info("Tell merchant page to retry with a regionCode error string"); let retryPromise2 = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - shippingAddress: { - regionCode: "Can only ship to California", + browser, + [ + { + delayMs: 1000, + validationErrors: { + shippingAddress: { + regionCode: "Can only ship to California", + }, }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await loginAndCompletePayment(frame); @@ -238,7 +246,9 @@ add_task(async function test_retry_with_shippingAddressErrors() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); // Verify response has the expected properties @@ -377,14 +387,18 @@ add_task(async function test_retry_with_payerErrors() { // Add a handler to retry the payment above. info("Tell merchant page to retry with a country error string"); let retryPromise = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - payer: { - email: "You must use your employee email address", + browser, + [ + { + delayMs: 1000, + validationErrors: { + payer: { + email: "You must use your employee email address", + }, }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await retryUpdatePromise; @@ -398,14 +412,18 @@ add_task(async function test_retry_with_payerErrors() { info("Tell merchant page to retry with a phone error string"); let retryPromise2 = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - payer: { - phone: "Your phone number isn't valid", + browser, + [ + { + delayMs: 1000, + validationErrors: { + payer: { + phone: "Your phone number isn't valid", + }, }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await loginAndCompletePayment(frame); @@ -458,17 +476,25 @@ add_task(async function test_retry_with_payerErrors() { await fillInPayerAddressForm(frame, { tel: newPhoneNumber }); await SpecialPowers.spawn( - browser, [{ - eventName: "payerdetailchange", - }], PTU.ContentTasks.promisePaymentResponseEvent + browser, + [ + { + eventName: "payerdetailchange", + }, + ], + PTU.ContentTasks.promisePaymentResponseEvent ); await submitAddressForm(frame, null, { isEditing: true }); await SpecialPowers.spawn( - browser, [{ - eventName: "payerdetailchange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "payerdetailchange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await loginAndCompletePayment(frame); @@ -489,7 +515,9 @@ add_task(async function test_retry_with_payerErrors() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); // Verify response has the expected properties @@ -636,14 +664,18 @@ add_task(async function test_retry_with_paymentMethodErrors() { // Add a handler to retry the payment above. info("Tell merchant page to retry with a cardSecurityCode error string"); let retryPromise = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - paymentMethod: { - cardSecurityCode: "Your CVV is incorrect", + browser, + [ + { + delayMs: 1000, + validationErrors: { + paymentMethod: { + cardSecurityCode: "Your CVV is incorrect", + }, }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await retryUpdatePromise; @@ -659,16 +691,20 @@ add_task(async function test_retry_with_paymentMethodErrors() { "Tell merchant page to retry with a billing postalCode error string" ); let retryPromise2 = SpecialPowers.spawn( - browser, [{ - delayMs: 1000, - validationErrors: { - paymentMethod: { - billingAddress: { - postalCode: "Your postal code isn't valid", + browser, + [ + { + delayMs: 1000, + validationErrors: { + paymentMethod: { + billingAddress: { + postalCode: "Your postal code isn't valid", + }, }, }, }, - }], PTU.ContentTasks.addRetryHandler + ], + PTU.ContentTasks.addRetryHandler ); await loginAndCompletePayment(frame); @@ -733,9 +769,13 @@ add_task(async function test_retry_with_paymentMethodErrors() { await fillInBillingAddressForm(frame, { "postal-code": newPostalCode }); await SpecialPowers.spawn( - browser, [{ - eventName: "paymentmethodchange", - }], PTU.ContentTasks.promisePaymentResponseEvent + browser, + [ + { + eventName: "paymentmethodchange", + }, + ], + PTU.ContentTasks.promisePaymentResponseEvent ); await submitAddressForm(frame, null, { @@ -778,9 +818,13 @@ add_task(async function test_retry_with_paymentMethodErrors() { // TODO: Add an `await` here after bug 1477113. SpecialPowers.spawn( - browser, [{ - eventName: "paymentmethodchange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "paymentmethodchange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await loginAndCompletePayment(frame); @@ -801,7 +845,9 @@ add_task(async function test_retry_with_paymentMethodErrors() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); // Verify response has the expected properties diff --git a/browser/components/payments/test/browser/browser_shippingaddresschange_error.js b/browser/components/payments/test/browser/browser_shippingaddresschange_error.js index 3cc0f20157bb..803296eea6cc 100644 --- a/browser/components/payments/test/browser/browser_shippingaddresschange_error.js +++ b/browser/components/payments/test/browser/browser_shippingaddresschange_error.js @@ -24,15 +24,19 @@ add_task(async function test_show_error_on_addresschange() { info("setting up the event handler for shippingoptionchange"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingoptionchange", - details: Object.assign( - {}, - PTU.Details.genericShippingError, - PTU.Details.noShippingOptions, - PTU.Details.total2USD - ), - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingoptionchange", + details: Object.assign( + {}, + PTU.Details.genericShippingError, + PTU.Details.noShippingOptions, + PTU.Details.total2USD + ), + }, + ], + PTU.ContentTasks.updateWith ); await spawnPaymentDialogTask( @@ -43,9 +47,13 @@ add_task(async function test_show_error_on_addresschange() { info("awaiting the shippingoptionchange event"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingoptionchange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingoptionchange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await spawnPaymentDialogTask( @@ -64,24 +72,32 @@ add_task(async function test_show_error_on_addresschange() { info("setting up the event handler for shippingaddresschange"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: Object.assign( - {}, - PTU.Details.noError, - PTU.Details.twoShippingOptions, - PTU.Details.total2USD - ), - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingaddresschange", + details: Object.assign( + {}, + PTU.Details.noError, + PTU.Details.twoShippingOptions, + PTU.Details.total2USD + ), + }, + ], + PTU.ContentTasks.updateWith ); await selectPaymentDialogShippingAddressByCountry(frame, "DE"); info("awaiting the shippingaddresschange event"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await spawnPaymentDialogTask(frame, () => { @@ -121,15 +137,19 @@ add_task(async function test_show_field_specific_error_on_addresschange() { info("setting up the event handler for shippingaddresschange"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: Object.assign( - {}, - PTU.Details.fieldSpecificErrors, - PTU.Details.noShippingOptions, - PTU.Details.total2USD - ), - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingaddresschange", + details: Object.assign( + {}, + PTU.Details.fieldSpecificErrors, + PTU.Details.noShippingOptions, + PTU.Details.total2USD + ), + }, + ], + PTU.ContentTasks.updateWith ); spawnPaymentDialogTask( @@ -140,9 +160,13 @@ add_task(async function test_show_field_specific_error_on_addresschange() { info("awaiting the shippingaddresschange event"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingaddresschange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); await spawnPaymentDialogTask(frame, async () => { @@ -243,19 +267,23 @@ add_task(async function test_show_field_specific_error_on_addresschange() { "setting up the event handler for a 2nd shippingaddresschange with a different error" ); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: Object.assign( - {}, - { - shippingAddressErrors: { - phone: "Invalid phone number", + browser, + [ + { + eventName: "shippingaddresschange", + details: Object.assign( + {}, + { + shippingAddressErrors: { + phone: "Invalid phone number", + }, }, - }, - PTU.Details.noShippingOptions, - PTU.Details.total2USD - ), - }], PTU.ContentTasks.updateWith + PTU.Details.noShippingOptions, + PTU.Details.total2USD + ), + }, + ], + PTU.ContentTasks.updateWith ); await spawnPaymentDialogTask( @@ -317,14 +345,18 @@ add_task(async function test_show_field_specific_error_on_addresschange() { info("setup updateWith to clear errors"); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingaddresschange", - details: Object.assign( - {}, - PTU.Details.twoShippingOptions, - PTU.Details.total2USD - ), - }], PTU.ContentTasks.updateWith + browser, + [ + { + eventName: "shippingaddresschange", + details: Object.assign( + {}, + PTU.Details.twoShippingOptions, + PTU.Details.total2USD + ), + }, + ], + PTU.ContentTasks.updateWith ); await spawnPaymentDialogTask( diff --git a/browser/components/payments/test/browser/browser_show_dialog.js b/browser/components/payments/test/browser/browser_show_dialog.js index 0eea603bfb99..f3492cfdd945 100644 --- a/browser/components/payments/test/browser/browser_show_dialog.js +++ b/browser/components/payments/test/browser/browser_show_dialog.js @@ -117,7 +117,9 @@ add_task(async function test_show_completePayment() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); let { shippingAddress } = result.response; @@ -177,9 +179,13 @@ add_task(async function test_show_completePayment2() { }); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingoptionchange", - }], PTU.ContentTasks.promisePaymentRequestEvent + browser, + [ + { + eventName: "shippingoptionchange", + }, + ], + PTU.ContentTasks.promisePaymentRequestEvent ); info( @@ -192,9 +198,13 @@ add_task(async function test_show_completePayment2() { ); await SpecialPowers.spawn( - browser, [{ - eventName: "shippingoptionchange", - }], PTU.ContentTasks.awaitPaymentEventPromise + browser, + [ + { + eventName: "shippingoptionchange", + }, + ], + PTU.ContentTasks.awaitPaymentEventPromise ); info("got shippingoptionchange event"); @@ -226,7 +236,9 @@ add_task(async function test_show_completePayment2() { // Add a handler to complete the payment above. info("acknowledging the completion from the merchant page"); let result = await SpecialPowers.spawn( - browser, [], PTU.ContentTasks.addCompletionHandler + browser, + [], + PTU.ContentTasks.addCompletionHandler ); is(result.response.shippingOption, "1", "Check shipping option"); diff --git a/browser/components/payments/test/browser/head.js b/browser/components/payments/test/browser/head.js index c4eff942e52a..f9e074506495 100644 --- a/browser/components/payments/test/browser/head.js +++ b/browser/components/payments/test/browser/head.js @@ -317,11 +317,15 @@ async function setupPaymentDialog( ) { let dialogReadyPromise = waitForWidgetReady(); let { requestId } = await SpecialPowers.spawn( - browser, [{ - methodData, - details, - options, - }], merchantTaskFn + browser, + [ + { + methodData, + details, + options, + }, + ], + merchantTaskFn ); ok(requestId, "requestId should be defined"); diff --git a/browser/components/preferences/in-content/tests/browser_hometab_restore_defaults.js b/browser/components/preferences/in-content/tests/browser_hometab_restore_defaults.js index 357dc06c7728..898625767803 100644 --- a/browser/components/preferences/in-content/tests/browser_hometab_restore_defaults.js +++ b/browser/components/preferences/in-content/tests/browser_hometab_restore_defaults.js @@ -26,7 +26,9 @@ add_task(async function testRestoreDefaultsBtn_visible() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.getElementById("restoreDefaultHomePageBtn") !== null ), "Wait for the button to be added to the page" @@ -35,7 +37,9 @@ add_task(async function testRestoreDefaultsBtn_visible() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.querySelector( "[data-subcategory='topsites'] checkbox" ) !== null @@ -46,7 +50,9 @@ add_task(async function testRestoreDefaultsBtn_visible() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.getElementById("restoreDefaultHomePageBtn") .hidden === false ), @@ -60,7 +66,9 @@ add_task(async function testRestoreDefaultsBtn_visible() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.querySelector( "[data-subcategory='topsites'] checkbox" ).checked @@ -71,7 +79,9 @@ add_task(async function testRestoreDefaultsBtn_visible() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.getElementById("restoreDefaultHomePageBtn").style .visibility === "hidden" ), @@ -113,7 +123,9 @@ add_task(async function testRestoreDefaultsBtn_hidden() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.getElementById("restoreDefaultHomePageBtn") !== null ), "Wait for the button to be added to the page" @@ -122,7 +134,9 @@ add_task(async function testRestoreDefaultsBtn_hidden() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.querySelector( "[data-subcategory='topsites'] checkbox" ) !== null @@ -131,7 +145,9 @@ add_task(async function testRestoreDefaultsBtn_hidden() { ); const btnDefault = await SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.getElementById("restoreDefaultHomePageBtn").style .visibility ); @@ -144,7 +160,9 @@ add_task(async function testRestoreDefaultsBtn_hidden() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.querySelector( "[data-subcategory='topsites'] checkbox" ).checked @@ -162,7 +180,9 @@ add_task(async function testRestoreDefaultsBtn_hidden() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => !content.document.querySelector( "[data-subcategory='topsites'] checkbox" ).checked @@ -173,7 +193,9 @@ add_task(async function testRestoreDefaultsBtn_hidden() { await BrowserTestUtils.waitForCondition( () => SpecialPowers.spawn( - browser, [], () => + browser, + [], + () => content.document.getElementById("restoreDefaultHomePageBtn").style .visibility === "visible" ), diff --git a/browser/components/preferences/in-content/tests/browser_subdialogs.js b/browser/components/preferences/in-content/tests/browser_subdialogs.js index ead7f7299f86..a780c1d9cea5 100644 --- a/browser/components/preferences/in-content/tests/browser_subdialogs.js +++ b/browser/components/preferences/in-content/tests/browser_subdialogs.js @@ -19,7 +19,9 @@ function open_subdialog_and_test_generic_start_state( ? "(" + domcontentloadedFn.toString() + ")()" : ""; return SpecialPowers.spawn( - browser, [{ url, domcontentloadedFnStr }], async function(args) { + browser, + [{ url, domcontentloadedFnStr }], + async function(args) { let rv = { acceptCount: 0 }; let win = content.window; content.gSubDialog.open(args.url, null, rv); @@ -100,16 +102,22 @@ async function close_subdialog_and_test_generic_end_state( ) { let getDialogsCount = () => { return SpecialPowers.spawn( - browser, [], () => content.window.gSubDialog._dialogs.length + browser, + [], + () => content.window.gSubDialog._dialogs.length ); }; let getStackChildrenCount = () => { return SpecialPowers.spawn( - browser, [], () => content.window.gSubDialog._dialogStack.children.length + browser, + [], + () => content.window.gSubDialog._dialogStack.children.length ); }; let dialogclosingPromise = SpecialPowers.spawn( - browser, [{ closingButton, acceptCount }], async function(expectations) { + browser, + [{ closingButton, acceptCount }], + async function(expectations) { let win = content.window; let subdialog = win.gSubDialog._topDialog; let frame = subdialog._frame; diff --git a/browser/components/preferences/in-content/tests/siteData/browser_clearSiteData.js b/browser/components/preferences/in-content/tests/siteData/browser_clearSiteData.js index db32fc52b8f0..5555d19f2635 100644 --- a/browser/components/preferences/in-content/tests/siteData/browser_clearSiteData.js +++ b/browser/components/preferences/in-content/tests/siteData/browser_clearSiteData.js @@ -52,7 +52,9 @@ async function testClearData(clearSiteData, clearCache) { Assert.greater(totalUsage, 0, "The total usage should not be 0"); let initialSizeLabelValue = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { let sizeLabel = content.document.getElementById("totalSiteDataSize"); return sizeLabel.textContent; } @@ -170,7 +172,9 @@ async function testClearData(clearSiteData, clearCache) { if (clearCache || clearSiteData) { // Check that the size label in about:preferences updates after we cleared data. await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ initialSizeLabelValue }], async function(opts) { + gBrowser.selectedBrowser, + [{ initialSizeLabelValue }], + async function(opts) { let sizeLabel = content.document.getElementById("totalSiteDataSize"); await ContentTaskUtils.waitForCondition( () => sizeLabel.textContent != opts.initialSizeLabelValue, diff --git a/browser/components/preferences/in-content/tests/siteData/browser_siteData.js b/browser/components/preferences/in-content/tests/siteData/browser_siteData.js index d7f740b85370..932b2239c72e 100644 --- a/browser/components/preferences/in-content/tests/siteData/browser_siteData.js +++ b/browser/components/preferences/in-content/tests/siteData/browser_siteData.js @@ -164,21 +164,25 @@ add_task(async function() { await openSiteDataSettingsDialog(); let acceptRemovePromise = BrowserTestUtils.promiseAlertDialogOpen("accept"); let updatePromise = promiseSiteDataManagerSitesUpdated(); - SpecialPowers.spawn(gBrowser.selectedBrowser, [{ TEST_OFFLINE_HOST }], args => { - let host = args.TEST_OFFLINE_HOST; - let frameDoc = content.gSubDialog._topDialog._frame.contentDocument; - let sitesList = frameDoc.getElementById("sitesList"); - let site = sitesList.querySelector(`richlistitem[host="${host}"]`); - if (site) { - let removeBtn = frameDoc.getElementById("removeSelected"); - let saveBtn = frameDoc.getElementById("save"); - site.click(); - removeBtn.doCommand(); - saveBtn.doCommand(); - } else { - ok(false, `Should have one site of ${host}`); + SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ TEST_OFFLINE_HOST }], + args => { + let host = args.TEST_OFFLINE_HOST; + let frameDoc = content.gSubDialog._topDialog._frame.contentDocument; + let sitesList = frameDoc.getElementById("sitesList"); + let site = sitesList.querySelector(`richlistitem[host="${host}"]`); + if (site) { + let removeBtn = frameDoc.getElementById("removeSelected"); + let saveBtn = frameDoc.getElementById("save"); + site.click(); + removeBtn.doCommand(); + saveBtn.doCommand(); + } else { + ok(false, `Should have one site of ${host}`); + } } - }); + ); await acceptRemovePromise; await updatePromise; await promiseServiceWorkersCleared(); @@ -268,10 +272,14 @@ add_task(async function() { REMOVE_DIALOG_URL ); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ - creationDate1Formatted, - creationDate2Formatted, - }], function(args) { + gBrowser.selectedBrowser, + [ + { + creationDate1Formatted, + creationDate2Formatted, + }, + ], + function(args) { let frameDoc = content.gSubDialog._topDialog._frame.contentDocument; let siteItems = frameDoc.getElementsByTagName("richlistitem"); @@ -335,7 +343,9 @@ add_task(async function() { await openSiteDataSettingsDialog(); let acceptRemovePromise = BrowserTestUtils.promiseAlertDialogOpen("accept"); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ creationDate1Formatted }], function(args) { + gBrowser.selectedBrowser, + [{ creationDate1Formatted }], + function(args) { let frameDoc = content.gSubDialog._topDialog._frame.contentDocument; let siteItems = frameDoc.getElementsByTagName("richlistitem"); diff --git a/browser/components/preferences/in-content/tests/siteData/head.js b/browser/components/preferences/in-content/tests/siteData/head.js index 2b488f056689..51eeca25a3e2 100644 --- a/browser/components/preferences/in-content/tests/siteData/head.js +++ b/browser/components/preferences/in-content/tests/siteData/head.js @@ -248,7 +248,9 @@ async function loadServiceWorkerTestPage(url) { let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); await BrowserTestUtils.waitForCondition(() => { return SpecialPowers.spawn( - tab.linkedBrowser, [], () => + tab.linkedBrowser, + [], + () => content.document.body.getAttribute( "data-test-service-worker-registered" ) === "true" diff --git a/browser/components/privatebrowsing/test/browser/browser_oa_private_browsing_window.js b/browser/components/privatebrowsing/test/browser/browser_oa_private_browsing_window.js index 18432ab07972..ea3b337e5889 100644 --- a/browser/components/privatebrowsing/test/browser/browser_oa_private_browsing_window.js +++ b/browser/components/privatebrowsing/test/browser/browser_oa_private_browsing_window.js @@ -27,7 +27,11 @@ add_task( ); let privateWin = await promiseNewWindow; - await SpecialPowers.spawn(privateWin.gBrowser.selectedBrowser, [{DUMMY_PAGE, TEST_PAGE}], async function({DUMMY_PAGE, TEST_PAGE}) { // eslint-disable-line + await SpecialPowers.spawn( + privateWin.gBrowser.selectedBrowser, + [{ DUMMY_PAGE, TEST_PAGE }], + async function({ DUMMY_PAGE, TEST_PAGE }) { + // eslint-disable-line let channel = content.docShell.currentDocumentChannel; is( diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js index 4599eda36dad..838c199acdae 100644 --- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_context_and_chromeFlags.js @@ -31,7 +31,9 @@ function assertWindowIsPrivate(win) { ); return SpecialPowers.spawn( - win.gBrowser.selectedBrowser, [], async function() { + win.gBrowser.selectedBrowser, + [], + async function() { let contentLoadContext = docShell.QueryInterface(Ci.nsILoadContext); Assert.ok( contentLoadContext.usePrivateBrowsing, diff --git a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js index f57c2c598362..522a2cc3b1e5 100644 --- a/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js +++ b/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_favicon.js @@ -176,7 +176,9 @@ function waitOnFaviconLoaded(aFaviconURL) { async function assignCookies(aBrowser, aURL, aCookieValue) { let tabInfo = await openTab(aBrowser, aURL); - await SpecialPowers.spawn(tabInfo.browser, [aCookieValue], async function(value) { + await SpecialPowers.spawn(tabInfo.browser, [aCookieValue], async function( + value + ) { content.document.cookie = value; }); diff --git a/browser/components/protections/test/browser/browser_protections_proxy.js b/browser/components/protections/test/browser/browser_protections_proxy.js index 304cc8699a0b..4b16937a30c3 100644 --- a/browser/components/protections/test/browser/browser_protections_proxy.js +++ b/browser/components/protections/test/browser/browser_protections_proxy.js @@ -87,7 +87,9 @@ add_task(async function() { async function checkProxyCardVisibility(tab, shouldBeHidden) { await SpecialPowers.spawn( - tab.linkedBrowser, [{ _shouldBeHidden: shouldBeHidden }], async function({ _shouldBeHidden }) { + tab.linkedBrowser, + [{ _shouldBeHidden: shouldBeHidden }], + async function({ _shouldBeHidden }) { await ContentTaskUtils.waitForCondition(() => { const proxyCard = content.document.querySelector(".proxy-card"); return ContentTaskUtils.is_hidden(proxyCard) === _shouldBeHidden; diff --git a/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js b/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js index 07c33dedea8f..dc5a2e67dc20 100644 --- a/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js +++ b/browser/components/resistfingerprinting/test/browser/browser_dynamical_window_rounding.js @@ -189,7 +189,9 @@ async function test_dynamical_window_rounding(aWindow, aCheckFunc) { info(caseString + "Get innerWidth/Height from the content."); await BrowserTestUtils.waitForCondition(async () => { let { contentWidth, contentHeight } = await SpecialPowers.spawn( - tab.linkedBrowser, [], () => { + tab.linkedBrowser, + [], + () => { return { contentWidth: content.innerWidth, contentHeight: content.innerHeight, diff --git a/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js b/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js index b008de280764..ecae695f769f 100644 --- a/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js +++ b/browser/components/resistfingerprinting/test/browser/browser_performanceAPI.js @@ -101,12 +101,16 @@ let setupTest = async function( expectedPrecision = expectedPrecision < 100 ? 100 : expectedPrecision; } await SpecialPowers.spawn( - tab.linkedBrowser, [{ - list: PERFORMANCE_TIMINGS, - precision: expectedPrecision, - isRoundedFunc: isRounded.toString(), - workerCall, - }], runTests + tab.linkedBrowser, + [ + { + list: PERFORMANCE_TIMINGS, + precision: expectedPrecision, + isRoundedFunc: isRounded.toString(), + workerCall, + }, + ], + runTests ); }; // ================================================================================================ diff --git a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js index 50c7ba8002d5..71a811bdcb63 100644 --- a/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js +++ b/browser/components/resistfingerprinting/test/browser/browser_roundedWindow_newWindow.js @@ -35,7 +35,9 @@ add_task(async function test_new_window() { ); await SpecialPowers.spawn( - tab.linkedBrowser, [{ gMaxAvailWidth, gMaxAvailHeight }], async function(input) { + tab.linkedBrowser, + [{ gMaxAvailWidth, gMaxAvailHeight }], + async function(input) { is( content.screen.width, input.gMaxAvailWidth, diff --git a/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js b/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js index 932b2fae156f..0209381f4643 100644 --- a/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js +++ b/browser/components/resistfingerprinting/test/browser/browser_spoofing_keyboard_event.js @@ -1987,7 +1987,9 @@ async function testKeyEvent(aTab, aTestCase) { for (let testEvent of testEvents) { let keyEventPromise = SpecialPowers.spawn( - aTab.linkedBrowser, [{ testEvent, result: aTestCase.result, kSameKeyCodeAndCharCodeValue }], async aInput => { + aTab.linkedBrowser, + [{ testEvent, result: aTestCase.result, kSameKeyCodeAndCharCodeValue }], + async aInput => { function verifyKeyboardEvent( aEvent, aResult, @@ -2216,7 +2218,9 @@ add_task(async function runTestForSuppressModifierKeys() { for (let eventType of ["keydown", "keyup"]) { for (let modifierKey of ["Alt", "Shift", "Control"]) { let testPromise = SpecialPowers.spawn( - tab.linkedBrowser, [eventType], async aEventType => { + tab.linkedBrowser, + [eventType], + async aEventType => { let inputBox = content.document.getElementById("test"); // First, try to focus on the input box. diff --git a/browser/components/resistfingerprinting/test/browser/head.js b/browser/components/resistfingerprinting/test/browser/head.js index 324db989b885..edd244827852 100644 --- a/browser/components/resistfingerprinting/test/browser/head.js +++ b/browser/components/resistfingerprinting/test/browser/head.js @@ -23,7 +23,9 @@ async function calcMaximumAvailSize(aChromeWidth, aChromeHeight) { ); let contentSize = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { let result = { width: content.innerWidth, height: content.innerHeight, @@ -81,7 +83,9 @@ async function calcPopUpWindowChromeUISize() { ); let result = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { let win; await new Promise(resolve => { diff --git a/browser/components/search/test/browser/browser_contentContextMenu.js b/browser/components/search/test/browser/browser_contentContextMenu.js index bd3fd82c7eac..38c60e22deb1 100644 --- a/browser/components/search/test/browser/browser_contentContextMenu.js +++ b/browser/components/search/test/browser/browser_contentContextMenu.js @@ -142,7 +142,9 @@ add_task(async function() { } await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ selectElement: test.isSelected ? test.id : null }], async function(arg) { + gBrowser.selectedBrowser, + [{ selectElement: test.isSelected ? test.id : null }], + async function(arg) { let selection = content.getSelection(); selection.removeAllRanges(); diff --git a/browser/components/sessionstore/test/browser_491168.js b/browser/components/sessionstore/test/browser_491168.js index b5b23779083f..09c45faa8e25 100644 --- a/browser/components/sessionstore/test/browser_491168.js +++ b/browser/components/sessionstore/test/browser_491168.js @@ -7,7 +7,9 @@ const REFERRER3 = "http://example.org/?" + Math.random(); add_task(async function() { async function checkDocumentReferrer(referrer, msg) { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ referrer, msg }], async function(args) { + gBrowser.selectedBrowser, + [{ referrer, msg }], + async function(args) { Assert.equal(content.document.referrer, args.referrer, args.msg); } ); diff --git a/browser/components/sessionstore/test/browser_911547.js b/browser/components/sessionstore/test/browser_911547.js index 4eb2ca9375d6..046ddbece82c 100644 --- a/browser/components/sessionstore/test/browser_911547.js +++ b/browser/components/sessionstore/test/browser_911547.js @@ -38,7 +38,8 @@ add_task(async function test() { await loadedPromise; - await SpecialPowers.spawn(browser, [], function( {}) { // eslint-disable-line + await SpecialPowers.spawn(browser, [], function({}) { + // eslint-disable-line // the data: URI inherits the CSP and the inline script needs to be blocked is( content.document.getElementById("test_id2").value, @@ -55,7 +56,8 @@ add_task(async function test() { await promiseTabRestored(tab); browser = tab.linkedBrowser; - await SpecialPowers.spawn(browser, [], function({}) { // eslint-disable-line + await SpecialPowers.spawn(browser, [], function({}) { + // eslint-disable-line // the data: URI should be restored including the inherited CSP and the // inline script should be blocked. is( diff --git a/browser/components/sessionstore/test/browser_async_duplicate_tab.js b/browser/components/sessionstore/test/browser_async_duplicate_tab.js index 9cb42379e22e..2a16a1612417 100644 --- a/browser/components/sessionstore/test/browser_async_duplicate_tab.js +++ b/browser/components/sessionstore/test/browser_async_duplicate_tab.js @@ -18,10 +18,16 @@ add_task(async function test_duplicate() { // Click the link to navigate, this will add second shistory entry. await SpecialPowers.spawn(browser, [], async function() { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("hashchange", function onHashChange() { - docShell.chromeEventHandler.removeEventListener("hashchange", onHashChange); - resolve(); - }); + docShell.chromeEventHandler.addEventListener( + "hashchange", + function onHashChange() { + docShell.chromeEventHandler.removeEventListener( + "hashchange", + onHashChange + ); + resolve(); + } + ); // Click the link. content.document.querySelector("a").click(); @@ -56,10 +62,16 @@ add_task(async function test_duplicate_remove() { // Click the link to navigate, this will add second shistory entry. await SpecialPowers.spawn(browser, [], async function() { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("hashchange", function onHashChange() { - docShell.chromeEventHandler.removeEventListener("hashchange", onHashChange); - resolve(); - }); + docShell.chromeEventHandler.addEventListener( + "hashchange", + function onHashChange() { + docShell.chromeEventHandler.removeEventListener( + "hashchange", + onHashChange + ); + resolve(); + } + ); // Click the link. content.document.querySelector("a").click(); diff --git a/browser/components/sessionstore/test/browser_async_flushes.js b/browser/components/sessionstore/test/browser_async_flushes.js index 40b6812f705d..86212907685a 100644 --- a/browser/components/sessionstore/test/browser_async_flushes.js +++ b/browser/components/sessionstore/test/browser_async_flushes.js @@ -22,10 +22,16 @@ add_task(async function test_flush() { // Click the link to navigate, this will add second shistory entry. await SpecialPowers.spawn(browser, [], async function() { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("hashchange", function onHashChange() { - docShell.chromeEventHandler.removeEventListener("hashchange", onHashChange); - resolve(); - }); + docShell.chromeEventHandler.addEventListener( + "hashchange", + function onHashChange() { + docShell.chromeEventHandler.removeEventListener( + "hashchange", + onHashChange + ); + resolve(); + } + ); // Click the link. content.document.querySelector("a").click(); @@ -60,10 +66,16 @@ add_task(async function test_crash() { // Click the link to navigate. await SpecialPowers.spawn(browser, [], async function() { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("hashchange", function onHashChange() { - docShell.chromeEventHandler.removeEventListener("hashchange", onHashChange); - resolve(); - }); + docShell.chromeEventHandler.addEventListener( + "hashchange", + function onHashChange() { + docShell.chromeEventHandler.removeEventListener( + "hashchange", + onHashChange + ); + resolve(); + } + ); // Click the link. content.document.querySelector("a").click(); @@ -102,10 +114,16 @@ add_task(async function test_remove() { // Click the link to navigate. await SpecialPowers.spawn(browser, [], async function() { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("hashchange", function onHashChange() { - docShell.chromeEventHandler.removeEventListener("hashchange", onHashChange); - resolve(); - }); + docShell.chromeEventHandler.addEventListener( + "hashchange", + function onHashChange() { + docShell.chromeEventHandler.removeEventListener( + "hashchange", + onHashChange + ); + resolve(); + } + ); // Click the link. content.document.querySelector("a").click(); diff --git a/browser/components/sessionstore/test/browser_cookies.js b/browser/components/sessionstore/test/browser_cookies.js index 39f703bae9bb..f514efc777e0 100644 --- a/browser/components/sessionstore/test/browser_cookies.js +++ b/browser/components/sessionstore/test/browser_cookies.js @@ -5,7 +5,9 @@ function promiseSetCookie(cookie) { return Promise.all([ waitForCookieChanged(), SpecialPowers.spawn( - gBrowser.selectedBrowser, [cookie], passedCookie => (content.document.cookie = passedCookie) + gBrowser.selectedBrowser, + [cookie], + passedCookie => (content.document.cookie = passedCookie) ), ]); } diff --git a/browser/components/sessionstore/test/browser_page_title.js b/browser/components/sessionstore/test/browser_page_title.js index 385bcf115921..606efa1ce2c6 100644 --- a/browser/components/sessionstore/test/browser_page_title.js +++ b/browser/components/sessionstore/test/browser_page_title.js @@ -31,10 +31,16 @@ add_task(async function() { // Set a new title. await SpecialPowers.spawn(browser, [], async function() { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("DOMTitleChanged", function onTitleChanged() { - docShell.chromeEventHandler.removeEventListener("DOMTitleChanged", onTitleChanged); - resolve(); - }); + docShell.chromeEventHandler.addEventListener( + "DOMTitleChanged", + function onTitleChanged() { + docShell.chromeEventHandler.removeEventListener( + "DOMTitleChanged", + onTitleChanged + ); + resolve(); + } + ); content.document.title = "new title"; }); diff --git a/browser/components/sessionstore/test/browser_sessionStoreContainer.js b/browser/components/sessionstore/test/browser_sessionStoreContainer.js index 98c4907e8337..b10f78cfd6d3 100644 --- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js +++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js @@ -18,7 +18,9 @@ add_task(async function() { let browser2 = tab2.linkedBrowser; await promiseTabRestored(tab2); - await SpecialPowers.spawn(browser2, [{ expectedId: i }], async function(args) { + await SpecialPowers.spawn(browser2, [{ expectedId: i }], async function( + args + ) { let loadContext = docShell.QueryInterface(Ci.nsILoadContext); Assert.equal( loadContext.originAttributes.userContextId, @@ -46,7 +48,9 @@ add_task(async function() { let browser2 = tab2.linkedBrowser; await promiseTabRestored(tab2); - await SpecialPowers.spawn(browser2, [{ expectedId: 1 }], async function(args) { + await SpecialPowers.spawn(browser2, [{ expectedId: 1 }], async function( + args + ) { Assert.equal( docShell.getOriginAttributes().userContextId, args.expectedId, @@ -71,15 +75,17 @@ add_task(async function() { let tab2 = ss.undoCloseTab(window, 0); Assert.equal(tab2.getAttribute("usercontextid"), 1); await promiseTabRestored(tab2); - await SpecialPowers.spawn(tab2.linkedBrowser, [{ expectedId: 1 }], async function( - args - ) { - Assert.equal( - docShell.getOriginAttributes().userContextId, - args.expectedId, - "The docShell has the correct userContextId" - ); - }); + await SpecialPowers.spawn( + tab2.linkedBrowser, + [{ expectedId: 1 }], + async function(args) { + Assert.equal( + docShell.getOriginAttributes().userContextId, + args.expectedId, + "The docShell has the correct userContextId" + ); + } + ); BrowserTestUtils.removeTab(tab2); }); @@ -137,7 +143,9 @@ add_task(async function test() { await Promise.all([ waitForNewCookie(), SpecialPowers.spawn( - browser, [cookie], passedCookie => (content.document.cookie = passedCookie) + browser, + [cookie], + passedCookie => (content.document.cookie = passedCookie) ), ]); diff --git a/browser/components/sessionstore/test/browser_windowStateContainer.js b/browser/components/sessionstore/test/browser_windowStateContainer.js index ab90be871e85..1c339a6e5911 100644 --- a/browser/components/sessionstore/test/browser_windowStateContainer.js +++ b/browser/components/sessionstore/test/browser_windowStateContainer.js @@ -129,7 +129,9 @@ add_task(async function() { for (let i = 0; i < 2; i++) { let browser = win2.gBrowser.tabs[i].linkedBrowser; - await SpecialPowers.spawn(browser, [{ expectedId: i }], async function(args) { + await SpecialPowers.spawn(browser, [{ expectedId: i }], async function( + args + ) { Assert.equal( docShell.getOriginAttributes().userContextId, args.expectedId, diff --git a/browser/components/sessionstore/test/head.js b/browser/components/sessionstore/test/head.js index 0ec25d19b3d5..b0841a4fa8e2 100644 --- a/browser/components/sessionstore/test/head.js +++ b/browser/components/sessionstore/test/head.js @@ -606,7 +606,9 @@ function promiseRemoveTabAndSessionState(tab) { // Write DOMSessionStorage data to the given browser. function modifySessionStorage(browser, storageData, storageOptions = {}) { return SpecialPowers.spawn( - browser, [[storageData, storageOptions]], async function([data, options]) { + browser, + [[storageData, storageOptions]], + async function([data, options]) { let frame = content; if (options && "frameIndex" in options) { frame = content.frames[options.frameIndex]; diff --git a/browser/components/uitour/test/browser_UITour_detach_tab.js b/browser/components/uitour/test/browser_UITour_detach_tab.js index d0ae51dc8a71..458094a2b87f 100644 --- a/browser/components/uitour/test/browser_UITour_detach_tab.js +++ b/browser/components/uitour/test/browser_UITour_detach_tab.js @@ -51,7 +51,9 @@ var tests = [ }, "browser-delayed-startup-finished"); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [myDocIdentifier], contentMyDocIdentifier => { + gBrowser.selectedBrowser, + [myDocIdentifier], + contentMyDocIdentifier => { let onPageShow = () => { if (!content.document.hidden) { let win = Cu.waiveXrays(content); @@ -79,7 +81,9 @@ var tests = [ let selectedTab = gContentWindow.gBrowser.selectedTab; await SpecialPowers.spawn( - selectedTab.linkedBrowser, [myDocIdentifier], contentMyDocIdentifier => { + selectedTab.linkedBrowser, + [myDocIdentifier], + contentMyDocIdentifier => { is( content.document.myExpando, contentMyDocIdentifier, diff --git a/browser/components/uitour/test/browser_backgroundTab.js b/browser/components/uitour/test/browser_backgroundTab.js index c4360f6af90c..6b911f0b0790 100644 --- a/browser/components/uitour/test/browser_backgroundTab.js +++ b/browser/components/uitour/test/browser_backgroundTab.js @@ -35,7 +35,9 @@ async function loadForegroundTab() { // Spawn a content task that resolves once we're sure the visibilityState was // changed. This state is what the tests in this file rely on. let promise = SpecialPowers.spawn( - gBrowser.selectedTab.linkedBrowser, [], async function() { + gBrowser.selectedTab.linkedBrowser, + [], + async function() { return new Promise(resolve => { let document = content.document; document.addEventListener("visibilitychange", function onStateChange() { diff --git a/browser/components/uitour/test/head.js b/browser/components/uitour/test/head.js index 415149cbd81b..cfd3e9477d5b 100644 --- a/browser/components/uitour/test/head.js +++ b/browser/components/uitour/test/head.js @@ -159,7 +159,9 @@ function waitForPopupAtAnchor(popup, anchorNode, nextTestFn, msg) { function getConfigurationPromise(configName) { return SpecialPowers.spawn( - gTestTab.linkedBrowser, [configName], contentConfigName => { + gTestTab.linkedBrowser, + [configName], + contentConfigName => { return new Promise(resolve => { let contentWin = Cu.waiveXrays(content); contentWin.Mozilla.UITour.getConfiguration(contentConfigName, resolve); @@ -333,7 +335,9 @@ function loadUITourTestPage(callback, host = "https://example.org/") { args, }; return SpecialPowers.spawn( - gTestTab.linkedBrowser, [taskArgs], contentArgs => { + gTestTab.linkedBrowser, + [taskArgs], + contentArgs => { let contentWin = Cu.waiveXrays(content); return contentWin[contentArgs.methodName].apply( contentWin, diff --git a/browser/components/urlbar/tests/browser/browser_keyword.js b/browser/components/urlbar/tests/browser/browser_keyword.js index 5692b63ce1c6..90de5765afb9 100644 --- a/browser/components/urlbar/tests/browser/browser_keyword.js +++ b/browser/components/urlbar/tests/browser/browser_keyword.js @@ -188,7 +188,9 @@ add_task(async function test_keyword_using_post() { ); let postData = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { return content.document.body.textContent; } ); diff --git a/browser/components/urlbar/tests/browser/browser_locationBarExternalLoad.js b/browser/components/urlbar/tests/browser/browser_locationBarExternalLoad.js index 5e4f2d423310..1b1da7510d7e 100644 --- a/browser/components/urlbar/tests/browser/browser_locationBarExternalLoad.js +++ b/browser/components/urlbar/tests/browser/browser_locationBarExternalLoad.js @@ -39,10 +39,14 @@ function promiseLoaded(browser) { return SpecialPowers.spawn(browser, [undefined], async () => { if (!["interactive", "complete"].includes(content.document.readyState)) { await new Promise(resolve => - docShell.chromeEventHandler.addEventListener("DOMContentLoaded", resolve, { - once: true, - capture: true, - }) + docShell.chromeEventHandler.addEventListener( + "DOMContentLoaded", + resolve, + { + once: true, + capture: true, + } + ) ); } }); @@ -64,7 +68,9 @@ async function testURL(url, loadFunc, endFunc) { await pageShowPromise; await SpecialPowers.spawn( - browser, [{ isRemote: gMultiProcessBrowser }], async function(arg) { + browser, + [{ isRemote: gMultiProcessBrowser }], + async function(arg) { Assert.equal( Services.focus.focusedElement, null, diff --git a/browser/components/urlbar/tests/browser/browser_switchToTabHavingURI_aOpenParams.js b/browser/components/urlbar/tests/browser/browser_switchToTabHavingURI_aOpenParams.js index ca0c8dd69388..7000d3136256 100644 --- a/browser/components/urlbar/tests/browser/browser_switchToTabHavingURI_aOpenParams.js +++ b/browser/components/urlbar/tests/browser/browser_switchToTabHavingURI_aOpenParams.js @@ -14,7 +14,9 @@ add_task(async function test_ignoreFragment() { switchTab("about:mozilla", true); let hashChangePromise = SpecialPowers.spawn( - tabRefAboutHome.linkedBrowser, [], async function() { + tabRefAboutHome.linkedBrowser, + [], + async function() { await ContentTaskUtils.waitForEvent(this, "hashchange", false); } ); diff --git a/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js b/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js index 1f1f534d5eb2..97e829db62ca 100644 --- a/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js +++ b/browser/extensions/formautofill/test/browser/creditCard/browser_insecure_form.js @@ -95,9 +95,13 @@ add_task(async function test_click_on_insecure_warning() { await EventUtils.synthesizeMouseAtCenter(insecureItem, {}); // Check input's value after popup closed to ensure the completion of autofilling. await expectPopupClose(browser); - const inputValue = await SpecialPowers.spawn(browser, [], async function() { - return content.document.querySelector("#cc-name").value; - }); + const inputValue = await SpecialPowers.spawn( + browser, + [], + async function() { + return content.document.querySelector("#cc-name").value; + } + ); is(inputValue, ""); await closePopup(browser); @@ -115,9 +119,13 @@ add_task(async function test_press_enter_on_insecure_warning() { await BrowserTestUtils.synthesizeKey("VK_RETURN", {}, browser); // Check input's value after popup closed to ensure the completion of autofilling. await expectPopupClose(browser); - const inputValue = await SpecialPowers.spawn(browser, [], async function() { - return content.document.querySelector("#cc-name").value; - }); + const inputValue = await SpecialPowers.spawn( + browser, + [], + async function() { + return content.document.querySelector("#cc-name").value; + } + ); is(inputValue, ""); await closePopup(browser); diff --git a/browser/extensions/formautofill/test/browser/creditCard/browser_privacyPreferences.js b/browser/extensions/formautofill/test/browser/creditCard/browser_privacyPreferences.js index 714e2bb3d67a..6c520dd1ad47 100644 --- a/browser/extensions/formautofill/test/browser/creditCard/browser_privacyPreferences.js +++ b/browser/extensions/formautofill/test/browser/creditCard/browser_privacyPreferences.js @@ -94,20 +94,24 @@ add_task(async function test_openManageAutofillDialogs() { MANAGE_ADDRESSES_DIALOG_URL, MANAGE_CREDIT_CARDS_DIALOG_URL, ]; - await SpecialPowers.spawn(browser, [args], ([selectors, addrUrl, ccUrl]) => { - function testManageDialogOpened(expectedUrl) { - return { - open: openUrl => is(openUrl, expectedUrl, "Manage dialog called"), - }; - } + await SpecialPowers.spawn( + browser, + [args], + ([selectors, addrUrl, ccUrl]) => { + function testManageDialogOpened(expectedUrl) { + return { + open: openUrl => is(openUrl, expectedUrl, "Manage dialog called"), + }; + } - let realgSubDialog = content.window.gSubDialog; - content.window.gSubDialog = testManageDialogOpened(addrUrl); - content.document.querySelector(selectors.savedAddressesBtn).click(); - content.window.gSubDialog = testManageDialogOpened(ccUrl); - content.document.querySelector(selectors.savedCreditCardsBtn).click(); - content.window.gSubDialog = realgSubDialog; - }); + let realgSubDialog = content.window.gSubDialog; + content.window.gSubDialog = testManageDialogOpened(addrUrl); + content.document.querySelector(selectors.savedAddressesBtn).click(); + content.window.gSubDialog = testManageDialogOpened(ccUrl); + content.document.querySelector(selectors.savedCreditCardsBtn).click(); + content.window.gSubDialog = realgSubDialog; + } + ); } ); }); diff --git a/browser/extensions/formautofill/test/browser/head.js b/browser/extensions/formautofill/test/browser/head.js index f6f43265374e..76782229cc5b 100644 --- a/browser/extensions/formautofill/test/browser/head.js +++ b/browser/extensions/formautofill/test/browser/head.js @@ -179,7 +179,9 @@ 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( - browser, [{ selector }], async function({ selector }) { + browser, + [{ selector }], + async function({ selector }) { const { FormLikeFactory } = ChromeUtils.import( "resource://gre/modules/FormLikeFactory.jsm" ); diff --git a/browser/modules/test/browser/browser_UsageTelemetry_domains.js b/browser/modules/test/browser/browser_UsageTelemetry_domains.js index bb5d4ab248c7..762d977eef64 100644 --- a/browser/modules/test/browser/browser_UsageTelemetry_domains.js +++ b/browser/modules/test/browser/browser_UsageTelemetry_domains.js @@ -107,16 +107,18 @@ add_task(async function test_URIAndDomainCounts() { // We should not count AJAX requests. const XHR_URL = "http://example.com/r"; - await SpecialPowers.spawn(newWin.gBrowser.selectedBrowser, [XHR_URL], function( - url - ) { - return new Promise(resolve => { - var xhr = new content.window.XMLHttpRequest(); - xhr.open("GET", url); - xhr.onload = () => resolve(); - xhr.send(); - }); - }); + await SpecialPowers.spawn( + newWin.gBrowser.selectedBrowser, + [XHR_URL], + function(url) { + return new Promise(resolve => { + var xhr = new content.window.XMLHttpRequest(); + xhr.open("GET", url); + xhr.onload = () => resolve(); + xhr.send(); + }); + } + ); checkCounts({ totalURIs: 2, domainCount: 1, totalUnfilteredURIs: 2 }); // Check that we're counting page fragments. @@ -147,7 +149,9 @@ add_task(async function test_URIAndDomainCounts() { // Check that we only account for top level loads (e.g. we don't count URIs from // embedded iframes). await SpecialPowers.spawn( - newWin.gBrowser.selectedBrowser, [], async function() { + newWin.gBrowser.selectedBrowser, + [], + async function() { let doc = content.document; let iframe = doc.createElement("iframe"); let promiseIframeLoaded = ContentTaskUtils.waitForEvent( diff --git a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm index 17a372796f93..83d895ee833b 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/PermissionPrompts.jsm @@ -10,7 +10,6 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { E10SUtils } = ChromeUtils.import( "resource://gre/modules/E10SUtils.jsm" ); -; const { BrowserTestUtils } = ChromeUtils.import( "resource://testing-common/BrowserTestUtils.jsm" ); @@ -156,15 +155,23 @@ async function clickOn(selector, beforeContentFn) { ); if (beforeContentFn) { - await lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn(lastTab.linkedBrowser, [], beforeContentFn); + await lastTab.linkedBrowser.ownerGlobal.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 lastTab.linkedBrowser.ownerGlobal.SpecialPowers.spawn( + lastTab.linkedBrowser, + [selector], + async function(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/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm index ba64cfad10d3..19fe42b03467 100644 --- a/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm +++ b/browser/tools/mozscreenshots/mozscreenshots/extension/configurations/Preferences.jsm @@ -10,8 +10,6 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); const { TestUtils } = ChromeUtils.import( "resource://testing-common/TestUtils.jsm" ); -; - var Preferences = { init(libDir) { let panes = [ @@ -57,14 +55,18 @@ let prefHelper = async function(primary, customFn = null) { let selectedBrowser = browserWindow.gBrowser.selectedBrowser; // close any dialog that might still be open - await selectedBrowser.ownerGlobal.SpecialPowers.spawn(selectedBrowser, [], async function() { - // Check that gSubDialog is defined on the content window - // and that there is an open dialog to close - if (!content.window.gSubDialog || !content.window.gSubDialog._topDialog) { - return; + await selectedBrowser.ownerGlobal.SpecialPowers.spawn( + selectedBrowser, + [], + async function() { + // Check that gSubDialog is defined on the content window + // and that there is an open dialog to close + if (!content.window.gSubDialog || !content.window.gSubDialog._topDialog) { + return; + } + content.window.gSubDialog.close(); } - content.window.gSubDialog.close(); - }); + ); let readyPromise = null; if (selectedBrowser.currentURI.specIgnoringRef == "about:preferences") { @@ -107,50 +109,78 @@ function paintPromise(browserWindow) { } async function browsingGroup(aBrowser) { - await aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - content.document.getElementById("browsingGroup").scrollIntoView(); - }); + await aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + content.document.getElementById("browsingGroup").scrollIntoView(); + } + ); } async function cacheGroup(aBrowser) { - await aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - content.document.getElementById("cacheGroup").scrollIntoView(); - }); + await aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + content.document.getElementById("cacheGroup").scrollIntoView(); + } + ); } async function DNTDialog(aBrowser) { - return aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - const button = content.document.getElementById("doNotTrackSettings"); - if (!button) { - return { - todo: "The dialog may have exited before we could click the button", - }; + return aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + const button = content.document.getElementById("doNotTrackSettings"); + if (!button) { + return { + todo: "The dialog may have exited before we could click the button", + }; + } + button.click(); + return undefined; } - button.click(); - return undefined; - }); + ); } async function connectionDialog(aBrowser) { - await aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - content.document.getElementById("connectionSettings").click(); - }); + await aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + content.document.getElementById("connectionSettings").click(); + } + ); } async function clearRecentHistoryDialog(aBrowser) { - await aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - content.document.getElementById("clearHistoryButton").click(); - }); + await aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + content.document.getElementById("clearHistoryButton").click(); + } + ); } async function certManager(aBrowser) { - await aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - content.document.getElementById("viewCertificatesButton").click(); - }); + await aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + content.document.getElementById("viewCertificatesButton").click(); + } + ); } async function deviceManager(aBrowser) { - await aBrowser.ownerGlobal.SpecialPowers.spawn(aBrowser, [], async function() { - content.document.getElementById("viewSecurityDevicesButton").click(); - }); + await aBrowser.ownerGlobal.SpecialPowers.spawn( + aBrowser, + [], + async function() { + content.document.getElementById("viewSecurityDevicesButton").click(); + } + ); } diff --git a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_addons_manifest_url.js b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_addons_manifest_url.js index 1b16d000d0d7..c529683062a3 100644 --- a/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_addons_manifest_url.js +++ b/devtools/client/aboutdebugging/test/browser/browser_aboutdebugging_addons_manifest_url.js @@ -43,7 +43,9 @@ add_task(async function() { info("Retrieve the text content of the new tab"); const textContent = await SpecialPowers.spawn( - target.linkedBrowser, [], function() { + target.linkedBrowser, + [], + function() { return content.wrappedJSObject.document.body.textContent; } ); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-call-stack.js b/devtools/client/debugger/test/mochitest/browser_dbg-call-stack.js index fea41a2efccc..bc504369943b 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-call-stack.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-call-stack.js @@ -8,7 +8,7 @@ function isFrameSelected(dbg, index, title) { const { selectors: { getSelectedFrame, getCurrentThread }, - getState + getState, } = dbg; const frame = getSelectedFrame(getCurrentThread()); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sources-named-eval.js b/devtools/client/debugger/test/mochitest/browser_dbg-sources-named-eval.js index cbb79f272054..52975521f5f2 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sources-named-eval.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sources-named-eval.js @@ -18,18 +18,24 @@ function getLabel(dbg, index) { } add_task(async function() { - const dbg = await initDebugger("doc-sources.html", "simple1", "simple2", "nested-source", "long.js"); + const dbg = await initDebugger( + "doc-sources.html", + "simple1", + "simple2", + "nested-source", + "long.js" + ); const { selectors: { getSelectedSource }, - getState + getState, } = dbg; - info(`>>> contentTask: evaluate evaled.js\n`) + info(`>>> contentTask: evaluate evaled.js\n`); SpecialPowers.spawn(gBrowser.selectedBrowser, [], function() { content.eval("window.evaledFunc = function() {} //# sourceURL=evaled.js"); }); await waitForSourceCount(dbg, 3); // is(getLabel(dbg, 3), "evaled.js", "evaled exists"); - ok(true) + ok(true); }); diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-sources.js b/devtools/client/debugger/test/mochitest/browser_dbg-sources.js index c161f129cf8e..186300e8c3a4 100644 --- a/devtools/client/debugger/test/mochitest/browser_dbg-sources.js +++ b/devtools/client/debugger/test/mochitest/browser_dbg-sources.js @@ -14,7 +14,7 @@ add_task(async function() { ); const { selectors: { getSelectedSource }, - getState + getState, } = dbg; // Expand nodes and make sure more sources appear. diff --git a/devtools/client/debugger/test/mochitest/helpers.js b/devtools/client/debugger/test/mochitest/helpers.js index 8f58c93c01b2..bdd7647ed371 100644 --- a/devtools/client/debugger/test/mochitest/helpers.js +++ b/devtools/client/debugger/test/mochitest/helpers.js @@ -1082,22 +1082,25 @@ function waitForActive(dbg) { */ function invokeInTab(fnc, ...args) { info(`Invoking in tab: ${fnc}(${args.map(uneval).join(",")})`); - return SpecialPowers.spawn(gBrowser.selectedBrowser, [{ fnc, args }], function*({ - fnc, - args, - }) { - return content.wrappedJSObject[fnc](...args); - }); + return SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ fnc, args }], + function*({ fnc, args }) { + return content.wrappedJSObject[fnc](...args); + } + ); } function clickElementInTab(selector) { info(`click element ${selector} in tab`); - return SpecialPowers.spawn(gBrowser.selectedBrowser, [{ selector }], function*({ - selector, - }) { - content.wrappedJSObject.document.querySelector(selector).click(); - }); + return SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ selector }], + function*({ selector }) { + content.wrappedJSObject.document.querySelector(selector).click(); + } + ); } const isLinux = Services.appinfo.OS === "Linux"; diff --git a/devtools/client/framework/test/helper_disable_cache.js b/devtools/client/framework/test/helper_disable_cache.js index d0f433f81533..a2adcf325c5a 100644 --- a/devtools/client/framework/test/helper_disable_cache.js +++ b/devtools/client/framework/test/helper_disable_cache.js @@ -56,7 +56,9 @@ async function checkCacheEnabled(tabX, expected) { await reloadTab(tabX); const oldGuid = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { const doc = content.document; const h1 = doc.querySelector("h1"); return h1.textContent; @@ -66,7 +68,9 @@ async function checkCacheEnabled(tabX, expected) { await reloadTab(tabX); const guid = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { const doc = content.document; const h1 = doc.querySelector("h1"); return h1.textContent; diff --git a/devtools/client/inspector/fonts/test/browser_fontinspector_reveal-in-page.js b/devtools/client/inspector/fonts/test/browser_fontinspector_reveal-in-page.js index 6c1a09adf646..0f0686650d9c 100644 --- a/devtools/client/inspector/fonts/test/browser_fontinspector_reveal-in-page.js +++ b/devtools/client/inspector/fonts/test/browser_fontinspector_reveal-in-page.js @@ -65,7 +65,9 @@ add_task(async function() { }); async function waitForNSelectionEvents(tab, numberOfTimes) { - await SpecialPowers.spawn(tab.linkedBrowser, [numberOfTimes], async function(n) { + await SpecialPowers.spawn(tab.linkedBrowser, [numberOfTimes], async function( + n + ) { const win = content.wrappedJSObject; await new Promise(resolve => { diff --git a/devtools/client/inspector/rules/test/browser_rules_inline-style-order.js b/devtools/client/inspector/rules/test/browser_rules_inline-style-order.js index bf9543a9a3ea..5561b6cdd311 100644 --- a/devtools/client/inspector/rules/test/browser_rules_inline-style-order.js +++ b/devtools/client/inspector/rules/test/browser_rules_inline-style-order.js @@ -43,7 +43,9 @@ add_task(async function() { const onStyleMutation = waitForStyleModification(inspector); const onRuleRefreshed = inspector.once("rule-view-refreshed"); - await SpecialPowers.spawn(browser, [{ name, value }], async function(change) { + await SpecialPowers.spawn(browser, [{ name, value }], async function( + change + ) { content.document.querySelector("div").style[change.name] = change.value; }); await Promise.all([onStyleMutation, onRuleRefreshed]); diff --git a/devtools/client/inspector/test/browser_inspector_open_on_neterror.js b/devtools/client/inspector/test/browser_inspector_open_on_neterror.js index 665dbbf188bd..d052fb87b89b 100644 --- a/devtools/client/inspector/test/browser_inspector_open_on_neterror.js +++ b/devtools/client/inspector/test/browser_inspector_open_on_neterror.js @@ -17,7 +17,9 @@ add_task(async function() { )); await BrowserTestUtils.browserLoaded(tab.linkedBrowser); await SpecialPowers.spawn( - tab.linkedBrowser, [{ url: TEST_URL_1 }], async function({ url }) { + tab.linkedBrowser, + [{ url: TEST_URL_1 }], + async function({ url }) { // Also, the neterror being privileged, the DOMContentLoaded only fires on // the chromeEventHandler. const { chromeEventHandler } = docShell; // eslint-disable-line no-undef diff --git a/devtools/client/inspector/test/shared-head.js b/devtools/client/inspector/test/shared-head.js index 0a7587f59cf5..98fcfb3017a2 100644 --- a/devtools/client/inspector/test/shared-head.js +++ b/devtools/client/inspector/test/shared-head.js @@ -727,7 +727,9 @@ function openContextMenuAndGetAllItems(inspector, options) { async function waitUntilVisitedState(tab, selectors) { await asyncWaitUntil(async () => { const hasVisitedState = await SpecialPowers.spawn( - tab.linkedBrowser, [selectors], args => { + tab.linkedBrowser, + [selectors], + args => { const NS_EVENT_STATE_VISITED = 1 << 24; for (const selector of args) { diff --git a/devtools/client/jsonview/test/browser_json_refresh.js b/devtools/client/jsonview/test/browser_json_refresh.js index ec30bcf1c406..39afa58a3c5f 100644 --- a/devtools/client/jsonview/test/browser_json_refresh.js +++ b/devtools/client/jsonview/test/browser_json_refresh.js @@ -15,7 +15,10 @@ add_task(async function() { const tab = await addJsonViewTab(uri.spec); // perform sanity checks for URI and principals in loadInfo - await SpecialPowers.spawn(tab.linkedBrowser, [{TEST_JSON_FILE}], async function ({TEST_JSON_FILE}) { // eslint-disable-line + await SpecialPowers.spawn( + tab.linkedBrowser, + [{ TEST_JSON_FILE }], + async function({ TEST_JSON_FILE }) { // eslint-disable-line const channel = content.docShell.currentDocumentChannel; const channelURI = channel.URI.spec; ok( @@ -54,7 +57,11 @@ add_task(async function() { await loaded; // check principals in loadInfo are still correct - await SpecialPowers.spawn(tab.linkedBrowser, [{TEST_JSON_FILE}], async function ({TEST_JSON_FILE}) { // eslint-disable-line + await SpecialPowers.spawn( + tab.linkedBrowser, + [{ TEST_JSON_FILE }], + async function({ TEST_JSON_FILE }) { + // eslint-disable-line const channel = content.docShell.currentDocumentChannel; const channelURI = channel.URI.spec; ok( diff --git a/devtools/client/jsonview/test/browser_jsonview_row_selection.js b/devtools/client/jsonview/test/browser_jsonview_row_selection.js index 2611e17d704f..193bde9607bf 100644 --- a/devtools/client/jsonview/test/browser_jsonview_row_selection.js +++ b/devtools/client/jsonview/test/browser_jsonview_row_selection.js @@ -167,7 +167,9 @@ add_task(async function() { await assertRowSelected(2); const scroll = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { const scroller = content.document.querySelector( ".jsonPanelBox .panelContent" ); @@ -211,7 +213,9 @@ add_task(async function() { async function assertRowSelected(rowNum) { const idx = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { return [].indexOf.call( content.document.querySelectorAll(".treeRow"), content.document.querySelector(".treeRow.selected") diff --git a/devtools/client/jsonview/test/browser_jsonview_serviceworker.js b/devtools/client/jsonview/test/browser_jsonview_serviceworker.js index 815921c3b49c..d0c01be3f7b8 100644 --- a/devtools/client/jsonview/test/browser_jsonview_serviceworker.js +++ b/devtools/client/jsonview/test/browser_jsonview_serviceworker.js @@ -22,7 +22,9 @@ add_task(async function() { const browser = gBrowser.getBrowserForTab(swTab); await BrowserTestUtils.browserLoaded(browser); await SpecialPowers.spawn( - browser, [{ script: SW, scope: TEST_JSON_URL }], async opts => { + browser, + [{ script: SW, scope: TEST_JSON_URL }], + async opts => { const reg = await content.navigator.serviceWorker.register(opts.script, { scope: opts.scope, }); @@ -69,7 +71,9 @@ add_task(async function() { is(await countRows(), 1, "There must be one row"); await SpecialPowers.spawn( - browser, [{ script: SW, scope: TEST_JSON_URL }], async opts => { + browser, + [{ script: SW, scope: TEST_JSON_URL }], + async opts => { const reg = await content.navigator.serviceWorker.getRegistration( opts.scope ); diff --git a/devtools/client/netmonitor/src/har/test/browser_net_har_throttle_upload.js b/devtools/client/netmonitor/src/har/test/browser_net_har_throttle_upload.js index 37b0a9abc276..e3edcca77c11 100644 --- a/devtools/client/netmonitor/src/har/test/browser_net_har_throttle_upload.js +++ b/devtools/client/netmonitor/src/har/test/browser_net_har_throttle_upload.js @@ -50,7 +50,9 @@ async function throttleUploadTest(actuallyThrottle) { EVENTS.RECEIVED_EVENT_TIMINGS ); const wait = waitForNetworkEvents(monitor, 1); - await SpecialPowers.spawn(tab.linkedBrowser, [{ size }], async function(args) { + await SpecialPowers.spawn(tab.linkedBrowser, [{ size }], async function( + args + ) { content.wrappedJSObject.executeTest2(args.size); }); await wait; diff --git a/devtools/client/netmonitor/test/browser_net_cause_redirect.js b/devtools/client/netmonitor/test/browser_net_cause_redirect.js index ee9b65122833..e8fb54ba3f95 100644 --- a/devtools/client/netmonitor/test/browser_net_cause_redirect.js +++ b/devtools/client/netmonitor/test/browser_net_cause_redirect.js @@ -60,10 +60,12 @@ add_task(async function() { await teardown(monitor); function performRequests(count, url) { - return SpecialPowers.spawn(tab.linkedBrowser, [{ count, url }], async function( - args - ) { - content.wrappedJSObject.performRequests(args.count, args.url); - }); + return SpecialPowers.spawn( + tab.linkedBrowser, + [{ count, url }], + async function(args) { + content.wrappedJSObject.performRequests(args.count, args.url); + } + ); } }); diff --git a/devtools/client/netmonitor/test/browser_net_copy_as_curl.js b/devtools/client/netmonitor/test/browser_net_copy_as_curl.js index 7c9374923724..a83a499355d8 100644 --- a/devtools/client/netmonitor/test/browser_net_copy_as_curl.js +++ b/devtools/client/netmonitor/test/browser_net_copy_as_curl.js @@ -159,11 +159,15 @@ async function testForPlatform(tab, monitor, testData) { async function performRequest(method, payload) { const waitRequest = waitForNetworkEvents(monitor, 1); await SpecialPowers.spawn( - tab.linkedBrowser, [{ - url: SIMPLE_SJS, - method_: method, - payload_: payload, - }], async function({ url, method_, payload_ }) { + tab.linkedBrowser, + [ + { + url: SIMPLE_SJS, + method_: method, + payload_: payload, + }, + ], + async function({ url, method_, payload_ }) { content.wrappedJSObject.performRequest(url, method_, payload_); } ); diff --git a/devtools/client/netmonitor/test/browser_net_copy_as_fetch.js b/devtools/client/netmonitor/test/browser_net_copy_as_fetch.js index 39e1666e89ed..b9e5e5b5db83 100644 --- a/devtools/client/netmonitor/test/browser_net_copy_as_fetch.js +++ b/devtools/client/netmonitor/test/browser_net_copy_as_fetch.js @@ -35,11 +35,15 @@ add_task(async function() { async function performRequest(method, payload) { const waitRequest = waitForNetworkEvents(monitor, 1); await SpecialPowers.spawn( - tab.linkedBrowser, [{ - url: SIMPLE_SJS, - method_: method, - payload_: payload, - }], async function({ url, method_, payload_ }) { + tab.linkedBrowser, + [ + { + url: SIMPLE_SJS, + method_: method, + payload_: payload, + }, + ], + async function({ url, method_, payload_ }) { content.wrappedJSObject.performRequest(url, method_, payload_); } ); diff --git a/devtools/client/netmonitor/test/browser_net_cors_requests.js b/devtools/client/netmonitor/test/browser_net_cors_requests.js index 87fe83131f5a..f063137e8b06 100644 --- a/devtools/client/netmonitor/test/browser_net_cors_requests.js +++ b/devtools/client/netmonitor/test/browser_net_cors_requests.js @@ -22,7 +22,9 @@ add_task(async function() { info("Performing a CORS request"); const requestUrl = "http://test1.example.com" + CORS_SJS_PATH; - await SpecialPowers.spawn(tab.linkedBrowser, [requestUrl], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [requestUrl], async function( + url + ) { content.wrappedJSObject.performRequests( url, "triggering/preflight", diff --git a/devtools/client/netmonitor/test/browser_net_curl-utils.js b/devtools/client/netmonitor/test/browser_net_curl-utils.js index a04479c90f12..8748c6239696 100644 --- a/devtools/client/netmonitor/test/browser_net_curl-utils.js +++ b/devtools/client/netmonitor/test/browser_net_curl-utils.js @@ -23,7 +23,9 @@ add_task(async function() { store.dispatch(Actions.batchEnable(false)); const wait = waitForNetworkEvents(monitor, 6); - await SpecialPowers.spawn(tab.linkedBrowser, [SIMPLE_SJS], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [SIMPLE_SJS], async function( + url + ) { content.wrappedJSObject.performRequests(url); }); await wait; diff --git a/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js b/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js index 42a024e99735..731cb32c1145 100644 --- a/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js +++ b/devtools/client/netmonitor/test/browser_net_open_request_in_tab.js @@ -157,7 +157,9 @@ add_task(async function() { async function performRequest(monitor, tab, method, contentType, payload) { const wait = waitForNetworkEvents(monitor, 1); await SpecialPowers.spawn( - tab.linkedBrowser, [[method, contentType, payload]], async function([method_, contentType_, payload_]) { + tab.linkedBrowser, + [[method, contentType, payload]], + async function([method_, contentType_, payload_]) { content.wrappedJSObject.performRequest(method_, contentType_, payload_); } ); @@ -167,7 +169,9 @@ async function performRequest(monitor, tab, method, contentType, payload) { async function checkTabResponse(checkedTab, method, contentType, payload) { await SpecialPowers.spawn( - checkedTab.linkedBrowser, [[method, contentType, payload]], async function([method_, contentType_, payload_]) { + checkedTab.linkedBrowser, + [[method, contentType, payload]], + async function([method_, contentType_, payload_]) { const { body } = content.wrappedJSObject.document; const expected = [method_, contentType_, payload_].join("\n"); info("Response from the server:" + body.innerHTML.replace(/\n/g, "\\n")); diff --git a/devtools/client/netmonitor/test/browser_net_pause.js b/devtools/client/netmonitor/test/browser_net_pause.js index 943b341b94d2..68c20d3dfa89 100644 --- a/devtools/client/netmonitor/test/browser_net_pause.js +++ b/devtools/client/netmonitor/test/browser_net_pause.js @@ -70,7 +70,9 @@ function assertRequestCount(store, count) { */ async function performRequestAndWait(tab, monitor) { const wait = waitForNetworkEvents(monitor, 1); - await SpecialPowers.spawn(tab.linkedBrowser, [SIMPLE_SJS], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [SIMPLE_SJS], async function( + url + ) { await content.wrappedJSObject.performRequests(url); }); await wait; @@ -81,7 +83,9 @@ async function performRequestAndWait(tab, monitor) { */ async function performPausedRequest(connector, tab, monitor) { const wait = connector.connector.webConsoleFront.once("networkEvent"); - await SpecialPowers.spawn(tab.linkedBrowser, [SIMPLE_SJS], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [SIMPLE_SJS], async function( + url + ) { await content.wrappedJSObject.performRequests(url); }); await wait; diff --git a/devtools/client/netmonitor/test/browser_net_resend_cors.js b/devtools/client/netmonitor/test/browser_net_resend_cors.js index 1b8952a8338d..36b7bfbfb207 100644 --- a/devtools/client/netmonitor/test/browser_net_resend_cors.js +++ b/devtools/client/netmonitor/test/browser_net_resend_cors.js @@ -24,7 +24,9 @@ add_task(async function() { info("Waiting for OPTIONS, then POST"); const wait = waitForNetworkEvents(monitor, 2); - await SpecialPowers.spawn(tab.linkedBrowser, [requestUrl], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [requestUrl], async function( + url + ) { content.wrappedJSObject.performRequests( url, "triggering/preflight", diff --git a/devtools/client/netmonitor/test/browser_net_security-details.js b/devtools/client/netmonitor/test/browser_net_security-details.js index dff73040441c..99b27916df63 100644 --- a/devtools/client/netmonitor/test/browser_net_security-details.js +++ b/devtools/client/netmonitor/test/browser_net_security-details.js @@ -19,7 +19,9 @@ add_task(async function() { info("Performing a secure request."); const REQUESTS_URL = "https://example.com" + CORS_SJS_PATH; const wait = waitForNetworkEvents(monitor, 1); - await SpecialPowers.spawn(tab.linkedBrowser, [REQUESTS_URL], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [REQUESTS_URL], async function( + url + ) { content.wrappedJSObject.performRequests(1, url); }); await wait; diff --git a/devtools/client/netmonitor/test/browser_net_security-icon-click.js b/devtools/client/netmonitor/test/browser_net_security-icon-click.js index 5917137da8f6..542e352cc290 100644 --- a/devtools/client/netmonitor/test/browser_net_security-icon-click.js +++ b/devtools/client/netmonitor/test/browser_net_security-icon-click.js @@ -48,7 +48,9 @@ add_task(async function() { async function performRequestAndWait(url) { const wait = waitForNetworkEvents(monitor, 1); - await SpecialPowers.spawn(tab.linkedBrowser, [{ url }], async function(args) { + await SpecialPowers.spawn(tab.linkedBrowser, [{ url }], async function( + args + ) { content.wrappedJSObject.performRequests(1, args.url); }); return wait; diff --git a/devtools/client/netmonitor/test/browser_net_security-redirect.js b/devtools/client/netmonitor/test/browser_net_security-redirect.js index d68e5296aa97..1d8893bb41cc 100644 --- a/devtools/client/netmonitor/test/browser_net_security-redirect.js +++ b/devtools/client/netmonitor/test/browser_net_security-redirect.js @@ -16,11 +16,13 @@ add_task(async function() { store.dispatch(Actions.batchEnable(false)); const wait = waitForNetworkEvents(monitor, 2); - await SpecialPowers.spawn(tab.linkedBrowser, [HTTPS_REDIRECT_SJS], async function( - url - ) { - content.wrappedJSObject.performRequests(1, url); - }); + await SpecialPowers.spawn( + tab.linkedBrowser, + [HTTPS_REDIRECT_SJS], + async function(url) { + content.wrappedJSObject.performRequests(1, url); + } + ); await wait; is( diff --git a/devtools/client/netmonitor/test/browser_net_security-state.js b/devtools/client/netmonitor/test/browser_net_security-state.js index 22f625d5c729..5a5aebc675e8 100644 --- a/devtools/client/netmonitor/test/browser_net_security-state.js +++ b/devtools/client/netmonitor/test/browser_net_security-state.js @@ -60,7 +60,9 @@ add_task(async function() { async function performRequests() { function executeRequests(count, url) { return SpecialPowers.spawn( - tab.linkedBrowser, [{ count, url }], async function(args) { + tab.linkedBrowser, + [{ count, url }], + async function(args) { content.wrappedJSObject.performRequests(args.count, args.url); } ); diff --git a/devtools/client/netmonitor/test/browser_net_security-warnings.js b/devtools/client/netmonitor/test/browser_net_security-warnings.js index 98ebdbdc2654..da7eda6dba5c 100644 --- a/devtools/client/netmonitor/test/browser_net_security-warnings.js +++ b/devtools/client/netmonitor/test/browser_net_security-warnings.js @@ -27,7 +27,9 @@ add_task(async function() { info("Performing request to " + test.uri); let wait = waitForNetworkEvents(monitor, 1); - await SpecialPowers.spawn(tab.linkedBrowser, [test.uri], async function(url) { + await SpecialPowers.spawn(tab.linkedBrowser, [test.uri], async function( + url + ) { content.wrappedJSObject.performRequests(1, url); }); await wait; diff --git a/devtools/client/netmonitor/test/browser_net_server_timings.js b/devtools/client/netmonitor/test/browser_net_server_timings.js index c6cac3f4b4bf..722c5a81c686 100644 --- a/devtools/client/netmonitor/test/browser_net_server_timings.js +++ b/devtools/client/netmonitor/test/browser_net_server_timings.js @@ -15,7 +15,9 @@ add_task(async function() { let wait = waitForNetworkEvents(monitor, 1); await SpecialPowers.spawn( - tab.linkedBrowser, [SERVER_TIMINGS_TYPE_SJS], async function(url) { + tab.linkedBrowser, + [SERVER_TIMINGS_TYPE_SJS], + async function(url) { content.wrappedJSObject.performRequests(1, url); } ); diff --git a/devtools/client/netmonitor/test/browser_net_streaming-response.js b/devtools/client/netmonitor/test/browser_net_streaming-response.js index 9a7a6bcc812d..45b7a4c75028 100644 --- a/devtools/client/netmonitor/test/browser_net_streaming-response.js +++ b/devtools/client/netmonitor/test/browser_net_streaming-response.js @@ -25,7 +25,9 @@ add_task(async function() { let wait = waitForNetworkEvents(monitor, REQUESTS.length); for (const [fmt] of REQUESTS) { const url = CONTENT_TYPE_SJS + "?fmt=" + fmt; - await SpecialPowers.spawn(tab.linkedBrowser, [{ url }], async function(args) { + await SpecialPowers.spawn(tab.linkedBrowser, [{ url }], async function( + args + ) { content.wrappedJSObject.performRequests(1, args.url); }); } diff --git a/devtools/client/netmonitor/test/browser_net_use_as_fetch.js b/devtools/client/netmonitor/test/browser_net_use_as_fetch.js index 27c78e7143cf..c55220ba4245 100644 --- a/devtools/client/netmonitor/test/browser_net_use_as_fetch.js +++ b/devtools/client/netmonitor/test/browser_net_use_as_fetch.js @@ -35,11 +35,15 @@ add_task(async function() { async function performRequest(method, payload) { const waitRequest = waitForNetworkEvents(monitor, 1); await SpecialPowers.spawn( - tab.linkedBrowser, [{ - url: SIMPLE_SJS, - method_: method, - payload_: payload, - }], async function({ url, method_, payload_ }) { + tab.linkedBrowser, + [ + { + url: SIMPLE_SJS, + method_: method, + payload_: payload, + }, + ], + async function({ url, method_, payload_ }) { content.wrappedJSObject.performRequest(url, method_, payload_); } ); diff --git a/devtools/client/responsive/test/browser/browser_contextual_identity.js b/devtools/client/responsive/test/browser/browser_contextual_identity.js index 5676dc719309..8c9291b8cb1a 100644 --- a/devtools/client/responsive/test/browser/browser_contextual_identity.js +++ b/devtools/client/responsive/test/browser/browser_contextual_identity.js @@ -36,7 +36,9 @@ async function sendMessages(receiver) { // then send a message from a tab in the same user context for (const sender of [sender1, sender2]) { await SpecialPowers.spawn( - sender.browser, [{ name: channelName, message: sender.message }], function(opts) { + sender.browser, + [{ name: channelName, message: sender.message }], + function(opts) { const bc = new content.BroadcastChannel(opts.name); bc.postMessage(opts.message); } diff --git a/devtools/client/responsive/test/browser/browser_page_style.js b/devtools/client/responsive/test/browser/browser_page_style.js index ddf5b2858dbf..6fdc8a13bb46 100644 --- a/devtools/client/responsive/test/browser/browser_page_style.js +++ b/devtools/client/responsive/test/browser/browser_page_style.js @@ -51,17 +51,19 @@ addRDMTask(TEST_URL, async function({ ui, manager }) { }); function waitForContentPageTextColor(ui, expectedColor) { - return SpecialPowers.spawn(ui.getViewportBrowser(), [{ expectedColor }], function( - args - ) { - return new Promise(resolve => { - const interval = content.setInterval(() => { - const color = content.getComputedStyle(content.document.body).color; - if (color === args.expectedColor) { - content.clearInterval(interval); - resolve(color); - } - }, 200); - }); - }); + return SpecialPowers.spawn( + ui.getViewportBrowser(), + [{ expectedColor }], + function(args) { + return new Promise(resolve => { + const interval = content.setInterval(() => { + const color = content.getComputedStyle(content.document.body).color; + if (color === args.expectedColor) { + content.clearInterval(interval); + resolve(color); + } + }, 200); + }); + } + ); } diff --git a/devtools/client/responsive/test/browser/browser_touch_does_not_trigger_hover_states.js b/devtools/client/responsive/test/browser/browser_touch_does_not_trigger_hover_states.js index e6b366edc538..d56633615573 100644 --- a/devtools/client/responsive/test/browser/browser_touch_does_not_trigger_hover_states.js +++ b/devtools/client/responsive/test/browser/browser_touch_does_not_trigger_hover_states.js @@ -26,49 +26,53 @@ addRDMTask(TEST_URL, async function({ ui }) { }); async function testButtonHoverState(ui, expected) { - await SpecialPowers.spawn(ui.getViewportBrowser(), [{ expected }], async function( - args - ) { - let button = content.document.querySelector("button"); - const { expected: contentExpected } = args; + await SpecialPowers.spawn( + ui.getViewportBrowser(), + [{ expected }], + async function(args) { + let button = content.document.querySelector("button"); + const { expected: contentExpected } = args; - info("Move mouse into the button element."); - await EventUtils.synthesizeMouseAtCenter( - button, - { type: "mousemove", isSynthesized: false }, - content - ); - button = content.document.querySelector("button"); - const win = content.document.defaultView; + info("Move mouse into the button element."); + await EventUtils.synthesizeMouseAtCenter( + button, + { type: "mousemove", isSynthesized: false }, + content + ); + button = content.document.querySelector("button"); + const win = content.document.defaultView; - is( - win.getComputedStyle(button).getPropertyValue("background-color"), - contentExpected, - `Button background color is ${contentExpected}.` - ); - }); + is( + win.getComputedStyle(button).getPropertyValue("background-color"), + contentExpected, + `Button background color is ${contentExpected}.` + ); + } + ); } async function testDropDownHoverState(ui, expected) { - await SpecialPowers.spawn(ui.getViewportBrowser(), [{ expected }], async function( - args - ) { - const dropDownMenu = content.document.querySelector(".drop-down-menu"); - const { expected: contentExpected } = args; + await SpecialPowers.spawn( + ui.getViewportBrowser(), + [{ expected }], + async function(args) { + const dropDownMenu = content.document.querySelector(".drop-down-menu"); + const { expected: contentExpected } = args; - info("Move mouse into the drop down menu."); - await EventUtils.synthesizeMouseAtCenter( - dropDownMenu, - { type: "mousemove", isSynthesized: false }, - content - ); - const win = content.document.defaultView; - const menuItems = content.document.querySelector(".menu-items-list"); + info("Move mouse into the drop down menu."); + await EventUtils.synthesizeMouseAtCenter( + dropDownMenu, + { type: "mousemove", isSynthesized: false }, + content + ); + const win = content.document.defaultView; + const menuItems = content.document.querySelector(".menu-items-list"); - is( - win.getComputedStyle(menuItems).getPropertyValue("display"), - contentExpected, - `Menu items is display: ${contentExpected}.` - ); - }); + is( + win.getComputedStyle(menuItems).getPropertyValue("display"), + contentExpected, + `Menu items is display: ${contentExpected}.` + ); + } + ); } diff --git a/devtools/client/responsive/test/browser/browser_window_sizing.js b/devtools/client/responsive/test/browser/browser_window_sizing.js index 824d86799e29..1df39eb87235 100644 --- a/devtools/client/responsive/test/browser/browser_window_sizing.js +++ b/devtools/client/responsive/test/browser/browser_window_sizing.js @@ -31,7 +31,9 @@ add_task(async function() { async function checkWindowOuterSize(ui, zoom_level) { return SpecialPowers.spawn( - ui.getViewportBrowser(), [{ width: WIDTH, height: HEIGHT, zoom: zoom_level }], async function({ width, height, zoom }) { + ui.getViewportBrowser(), + [{ width: WIDTH, height: HEIGHT, zoom: zoom_level }], + async function({ width, height, zoom }) { // Approximate the outer size value returned on the window content with the expected // value. We should expect, at the very most, a 2px difference between the two due // to floating point rounding errors that occur when scaling from inner size CSS @@ -55,7 +57,9 @@ async function checkWindowOuterSize(ui, zoom_level) { async function checkWindowScreenSize(ui, zoom_level) { return SpecialPowers.spawn( - ui.getViewportBrowser(), [{ width: WIDTH, height: HEIGHT, zoom: zoom_level }], async function({ width, height, zoom }) { + ui.getViewportBrowser(), + [{ width: WIDTH, height: HEIGHT, zoom: zoom_level }], + async function({ width, height, zoom }) { const { screen } = content; ok( diff --git a/devtools/client/responsive/test/browser/head.js b/devtools/client/responsive/test/browser/head.js index 71db7a814a6e..59a8b8262093 100644 --- a/devtools/client/responsive/test/browser/head.js +++ b/devtools/client/responsive/test/browser/head.js @@ -275,7 +275,9 @@ var setViewportSize = async function(ui, manager, width, height) { var setViewportSizeAndAwaitReflow = async function(ui, manager, width, height) { await setViewportSize(ui, manager, width, height); const reflowed = SpecialPowers.spawn( - ui.getViewportBrowser(), [], async function() { + ui.getViewportBrowser(), + [], + async function() { return new Promise(resolve => { content.requestAnimationFrame(resolve); }); diff --git a/devtools/client/shared/sourceeditor/test/browser_css_autocompletion.js b/devtools/client/shared/sourceeditor/test/browser_css_autocompletion.js index ec534539e13b..09516f24d9c6 100644 --- a/devtools/client/shared/sourceeditor/test/browser_css_autocompletion.js +++ b/devtools/client/shared/sourceeditor/test/browser_css_autocompletion.js @@ -114,7 +114,10 @@ async function checkStateAndMoveOn() { const [line, ch] = lineCh; ++index; - await SpecialPowers.spawn(browser, [[index, tests.length]], function([idx, len]) { + await SpecialPowers.spawn(browser, [[index, tests.length]], function([ + idx, + len, + ]) { const progress = content.document.getElementById("progress"); const progressDiv = content.document.querySelector("#progress > div"); progress.dataset.progress = idx; diff --git a/devtools/client/shared/sourceeditor/test/browser_css_getInfo.js b/devtools/client/shared/sourceeditor/test/browser_css_getInfo.js index 46ac6451a943..fdbbb68514d6 100644 --- a/devtools/client/shared/sourceeditor/test/browser_css_getInfo.js +++ b/devtools/client/shared/sourceeditor/test/browser_css_getInfo.js @@ -209,7 +209,10 @@ add_task(async function test() { for (const expected of tests) { ++i; const caret = expected.splice(0, 1)[0]; - await SpecialPowers.spawn(browser, [[i, tests.length]], function([idx, len]) { + await SpecialPowers.spawn(browser, [[i, tests.length]], function([ + idx, + len, + ]) { const progress = content.document.getElementById("progress"); const progressDiv = content.document.querySelector("#progress > div"); progress.dataset.progress = idx; diff --git a/devtools/client/shared/sourceeditor/test/browser_css_statemachine.js b/devtools/client/shared/sourceeditor/test/browser_css_statemachine.js index e31d4626158c..54e562d7f90b 100644 --- a/devtools/client/shared/sourceeditor/test/browser_css_statemachine.js +++ b/devtools/client/shared/sourceeditor/test/browser_css_statemachine.js @@ -100,7 +100,10 @@ add_task(async function test() { let i = 0; for (const testcase of tests) { ++i; - await SpecialPowers.spawn(browser, [[i, tests.length]], function([idx, len]) { + await SpecialPowers.spawn(browser, [[i, tests.length]], function([ + idx, + len, + ]) { const progress = content.document.getElementById("progress"); const progressDiv = content.document.querySelector("#progress > div"); progress.dataset.progress = idx; diff --git a/devtools/client/shared/test/shared-head.js b/devtools/client/shared/test/shared-head.js index 4f4cb52d6c70..1bdaca13312f 100644 --- a/devtools/client/shared/test/shared-head.js +++ b/devtools/client/shared/test/shared-head.js @@ -771,16 +771,20 @@ async function registerActorInContentProcess(url, options) { // chrome://mochitests URI is registered only in the parent process, so convert these // URLs to file:// one in order to work in the content processes url = url.startsWith("chrome://mochitests") ? convertChromeToFile(url) : url; - return SpecialPowers.spawn(gBrowser.selectedBrowser, [{ url, options }], args => { - // eslint-disable-next-line no-shadow - const { require } = ChromeUtils.import( - "resource://devtools/shared/Loader.jsm" - ); - const { - ActorRegistry, - } = require("devtools/server/actors/utils/actor-registry"); - ActorRegistry.registerModule(args.url, args.options); - }); + return SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ url, options }], + args => { + // eslint-disable-next-line no-shadow + const { require } = ChromeUtils.import( + "resource://devtools/shared/Loader.jsm" + ); + const { + ActorRegistry, + } = require("devtools/server/actors/utils/actor-registry"); + ActorRegistry.registerModule(args.url, args.options); + } + ); } /** diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js index 56cf8ee51cdb..d2e6a3fb9f97 100644 --- a/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js +++ b/devtools/client/storage/test/browser_storage_dynamic_updates_cookies.js @@ -222,7 +222,9 @@ add_task(async function() { async function addCookie(name, value, path) { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[name, value, path]], ([nam, valu, pat]) => { + gBrowser.selectedBrowser, + [[name, value, path]], + ([nam, valu, pat]) => { content.wrappedJSObject.addCookie(nam, valu, pat); } ); @@ -230,7 +232,9 @@ async function addCookie(name, value, path) { async function removeCookie(name, path) { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[name, path]], ([nam, pat]) => { + gBrowser.selectedBrowser, + [[name, path]], + ([nam, pat]) => { content.wrappedJSObject.removeCookie(nam, pat); } ); diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js b/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js index 5af1635bfd6e..70b6479fce77 100644 --- a/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js +++ b/devtools/client/storage/test/browser_storage_dynamic_updates_localStorage.js @@ -57,7 +57,9 @@ async function testRemoveAndChange(targetKey, expectedKeys, host) { async function setLocalStorageItem(key, value) { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[key, value]], ([innerKey, innerValue]) => { + gBrowser.selectedBrowser, + [[key, value]], + ([innerKey, innerValue]) => { content.wrappedJSObject.localStorage.setItem(innerKey, innerValue); } ); diff --git a/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js b/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js index 1b6ee8c425e3..6800694df1a4 100644 --- a/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js +++ b/devtools/client/storage/test/browser_storage_dynamic_updates_sessionStorage.js @@ -71,7 +71,9 @@ add_task(async function() { async function setSessionStorageItem(key, value) { await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[key, value]], ([innerKey, innerValue]) => { + gBrowser.selectedBrowser, + [[key, value]], + ([innerKey, innerValue]) => { content.wrappedJSObject.sessionStorage.setItem(innerKey, innerValue); } ); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_sync.js b/devtools/client/styleeditor/test/browser_styleeditor_sync.js index f27dcadc4b80..36bba6a6b7c9 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_sync.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_sync.js @@ -63,7 +63,9 @@ add_task(async function() { // For the time being, the actor does not update the style's owning // node's textContent. See bug 1205380. const textContent = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { return content.document.querySelector("style").textContent; } ); diff --git a/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js b/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js index 42daf7db2d2b..a2f4c38de21a 100644 --- a/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js +++ b/devtools/client/styleeditor/test/browser_styleeditor_transition_rule.js @@ -24,7 +24,9 @@ add_task(async function() { await styleChanges; const rules = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [0], async function(index) { + gBrowser.selectedBrowser, + [0], + async function(index) { const sheet = content.document.styleSheets[index]; return [...sheet.cssRules].map(rule => rule.cssText); } diff --git a/devtools/client/webconsole/test/browser/browser_jsterm_copy_command.js b/devtools/client/webconsole/test/browser/browser_jsterm_copy_command.js index 345fb526892e..b0099e7f5a9a 100644 --- a/devtools/client/webconsole/test/browser/browser_jsterm_copy_command.js +++ b/devtools/client/webconsole/test/browser/browser_jsterm_copy_command.js @@ -37,7 +37,9 @@ add_task(async function() { await testCopy(hud, obj.toSource(), JSON.stringify(obj, null, " ")); const outerHTML = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [id], function(elementId) { + gBrowser.selectedBrowser, + [id], + function(elementId) { return content.document.getElementById(elementId).outerHTML; } ); diff --git a/devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_clipboard.js b/devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_clipboard.js index 87755771db51..d9c0413399b9 100644 --- a/devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_clipboard.js +++ b/devtools/client/webconsole/test/browser/browser_jsterm_screenshot_command_clipboard.js @@ -137,7 +137,9 @@ async function createScrollbarOverflow() { async function getScrollbarSize() { const scrollbarSize = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { const winUtils = content.windowUtils; const scrollbarHeight = {}; const scrollbarWidth = {}; @@ -154,7 +156,9 @@ async function getScrollbarSize() { async function getContentSize() { const contentSize = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { return { scrollMaxY: content.scrollMaxY, scrollMaxX: content.scrollMaxX, diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_clickable_urls.js b/devtools/client/webconsole/test/browser/browser_webconsole_clickable_urls.js index a4d4ad73e205..fe5f60c63c9b 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_clickable_urls.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_clickable_urls.js @@ -16,9 +16,13 @@ add_task(async function() { const firstURL = "http://example.com/"; const secondURL = "http://example.com/?id=secondURL"; - SpecialPowers.spawn(gBrowser.selectedBrowser, [[firstURL, secondURL]], urls => { - content.wrappedJSObject.console.log("Visit ", urls[0], " and ", urls[1]); - }); + SpecialPowers.spawn( + gBrowser.selectedBrowser, + [[firstURL, secondURL]], + urls => { + content.wrappedJSObject.console.log("Visit ", urls[0], " and ", urls[1]); + } + ); const node = await waitFor(() => findMessage(hud, firstURL)); const [urlEl1, urlEl2] = Array.from(node.querySelectorAll("a.url")); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_console_dir_uninspectable.js b/devtools/client/webconsole/test/browser/browser_webconsole_console_dir_uninspectable.js index d8272f2d235e..255d9638be71 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_console_dir_uninspectable.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_console_dir_uninspectable.js @@ -32,9 +32,13 @@ add_task(async function() { info("Logging a second message to make sure the console is not broken"); const onLogMessage = waitForMessage(hud, SECOND_LOG_MESSAGE); // Logging from content to make sure the console API is working. - SpecialPowers.spawn(gBrowser.selectedBrowser, [SECOND_LOG_MESSAGE], string => { - content.console.log(string); - }); + SpecialPowers.spawn( + gBrowser.selectedBrowser, + [SECOND_LOG_MESSAGE], + string => { + content.console.log(string); + } + ); await onLogMessage; ok( diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_cors_errors.js b/devtools/client/webconsole/test/browser/browser_webconsole_cors_errors.js index e9f9b16d11da..1f3b97abaf1f 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_cors_errors.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_cors_errors.js @@ -186,7 +186,9 @@ async function checkCorsMessage(message, category) { function makeFaultyCorsCall(errorCategory, corsUrl) { SpecialPowers.spawn( - gBrowser.selectedBrowser, [[errorCategory, corsUrl]], ([category, url]) => { + gBrowser.selectedBrowser, + [[errorCategory, corsUrl]], + ([category, url]) => { if (!url) { const baseUrl = "http://mochi.test:8888/browser/devtools/client/webconsole/test/browser"; diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_document_focus.js b/devtools/client/webconsole/test/browser/browser_webconsole_document_focus.js index e542ddd637ef..a7bd54666b1c 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_document_focus.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_document_focus.js @@ -23,7 +23,9 @@ add_task(async function() { await closeConsole(); const isFocused = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { await this.onFocus; return Services.focus.focusedWindow == content; } diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_persist.js b/devtools/client/webconsole/test/browser/browser_webconsole_persist.js index 406404197c25..88b39db8f56c 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_persist.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_persist.js @@ -19,7 +19,9 @@ add_task(async function() { const INITIAL_LOGS_NUMBER = 5; await SpecialPowers.spawn( - gBrowser.selectedBrowser, [INITIAL_LOGS_NUMBER], count => { + gBrowser.selectedBrowser, + [INITIAL_LOGS_NUMBER], + count => { content.wrappedJSObject.doLogs(count); } ); @@ -47,7 +49,9 @@ add_task(async function() { const INITIAL_LOGS_NUMBER = 5; await SpecialPowers.spawn( - gBrowser.selectedBrowser, [INITIAL_LOGS_NUMBER], count => { + gBrowser.selectedBrowser, + [INITIAL_LOGS_NUMBER], + count => { content.wrappedJSObject.doLogs(count); } ); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_sidebar_object_expand_when_message_pruned.js b/devtools/client/webconsole/test/browser/browser_webconsole_sidebar_object_expand_when_message_pruned.js index a10142f23357..3dc2b4103b58 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_sidebar_object_expand_when_message_pruned.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_sidebar_object_expand_when_message_pruned.js @@ -35,7 +35,9 @@ add_task(async function() { info("Log a message so the original one gets pruned"); const messageText = "hello world"; const onMessage = waitForMessage(hud, messageText); - SpecialPowers.spawn(gBrowser.selectedBrowser, [messageText], async function(str) { + SpecialPowers.spawn(gBrowser.selectedBrowser, [messageText], async function( + str + ) { content.console.log(str); }); await onMessage; diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js index 1d06eac8c42a..104f3e04d15b 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_console_api.js @@ -84,7 +84,9 @@ async function generateConsoleApiStubs() { target.activeConsole.on("consoleAPICall", listener); }); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function(subCode) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function( + subCode + ) { const script = content.document.createElement("script"); script.append( content.document.createTextNode(`function triggerPacket() {${subCode}}`) diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js index d15361e585fa..8d0b660e7eb6 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_css_message.js @@ -80,7 +80,9 @@ async function generateCssMessageStubs() { }); }); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function(subCode) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function( + subCode + ) { content.docShell.cssErrorReportingEnabled = true; const style = content.document.createElement("style"); style.append(content.document.createTextNode(subCode)); diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_network_event.js b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_network_event.js index ba2f61a99f54..d71bc390a8ac 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_stubs_network_event.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stubs_network_event.js @@ -94,7 +94,9 @@ async function generateNetworkEventStubs() { packets.set(updateKey, getCleanedPacket(updateKey, packet)); }); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function(subCode) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function( + subCode + ) { const script = content.document.createElement("script"); script.append( content.document.createTextNode(`function triggerPacket() {${subCode}}`) 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 36f36b8c1e33..1d598c28e763 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,7 +75,9 @@ async function generatePageErrorStubs() { expectUncaughtException(); } - await SpecialPowers.spawn(gBrowser.selectedBrowser, [code], function(subCode) { + await SpecialPowers.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/devtools/client/webconsole/test/browser/browser_webconsole_visibility_messages.js b/devtools/client/webconsole/test/browser/browser_webconsole_visibility_messages.js index 603f06949854..fb656dfff317 100644 --- a/devtools/client/webconsole/test/browser/browser_webconsole_visibility_messages.js +++ b/devtools/client/webconsole/test/browser/browser_webconsole_visibility_messages.js @@ -51,11 +51,15 @@ add_task(async function() { }); }); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [[MESSAGES_COUNT]], count => { - for (let i = 1; i <= count; i++) { - content.wrappedJSObject.log("in-inspector log " + i); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [[MESSAGES_COUNT]], + count => { + for (let i = 1; i <= count; i++) { + content.wrappedJSObject.log("in-inspector log " + i); + } } - }); + ); info("Waiting for all messages to be logged into the store"); await onAllMessagesInStore; @@ -102,11 +106,15 @@ add_task(async function() { await toolbox.openSplitConsole(); - await SpecialPowers.spawn(gBrowser.selectedBrowser, [[MESSAGES_COUNT]], count => { - for (let i = 1; i <= count; i++) { - content.wrappedJSObject.log("in-inspector log " + i); + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [[MESSAGES_COUNT]], + count => { + for (let i = 1; i <= count; i++) { + content.wrappedJSObject.log("in-inspector log " + i); + } } - }); + ); info("Wait for all messages to be visible in the split console"); const waitForMessagePromises = []; diff --git a/devtools/server/tests/browser/browser_accessibility_simulator.js b/devtools/server/tests/browser/browser_accessibility_simulator.js index ab87982c2d36..10562455fd33 100644 --- a/devtools/server/tests/browser/browser_accessibility_simulator.js +++ b/devtools/server/tests/browser/browser_accessibility_simulator.js @@ -51,7 +51,9 @@ async function testSimulate(simulator, matrix, type = null) { ok(matrixApplied, "Simulation color matrix is successfully applied."); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[type, matrix]], ([simulationType, simulationMatrix]) => { + gBrowser.selectedBrowser, + [[type, matrix]], + ([simulationType, simulationMatrix]) => { const { window } = content; info( `Test that color matrix is set to ${simulationType || diff --git a/devtools/server/tests/browser/browser_animation_actor-lifetime.js b/devtools/server/tests/browser/browser_animation_actor-lifetime.js index 11d1b02bee47..5ce73a0da1fd 100644 --- a/devtools/server/tests/browser/browser_animation_actor-lifetime.js +++ b/devtools/server/tests/browser/browser_animation_actor-lifetime.js @@ -55,7 +55,9 @@ add_task(async function setup() { async function assertNumberOfAnimationActors(expected, message) { const actors = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[animations.actorID]], function(actorID) { + gBrowser.selectedBrowser, + [[animations.actorID]], + function(actorID) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); diff --git a/devtools/server/tests/browser/browser_inspector-anonymous.js b/devtools/server/tests/browser/browser_inspector-anonymous.js index 4efd3467e6d4..2bdb978dd059 100644 --- a/devtools/server/tests/browser/browser_inspector-anonymous.js +++ b/devtools/server/tests/browser/browser_inspector-anonymous.js @@ -55,7 +55,9 @@ async function testNativeAnonymousStartingNode(walker) { info("Tests attaching an element that a walker can't see."); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[walker.actorID]], async function(actorID) { + gBrowser.selectedBrowser, + [[walker.actorID]], + async function(actorID) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); diff --git a/devtools/server/tests/browser/browser_inspector-insert.js b/devtools/server/tests/browser/browser_inspector-insert.js index 6cb49bc6377f..00a34941c36c 100644 --- a/devtools/server/tests/browser/browser_inspector-insert.js +++ b/devtools/server/tests/browser/browser_inspector-insert.js @@ -40,7 +40,9 @@ async function testRearrange(walker) { await walker.insertBefore(nodeA, longlist, nextNode); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[nextNode.actorID]], async function(actorID) { + gBrowser.selectedBrowser, + [[nextNode.actorID]], + async function(actorID) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); @@ -77,7 +79,9 @@ async function testInsertInvalidInput(walker) { // Now move it to the original location and make sure no mutation happens. await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[longlist.actorID]], async function(actorID) { + gBrowser.selectedBrowser, + [[longlist.actorID]], + async function(actorID) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); @@ -98,7 +102,9 @@ async function testInsertInvalidInput(walker) { await walker.insertBefore(nodeA, longlist, nodeA); let hasMutated = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { const state = content.hasMutated; content.hasMutated = false; return state; @@ -108,7 +114,9 @@ async function testInsertInvalidInput(walker) { await walker.insertBefore(nodeA, longlist, nextSibling); hasMutated = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { const state = content.hasMutated; content.hasMutated = false; return state; @@ -118,7 +126,9 @@ async function testInsertInvalidInput(walker) { await walker.insertBefore(nodeA, longlist); hasMutated = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { const state = content.hasMutated; content.hasMutated = false; return state; @@ -128,7 +138,9 @@ async function testInsertInvalidInput(walker) { await walker.insertBefore(nodeA, longlist); hasMutated = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { const state = content.hasMutated; content.hasMutated = false; return state; diff --git a/devtools/server/tests/browser/browser_inspector-mutations-childlist.js b/devtools/server/tests/browser/browser_inspector-mutations-childlist.js index 032896118247..bac22d77cb7d 100644 --- a/devtools/server/tests/browser/browser_inspector-mutations-childlist.js +++ b/devtools/server/tests/browser/browser_inspector-mutations-childlist.js @@ -20,7 +20,9 @@ function loadSelectors(walker, selectors) { } function doMoves(movesArg) { - return SpecialPowers.spawn(gBrowser.selectedBrowser, [movesArg], function(moves) { + return SpecialPowers.spawn(gBrowser.selectedBrowser, [movesArg], function( + moves + ) { function setParent(nodeSelector, newParentSelector) { const node = content.document.querySelector(nodeSelector); if (newParentSelector) { @@ -60,7 +62,9 @@ function mutationTest(testSpec) { // so do a dummy change to the root node to trigger // a mutation event anyway. await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[gDummySerial++]], function(serial) { + gBrowser.selectedBrowser, + [[gDummySerial++]], + function(serial) { content.document.documentElement.setAttribute("data-dummy", serial); } ); diff --git a/devtools/server/tests/browser/browser_inspector-remove.js b/devtools/server/tests/browser/browser_inspector-remove.js index c70cf6136101..89949da66e23 100644 --- a/devtools/server/tests/browser/browser_inspector-remove.js +++ b/devtools/server/tests/browser/browser_inspector-remove.js @@ -55,7 +55,9 @@ add_task(async function testRemoveSubtree() { const siblings = await walker.removeNode(longlist); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[siblings.previousSibling.actorID, siblings.nextSibling.actorID]], function([previousActorID, nextActorID]) { + gBrowser.selectedBrowser, + [[siblings.previousSibling.actorID, siblings.nextSibling.actorID]], + function([previousActorID, nextActorID]) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); diff --git a/devtools/server/tests/browser/browser_inspector-search.js b/devtools/server/tests/browser/browser_inspector-search.js index c081f5b8e11b..bcd6f17270c4 100644 --- a/devtools/server/tests/browser/browser_inspector-search.js +++ b/devtools/server/tests/browser/browser_inspector-search.js @@ -19,7 +19,9 @@ add_task(async function() { ); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[walker.actorID]], async function(actorID) { + gBrowser.selectedBrowser, + [[walker.actorID]], + async function(actorID) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); diff --git a/devtools/server/tests/browser/browser_inspector-traversal.js b/devtools/server/tests/browser/browser_inspector-traversal.js index 3722c93f9043..96630f944c8c 100644 --- a/devtools/server/tests/browser/browser_inspector-traversal.js +++ b/devtools/server/tests/browser/browser_inspector-traversal.js @@ -36,7 +36,9 @@ add_task(async function testInnerHTML() { const longstring = await walker.innerHTML(docElement); const innerHTML = await longstring.string(); const actualInnerHTML = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { return content.document.documentElement.innerHTML; } ); @@ -52,7 +54,9 @@ add_task(async function testOuterHTML() { const longstring = await walker.outerHTML(docElement); const outerHTML = await longstring.string(); const actualOuterHTML = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { return content.document.documentElement.outerHTML; } ); @@ -276,7 +280,9 @@ add_task(async function testLongValue() { }); const longstringText = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); @@ -308,7 +314,9 @@ add_task(async function testShortValue() { MAIN_DOMAIN + "inspector-traversal-data.html" ); const shortstringText = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { return content.document.getElementById("shortstring").firstChild .nodeValue; } diff --git a/devtools/server/tests/browser/browser_memory_allocations_01.js b/devtools/server/tests/browser/browser_memory_allocations_01.js index 2952aecf6cfe..6a932dd94b66 100644 --- a/devtools/server/tests/browser/browser_memory_allocations_01.js +++ b/devtools/server/tests/browser/browser_memory_allocations_01.js @@ -14,7 +14,9 @@ add_task(async function() { // Allocate some objects. const [line1, line2, line3] = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { // Use eval to ensure allocating the object in the page's compartment return content.eval( "(" + diff --git a/devtools/server/tests/browser/browser_storage_dynamic_windows.js b/devtools/server/tests/browser/browser_storage_dynamic_windows.js index f4c49191e085..0fdc0193b6e5 100644 --- a/devtools/server/tests/browser/browser_storage_dynamic_windows.js +++ b/devtools/server/tests/browser/browser_storage_dynamic_windows.js @@ -138,7 +138,9 @@ async function testAddIframe(front) { const update = front.once("stores-update"); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [ALT_DOMAIN_SECURED], secured => { + gBrowser.selectedBrowser, + [ALT_DOMAIN_SECURED], + secured => { const doc = content.document; const iframe = doc.createElement("iframe"); diff --git a/devtools/server/tests/browser/browser_storage_updates.js b/devtools/server/tests/browser/browser_storage_updates.js index bb0f90f6e1b8..83f3343ee590 100644 --- a/devtools/server/tests/browser/browser_storage_updates.js +++ b/devtools/server/tests/browser/browser_storage_updates.js @@ -255,7 +255,9 @@ async function addCookie(name, value) { info(`addCookie("${name}", "${value}")`); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[name, value]], ([iName, iValue]) => { + gBrowser.selectedBrowser, + [[name, value]], + ([iName, iValue]) => { content.wrappedJSObject.window.addCookie(iName, iValue); } ); @@ -273,7 +275,9 @@ async function localStorageSetItem(name, value) { info(`localStorageSetItem("${name}", "${value}")`); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[name, value]], ([iName, iValue]) => { + gBrowser.selectedBrowser, + [[name, value]], + ([iName, iValue]) => { content.window.localStorage.setItem(iName, iValue); } ); @@ -291,7 +295,9 @@ async function sessionStorageSetItem(name, value) { info(`sessionStorageSetItem("${name}", "${value}")`); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [[name, value]], ([iName, iValue]) => { + gBrowser.selectedBrowser, + [[name, value]], + ([iName, iValue]) => { content.window.sessionStorage.setItem(iName, iValue); } ); diff --git a/devtools/server/tests/browser/inspector-helpers.js b/devtools/server/tests/browser/inspector-helpers.js index 32745abaf3b7..2fba82908977 100644 --- a/devtools/server/tests/browser/inspector-helpers.js +++ b/devtools/server/tests/browser/inspector-helpers.js @@ -10,7 +10,9 @@ function serverOwnershipTree(walkerArg) { return SpecialPowers.spawn( - gBrowser.selectedBrowser, [[walkerArg.actorID]], function(actorID) { + gBrowser.selectedBrowser, + [[walkerArg.actorID]], + function(actorID) { const { require } = ChromeUtils.import( "resource://devtools/shared/Loader.jsm" ); diff --git a/docshell/test/browser/browser_browsingContext-02.js b/docshell/test/browser/browser_browsingContext-02.js index 34a3fedd7397..12d4d6d71a2f 100644 --- a/docshell/test/browser/browser_browsingContext-02.js +++ b/docshell/test/browser/browser_browsingContext-02.js @@ -29,7 +29,9 @@ add_task(async function() { true ); await SpecialPowers.spawn( - browser, [{ base1: BASE1, base2: BASE2 }], async function({ base1, base2 }) { + browser, + [{ base1: BASE1, base2: BASE2 }], + async function({ base1, base2 }) { let top = content; top.name = "top"; top.location.href += "#top"; diff --git a/docshell/test/browser/browser_bug670318.js b/docshell/test/browser/browser_bug670318.js index 1e48e374a636..1dc14b518416 100644 --- a/docshell/test/browser/browser_bug670318.js +++ b/docshell/test/browser/browser_bug670318.js @@ -32,7 +32,11 @@ add_task(async function test() { docShell.chromeEventHandler.addEventListener( "load", function onLoad() { - docShell.chromeEventHandler.removeEventListener("load", onLoad, true); + docShell.chromeEventHandler.removeEventListener( + "load", + onLoad, + true + ); Assert.ok( history.index < history.count, diff --git a/docshell/test/browser/browser_cross_process_csp_inheritance.js b/docshell/test/browser/browser_cross_process_csp_inheritance.js index 4ed9a7f16614..d9a4fa5fdd6a 100644 --- a/docshell/test/browser/browser_cross_process_csp_inheritance.js +++ b/docshell/test/browser/browser_cross_process_csp_inheritance.js @@ -35,7 +35,9 @@ function verifyResult( aFissionEnabled ) { return SpecialPowers.spawn( - aBrowser, [{ aTestName, aDataURI, aPID, aSamePID, aFissionEnabled }], async function({ aTestName, aDataURI, aPID, aSamePID, aFissionEnabled }) { + aBrowser, + [{ aTestName, aDataURI, aPID, aSamePID, aFissionEnabled }], + async function({ aTestName, aDataURI, aPID, aSamePID, aFissionEnabled }) { // sanity, to make sure the correct URI was loaded let channel = content.docShell.currentDocumentChannel; is( diff --git a/docshell/test/browser/browser_csp_uir.js b/docshell/test/browser/browser_csp_uir.js index 9b132996fbf5..177b2c781c7a 100644 --- a/docshell/test/browser/browser_csp_uir.js +++ b/docshell/test/browser/browser_csp_uir.js @@ -9,13 +9,14 @@ const RESULT_URI = TEST_PATH.replace("http://", "https://") + "file_csp_uir_dummy.html"; function verifyCSP(aTestName, aBrowser, aResultURI) { - return SpecialPowers.spawn(aBrowser, [{ aTestName, aResultURI }], async function({ - aTestName, - aResultURI, - }) { - let channel = content.docShell.currentDocumentChannel; - is(channel.URI.asciiSpec, aResultURI, "testing CSP for " + aTestName); - }); + return SpecialPowers.spawn( + aBrowser, + [{ aTestName, aResultURI }], + async function({ aTestName, aResultURI }) { + let channel = content.docShell.currentDocumentChannel; + is(channel.URI.asciiSpec, aResultURI, "testing CSP for " + aTestName); + } + ); } add_task(async function test_csp_inheritance_regular_click() { diff --git a/docshell/test/browser/browser_dataURI_unique_opaque_origin.js b/docshell/test/browser/browser_dataURI_unique_opaque_origin.js index 24c8d0d4693a..0fa7002f2952 100644 --- a/docshell/test/browser/browser_dataURI_unique_opaque_origin.js +++ b/docshell/test/browser/browser_dataURI_unique_opaque_origin.js @@ -17,19 +17,21 @@ add_task(async function test_dataURI_unique_opaque_origin() { BrowserTestUtils.loadURI(browser, "data:text/html,hi"); await BrowserTestUtils.browserLoaded(browser); - await SpecialPowers.spawn(browser, [{ principal: pagePrincipal }], async function( - args - ) { - info("data URI principal: " + content.document.nodePrincipal.origin); - Assert.ok( - content.document.nodePrincipal.isNullPrincipal, - "data: URI should have NullPrincipal." - ); - Assert.ok( - !content.document.nodePrincipal.equals(args.principal), - "data: URI should have unique opaque origin." - ); - }); + await SpecialPowers.spawn( + browser, + [{ principal: pagePrincipal }], + async function(args) { + info("data URI principal: " + content.document.nodePrincipal.origin); + Assert.ok( + content.document.nodePrincipal.isNullPrincipal, + "data: URI should have NullPrincipal." + ); + Assert.ok( + !content.document.nodePrincipal.equals(args.principal), + "data: URI should have unique opaque origin." + ); + } + ); gBrowser.removeTab(tab); }); diff --git a/docshell/test/browser/browser_data_load_inherit_csp.js b/docshell/test/browser/browser_data_load_inherit_csp.js index 159ad23111ae..653956367e75 100644 --- a/docshell/test/browser/browser_data_load_inherit_csp.js +++ b/docshell/test/browser/browser_data_load_inherit_csp.js @@ -15,19 +15,24 @@ function setDataHrefOnLink(aBrowser, aDataURI) { } function verifyCSP(aTestName, aBrowser, aDataURI) { - return SpecialPowers.spawn(aBrowser, [{ aTestName, aDataURI }], async function({ - aTestName, - aDataURI, - }) { - let channel = content.docShell.currentDocumentChannel; - is(channel.URI.spec, aDataURI, "testing CSP for " + aTestName); - let cspJSON = content.document.cspJSON; - let cspOBJ = JSON.parse(cspJSON); - let policies = cspOBJ["csp-policies"]; - is(policies.length, 1, "should be one policy"); - let policy = policies[0]; - is(policy["script-src"], "'unsafe-inline'", "script-src directive matches"); - }); + return SpecialPowers.spawn( + aBrowser, + [{ aTestName, aDataURI }], + async function({ aTestName, aDataURI }) { + let channel = content.docShell.currentDocumentChannel; + is(channel.URI.spec, aDataURI, "testing CSP for " + aTestName); + let cspJSON = content.document.cspJSON; + let cspOBJ = JSON.parse(cspJSON); + let policies = cspOBJ["csp-policies"]; + is(policies.length, 1, "should be one policy"); + let policy = policies[0]; + is( + policy["script-src"], + "'unsafe-inline'", + "script-src directive matches" + ); + } + ); } add_task(async function setup() { diff --git a/docshell/test/browser/browser_multiple_pushState.js b/docshell/test/browser/browser_multiple_pushState.js index 0bd22bec344f..92587b656720 100644 --- a/docshell/test/browser/browser_multiple_pushState.js +++ b/docshell/test/browser/browser_multiple_pushState.js @@ -9,7 +9,9 @@ add_task(async function test_multiple_pushState() { const kExpected = "http://example.org/bar/ABC/DEF?key=baz"; let contentLocation = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { return content.document.location.href; } ); diff --git a/docshell/test/browser/browser_tab_replace_while_loading.js b/docshell/test/browser/browser_tab_replace_while_loading.js index f84bb1659ad5..e1b88334ffbc 100644 --- a/docshell/test/browser/browser_tab_replace_while_loading.js +++ b/docshell/test/browser/browser_tab_replace_while_loading.js @@ -57,11 +57,13 @@ add_task(async function test_detach_loading_page() { info("Wait for content document to be created"); await BrowserTestUtils.waitForCondition(async function() { - return SpecialPowers.spawn(slowLoadingTab.linkedBrowser, [URL], async function( - url - ) { - return content.document.documentURI == url; - }); + return SpecialPowers.spawn( + slowLoadingTab.linkedBrowser, + [URL], + async function(url) { + return content.document.documentURI == url; + } + ); }); info("Detaching tab"); diff --git a/docshell/test/browser/browser_uriFixupAlternateRedirects.js b/docshell/test/browser/browser_uriFixupAlternateRedirects.js index 42c0235204ea..693097b65644 100644 --- a/docshell/test/browser/browser_uriFixupAlternateRedirects.js +++ b/docshell/test/browser/browser_uriFixupAlternateRedirects.js @@ -34,7 +34,9 @@ add_task(async function() { EventUtils.synthesizeKey("KEY_Enter"); await errorPageLoaded; let [contentURL, originalURL] = await SpecialPowers.spawn( - tab.linkedBrowser, [], () => { + tab.linkedBrowser, + [], + () => { return [ content.document.documentURI, content.document.mozDocumentURIIfNotForErrorPages.spec, diff --git a/docshell/test/navigation/browser_bug343515.js b/docshell/test/navigation/browser_bug343515.js index f24dd442f2e3..7c52aaad951d 100644 --- a/docshell/test/navigation/browser_bug343515.js +++ b/docshell/test/navigation/browser_bug343515.js @@ -222,7 +222,10 @@ add_task(async function() { async function checkBrowser(browser, outerTabNum, outerActive) { let data = { tabNum: outerTabNum, active: outerActive }; - await SpecialPowers.spawn(browser, [data], async function({ tabNum, active }) { + await SpecialPowers.spawn(browser, [data], async function({ + tabNum, + active, + }) { function isActive(aWindow) { var docshell = aWindow.docShell; return docshell.isActive; diff --git a/dom/base/test/browser_bug1303838.js b/dom/base/test/browser_bug1303838.js index c03ac840fee0..ca6893129e2f 100644 --- a/dom/base/test/browser_bug1303838.js +++ b/dom/base/test/browser_bug1303838.js @@ -253,7 +253,9 @@ function clickLink( ); promises.push( SpecialPowers.spawn( - browser, [[isFrame, linkId]], ([contentIsFrame, contentLinkId]) => { + browser, + [[isFrame, linkId]], + ([contentIsFrame, contentLinkId]) => { let doc = content.document; if (contentIsFrame) { let frame = content.document.getElementById("frame"); diff --git a/dom/base/test/browser_timeout_throttling_with_audio_playback.js b/dom/base/test/browser_timeout_throttling_with_audio_playback.js index b1bc0859e36d..6707acc11537 100644 --- a/dom/base/test/browser_timeout_throttling_with_audio_playback.js +++ b/dom/base/test/browser_timeout_throttling_with_audio_playback.js @@ -43,7 +43,9 @@ async function runTest(url) { // Put the tab in the background. await BrowserTestUtils.switchTab(gBrowser, currentTab); - let timeout = await SpecialPowers.spawn(newBrowser, [kDelay], function(delay) { + let timeout = await SpecialPowers.spawn(newBrowser, [kDelay], function( + delay + ) { return new Promise(resolve => { let before = new Date(); content.window.setTimeout(function() { diff --git a/dom/base/test/browser_use_counters.js b/dom/base/test/browser_use_counters.js index b9e85d95048c..bc15283e6730 100644 --- a/dom/base/test/browser_use_counters.js +++ b/dom/base/test/browser_use_counters.js @@ -28,7 +28,9 @@ add_task(async function test_initialize() { }); gOldContentCanRecord = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], function() { + gBrowser.selectedBrowser, + [], + function() { let telemetry = Cc["@mozilla.org/base/telemetry;1"].getService( Ci.nsITelemetry ); @@ -138,7 +140,9 @@ add_task(async function() { Telemetry.canRecordExtended = gOldParentCanRecord; await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ oldCanRecord: gOldContentCanRecord }], async function(arg) { + gBrowser.selectedBrowser, + [{ oldCanRecord: gOldContentCanRecord }], + async function(arg) { await new Promise(resolve => { let telemetry = Cc["@mozilla.org/base/telemetry;1"].getService( Ci.nsITelemetry @@ -203,7 +207,9 @@ var check_use_counter_iframe = async function( await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); // Inject our desired file into the iframe of the newly-loaded page. - await SpecialPowers.spawn(gBrowser.selectedBrowser, [{ file }], function(opts) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [{ file }], function( + opts + ) { let iframe = content.document.getElementById("content"); iframe.src = opts.file; @@ -275,20 +281,22 @@ var check_use_counter_img = async function(file, use_counter_middlefix) { await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser); // Inject our desired file into the img of the newly-loaded page. - await SpecialPowers.spawn(gBrowser.selectedBrowser, [{ file }], async function( - opts - ) { - let img = content.document.getElementById("display"); - img.src = opts.file; + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ file }], + async function(opts) { + let img = content.document.getElementById("display"); + img.src = opts.file; - return new Promise(resolve => { - let listener = event => { - img.removeEventListener("load", listener, true); - resolve(); - }; - img.addEventListener("load", listener, true); - }); - }); + return new Promise(resolve => { + let listener = event => { + img.removeEventListener("load", listener, true); + resolve(); + }; + img.addEventListener("load", listener, true); + }); + } + ); // Tear down the page. let tabClosed = BrowserTestUtils.waitForTabClosing(newTab); diff --git a/dom/file/ipc/tests/browser_ipcBlob.js b/dom/file/ipc/tests/browser_ipcBlob.js index c3a0f69cf2fb..ee99131d411e 100644 --- a/dom/file/ipc/tests/browser_ipcBlob.js +++ b/dom/file/ipc/tests/browser_ipcBlob.js @@ -163,7 +163,9 @@ add_task(async function test_CtoPtoC_bc_small() { let tab2 = await BrowserTestUtils.openNewForegroundTab(gBrowser, BASE_URI); let browser2 = gBrowser.getBrowserForTab(tab2); - let status = await SpecialPowers.spawn(browser2, [blobURL], function(blobURL) { + let status = await SpecialPowers.spawn(browser2, [blobURL], function( + blobURL + ) { return new Promise(resolve => { var xhr = new content.XMLHttpRequest(); xhr.open("GET", blobURL); diff --git a/dom/html/test/browser_DOMDocElementInserted.js b/dom/html/test/browser_DOMDocElementInserted.js index b78d5ce36a7a..caef6aaa264d 100644 --- a/dom/html/test/browser_DOMDocElementInserted.js +++ b/dom/html/test/browser_DOMDocElementInserted.js @@ -10,10 +10,18 @@ add_task(async function() { let deferred = PromiseUtils.defer(); let listener = event => { - docShell.chromeEventHandler.removeEventListener("DOMDocElementInserted", listener, true); + docShell.chromeEventHandler.removeEventListener( + "DOMDocElementInserted", + listener, + true + ); deferred.resolve(event.target.documentURIObject.spec); }; - docShell.chromeEventHandler.addEventListener("DOMDocElementInserted", listener, true); + docShell.chromeEventHandler.addEventListener( + "DOMDocElementInserted", + listener, + true + ); return deferred.promise; }); diff --git a/dom/html/test/browser_content_contextmenu_userinput.js b/dom/html/test/browser_content_contextmenu_userinput.js index 3b12827865f3..187384109a96 100644 --- a/dom/html/test/browser_content_contextmenu_userinput.js +++ b/dom/html/test/browser_content_contextmenu_userinput.js @@ -46,7 +46,9 @@ add_task(async function() { ); let promiseCtxMenuClick = SpecialPowers.spawn( - aBrowser, [], async function() { + aBrowser, + [], + async function() { await new Promise(resolve => { let windowUtils = content.windowUtils; let menuitem = content.document.getElementById("menuitem"); diff --git a/dom/html/test/browser_form_post_from_file_to_http.js b/dom/html/test/browser_form_post_from_file_to_http.js index 76dae2556c70..c835a3f2a0c6 100644 --- a/dom/html/test/browser_form_post_from_file_to_http.js +++ b/dom/html/test/browser_form_post_from_file_to_http.js @@ -35,7 +35,9 @@ add_task(async function() { ); /* eslint-disable no-shadow */ await SpecialPowers.spawn( - fileBrowser, [[TEST_HTTP_POST, filePaths]], ([actionUri, filePaths]) => { + fileBrowser, + [[TEST_HTTP_POST, filePaths]], + ([actionUri, filePaths]) => { Cu.importGlobalProperties(["File"]); let doc = content.document; diff --git a/dom/html/test/browser_submission_flush.js b/dom/html/test/browser_submission_flush.js index 5137310c7bed..53418a0edb62 100644 --- a/dom/html/test/browser_submission_flush.js +++ b/dom/html/test/browser_submission_flush.js @@ -25,7 +25,9 @@ async function runTest(aTestActions) { /* eslint-disable no-shadow */ let frame_url = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ kFormId, kFrameId, kSubmitButtonId, aTestActions }], async function({ kFormId, kFrameId, kSubmitButtonId, aTestActions }) { + gBrowser.selectedBrowser, + [{ kFormId, kFrameId, kSubmitButtonId, aTestActions }], + async function({ kFormId, kFrameId, kSubmitButtonId, aTestActions }) { let form = content.document.getElementById(kFormId); form.addEventListener( diff --git a/dom/html/test/browser_targetBlankNoOpener.js b/dom/html/test/browser_targetBlankNoOpener.js index dbb0ca37a99d..1647df0be210 100644 --- a/dom/html/test/browser_targetBlankNoOpener.js +++ b/dom/html/test/browser_targetBlankNoOpener.js @@ -4,7 +4,9 @@ async function checkOpener(browser, elm, name, rel) { let p = BrowserTestUtils.waitForNewTab(gBrowser, null, true, true); await SpecialPowers.spawn( - browser, [{ url: TEST_URL, name, rel, elm }], async obj => { + browser, + [{ url: TEST_URL, name, rel, elm }], + async obj => { let element; if (obj.elm == "anchor") { @@ -38,7 +40,9 @@ async function checkOpener(browser, elm, name, rel) { let newBrowser = gBrowser.getBrowserForTab(newTab); let hasOpener = await SpecialPowers.spawn( - newTab.linkedBrowser, [], _ => !!content.window.opener + newTab.linkedBrowser, + [], + _ => !!content.window.opener ); BrowserTestUtils.removeTab(newTab); diff --git a/dom/indexedDB/test/browser_private_idb.js b/dom/indexedDB/test/browser_private_idb.js index dbf40e0d359c..b97e3c48f835 100644 --- a/dom/indexedDB/test/browser_private_idb.js +++ b/dom/indexedDB/test/browser_private_idb.js @@ -112,19 +112,27 @@ function checkTabWindowIDB(tab) { async function checkTabDedicatedWorkerIDB(tab) { return SpecialPowers.spawn( - tab.linkedBrowser, [{ - srcBlob: workerScriptBlob, - workerType: "dedicated", - }], workerCheckDeployer + tab.linkedBrowser, + [ + { + srcBlob: workerScriptBlob, + workerType: "dedicated", + }, + ], + workerCheckDeployer ); } async function checkTabSharedWorkerIDB(tab) { return SpecialPowers.spawn( - tab.linkedBrowser, [{ - srcBlob: workerScriptBlob, - workerType: "shared", - }], workerCheckDeployer + tab.linkedBrowser, + [ + { + srcBlob: workerScriptBlob, + workerType: "shared", + }, + ], + workerCheckDeployer ); } diff --git a/dom/ipc/tests/browser_cancel_content_js.js b/dom/ipc/tests/browser_cancel_content_js.js index 35f2b9bc315b..a44c9cef4947 100644 --- a/dom/ipc/tests/browser_cancel_content_js.js +++ b/dom/ipc/tests/browser_cancel_content_js.js @@ -25,11 +25,15 @@ 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 = SpecialPowers.spawn( + tab.linkedBrowser, + [], + async function() { + return new Promise(resolve => { + content.window.addEventListener("LongLoopEnded", resolve); + }); + } + ); // Wait for the test page's long-running JS loop to start; it happens ~500ms // after load. diff --git a/dom/notification/test/browser/browser_permission_dismiss.js b/dom/notification/test/browser/browser_permission_dismiss.js index 3f6edb8cbe1d..e5a95fb3bd6f 100644 --- a/dom/notification/test/browser/browser_permission_dismiss.js +++ b/dom/notification/test/browser/browser_permission_dismiss.js @@ -58,9 +58,13 @@ function tabWithRequest(task, permission) { }, async function(browser) { let requestPromise = SpecialPowers.spawn( - browser, [{ - permission, - }], async function({ permission }) { + browser, + [ + { + permission, + }, + ], + async function({ permission }) { function requestCallback(perm) { is( perm, diff --git a/dom/plugins/test/mochitest/browser_bug1196539.js b/dom/plugins/test/mochitest/browser_bug1196539.js index f39b879ee5d6..03d83be0c7bd 100644 --- a/dom/plugins/test/mochitest/browser_bug1196539.js +++ b/dom/plugins/test/mochitest/browser_bug1196539.js @@ -41,7 +41,9 @@ add_task(async function() { ); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !!plugin; @@ -50,7 +52,9 @@ add_task(async function() { is(result, true, "plugin is loaded"); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -74,7 +78,9 @@ add_task(async function() { await waitForMs(100); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -84,7 +90,9 @@ add_task(async function() { // check for good paint count result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).getPaintCount(); @@ -109,7 +117,9 @@ add_task(async function() { // check for no paint count result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).getPaintCount(); @@ -118,7 +128,9 @@ add_task(async function() { is(result, 0, "no paints, this is correct."); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -140,7 +152,9 @@ add_task(async function() { // check paint count result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).getPaintCount(); diff --git a/dom/plugins/test/mochitest/browser_pluginscroll.js b/dom/plugins/test/mochitest/browser_pluginscroll.js index df275894983e..b8384a4e762a 100644 --- a/dom/plugins/test/mochitest/browser_pluginscroll.js +++ b/dom/plugins/test/mochitest/browser_pluginscroll.js @@ -75,7 +75,9 @@ add_task(async function() { ); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !!plugin; @@ -84,7 +86,9 @@ add_task(async function() { is(result, true, "plugin is loaded"); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -114,7 +118,9 @@ add_task(async function() { await waitScrollStart(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -125,7 +131,9 @@ add_task(async function() { await waitScrollFinish(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -161,7 +169,9 @@ add_task(async function() { ); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return !!plugin; @@ -170,7 +180,9 @@ add_task(async function() { is(result, true, "plugin is loaded"); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -200,7 +212,9 @@ add_task(async function() { await waitScrollStart(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -211,7 +225,9 @@ add_task(async function() { await waitScrollFinish(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -244,7 +260,9 @@ add_task(async function() { ); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !!plugin; @@ -253,7 +271,9 @@ add_task(async function() { is(result, true, "plugin is loaded"); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -266,7 +286,9 @@ add_task(async function() { await waitScrollStart(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -277,7 +299,9 @@ add_task(async function() { await waitScrollFinish(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -290,7 +314,9 @@ add_task(async function() { await waitScrollFinish(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -321,7 +347,9 @@ add_task(async function() { ); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return !!plugin; @@ -330,7 +358,9 @@ add_task(async function() { is(result, true, "plugin is loaded"); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -343,7 +373,9 @@ add_task(async function() { await waitScrollStart(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -354,7 +386,9 @@ add_task(async function() { await waitScrollFinish(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); @@ -367,7 +401,9 @@ add_task(async function() { await waitScrollFinish(gBrowser.selectedBrowser); result = await SpecialPowers.spawn( - pluginTab.linkedBrowser, [], async function() { + pluginTab.linkedBrowser, + [], + async function() { let doc = content.document.getElementById("subframe").contentDocument; let plugin = doc.getElementById("testplugin"); return XPCNativeWrapper.unwrap(plugin).nativeWidgetIsVisible(); diff --git a/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js b/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js index 6f54d44fc997..c6b7e10796f8 100644 --- a/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js +++ b/dom/plugins/test/mochitest/browser_tabswitchbetweenplugins.js @@ -49,7 +49,9 @@ add_task(async function() { ); result = await SpecialPowers.spawn( - pluginTab1.linkedBrowser, [], async function() { + pluginTab1.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !!plugin; @@ -58,7 +60,9 @@ add_task(async function() { is(result, true, "plugin1 is loaded"); result = await SpecialPowers.spawn( - pluginTab2.linkedBrowser, [], async function() { + pluginTab2.linkedBrowser, + [], + async function() { let doc = content.document; let plugin = doc.getElementById("testplugin"); return !!plugin; diff --git a/dom/reporting/tests/browser_cleanup.js b/dom/reporting/tests/browser_cleanup.js index d1d95d466d34..ab67a73a5fd6 100644 --- a/dom/reporting/tests/browser_cleanup.js +++ b/dom/reporting/tests/browser_cleanup.js @@ -8,7 +8,9 @@ const TEST_SJS = TEST_DOMAIN + TEST_PATH + "delivering.sjs"; async function storeReportingHeader(browser, extraParams = "") { await SpecialPowers.spawn( - browser, [{ url: TEST_SJS, extraParams }], async obj => { + browser, + [{ url: TEST_SJS, extraParams }], + async obj => { await content .fetch( obj.url + diff --git a/dom/security/test/general/browser_test_toplevel_data_navigations.js b/dom/security/test/general/browser_test_toplevel_data_navigations.js index da9f1130c097..9219047eac41 100644 --- a/dom/security/test/general/browser_test_toplevel_data_navigations.js +++ b/dom/security/test/general/browser_test_toplevel_data_navigations.js @@ -16,7 +16,11 @@ add_task(async function test_nav_data_uri() { set: [["security.data_uri.block_toplevel_data_uri_navigations", true]], }); await BrowserTestUtils.withNewTab(kDataURI, async function(browser) { - await SpecialPowers.spawn(gBrowser.selectedBrowser, [{kDataBody}], async function({kDataBody}) { // eslint-disable-line + await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [{ kDataBody }], + async function({ kDataBody }) { + // eslint-disable-line is( content.document.body.innerHTML, kDataBody, diff --git a/dom/serviceworkers/test/browser_antitracking.js b/dom/serviceworkers/test/browser_antitracking.js index 8100487c6579..d135932882bc 100644 --- a/dom/serviceworkers/test/browser_antitracking.js +++ b/dom/serviceworkers/test/browser_antitracking.js @@ -48,7 +48,9 @@ add_task(async function() { // ## Install SW info("Installing SW"); await SpecialPowers.spawn( - topTab.linkedBrowser, [{ sw: SW_REL_SW_SCRIPT }], async function({ sw }) { + topTab.linkedBrowser, + [{ sw: SW_REL_SW_SCRIPT }], + async function({ sw }) { // Waive the xray to use the content utils.js script functions. await content.wrappedJSObject.registerAndWaitForActive(sw); } @@ -75,7 +77,9 @@ add_task(async function() { // Create Iframe in the top-level page and verify its state. let { controlled } = await SpecialPowers.spawn( - topTab.linkedBrowser, [{ url: SW_IFRAME_PAGE }], async function({ url }) { + topTab.linkedBrowser, + [{ url: SW_IFRAME_PAGE }], + async function({ url }) { const payload = await content.wrappedJSObject.createIframeAndWaitForMessage( url ); diff --git a/dom/serviceworkers/test/browser_antitracking_subiframes.js b/dom/serviceworkers/test/browser_antitracking_subiframes.js index 22c8aac26e1d..591c69d26a07 100644 --- a/dom/serviceworkers/test/browser_antitracking_subiframes.js +++ b/dom/serviceworkers/test/browser_antitracking_subiframes.js @@ -43,7 +43,9 @@ add_task(async function() { // Install SW info("Registering a SW: " + SW_REL_SW_SCRIPT); await SpecialPowers.spawn( - topTab.linkedBrowser, [{ sw: SW_REL_SW_SCRIPT }], async function({ sw }) { + topTab.linkedBrowser, + [{ sw: SW_REL_SW_SCRIPT }], + async function({ sw }) { // Waive the xray to use the content utils.js script functions. await content.wrappedJSObject.registerAndWaitForActive(sw); // User interaction @@ -61,7 +63,9 @@ add_task(async function() { // Create Iframe in the top-level page and verify its state. info("Creating iframe and checking if controlled"); let { controlled } = await SpecialPowers.spawn( - topTab.linkedBrowser, [{ url: SW_IFRAME_PAGE }], async function({ url }) { + topTab.linkedBrowser, + [{ url: SW_IFRAME_PAGE }], + async function({ url }) { content.document.userInteractionForTesting(); const payload = await content.wrappedJSObject.createIframeAndWaitForMessage( url @@ -75,7 +79,9 @@ add_task(async function() { // Create a nested Iframe. info("Creating nested-iframe and checking if controlled"); let { nested_controlled } = await SpecialPowers.spawn( - topTab.linkedBrowser, [{ url: SW_IFRAME_PAGE }], async function({ url }) { + topTab.linkedBrowser, + [{ url: SW_IFRAME_PAGE }], + async function({ url }) { const payload = await content.wrappedJSObject.createNestedIframeAndWaitForMessage( url ); diff --git a/dom/serviceworkers/test/browser_download_canceled.js b/dom/serviceworkers/test/browser_download_canceled.js index 50a25d392b49..25c882f834ee 100644 --- a/dom/serviceworkers/test/browser_download_canceled.js +++ b/dom/serviceworkers/test/browser_download_canceled.js @@ -91,7 +91,9 @@ async function performCanceledDownload(tab, path) { // Wait for confirmation that the stream stopped. info(`wait for the ${path} stream to close.`); /* eslint-disable no-shadow */ - const why = await SpecialPowers.spawn(tab.linkedBrowser, [path], function(path) { + const why = await SpecialPowers.spawn(tab.linkedBrowser, [path], function( + path + ) { return content.wrappedJSObject.streamClosed[path].promise; }); /* eslint-enable no-shadow */ @@ -129,7 +131,9 @@ add_task(async function interruptedDownloads() { // Wait for it to become controlled. Check that it was a promise that // resolved as expected rather than undefined by checking the return value. const controlled = await SpecialPowers.spawn( - tab.linkedBrowser, [], function() { + tab.linkedBrowser, + [], + function() { // This is a promise set up by the page during load, and we are post-load. return content.wrappedJSObject.controlled; } diff --git a/dom/serviceworkers/test/browser_navigation_process_swap.js b/dom/serviceworkers/test/browser_navigation_process_swap.js index 20c61b15c761..7800e6c4ca84 100644 --- a/dom/serviceworkers/test/browser_navigation_process_swap.js +++ b/dom/serviceworkers/test/browser_navigation_process_swap.js @@ -64,7 +64,9 @@ async function runTest() { info(`Registering Service Worker ${SW_SCRIPT_URL}`); await SpecialPowers.spawn( - tab.linkedBrowser, [{ scriptURL: SW_SCRIPT_URL }], async ({ scriptURL }) => + tab.linkedBrowser, + [{ scriptURL: SW_SCRIPT_URL }], + async ({ scriptURL }) => await content.wrappedJSObject.registerAndWaitForActive(scriptURL) ); info(`Registered and activated Service Worker ${SW_SCRIPT_URL}`); @@ -82,7 +84,9 @@ async function runTest() { info(`Dynamically creating ${FILE_URL}'s link`); await SpecialPowers.spawn( - tab.linkedBrowser, [{ href: CROSS_ORIGIN_REDIRECT_URL }], ({ href }) => { + tab.linkedBrowser, + [{ href: CROSS_ORIGIN_REDIRECT_URL }], + ({ href }) => { const { document } = content; const link = document.createElement("a"); link.href = href; @@ -121,7 +125,9 @@ async function runTest() { info("Unregistering all Service Workers"); await SpecialPowers.spawn( - tab.linkedBrowser, [], async () => await content.wrappedJSObject.unregisterAll() + tab.linkedBrowser, + [], + async () => await content.wrappedJSObject.unregisterAll() ); info("Closing tab"); diff --git a/dom/serviceworkers/test/browser_storage_permission.js b/dom/serviceworkers/test/browser_storage_permission.js index 34a3f111585c..4d9823c9e4af 100644 --- a/dom/serviceworkers/test/browser_storage_permission.js +++ b/dom/serviceworkers/test/browser_storage_permission.js @@ -25,7 +25,9 @@ add_task(async function setup() { await BrowserTestUtils.browserLoaded(browser); await SpecialPowers.spawn( - browser, [{ script: SW_SCRIPT, scope: SCOPE }], async function(opts) { + browser, + [{ script: SW_SCRIPT, scope: SCOPE }], + async function(opts) { let reg = await content.navigator.serviceWorker.register(opts.script, { scope: opts.scope, }); diff --git a/dom/serviceworkers/test/browser_storage_recovery.js b/dom/serviceworkers/test/browser_storage_recovery.js index 0641466bac42..d9e3e7314ffa 100644 --- a/dom/serviceworkers/test/browser_storage_recovery.js +++ b/dom/serviceworkers/test/browser_storage_recovery.js @@ -57,7 +57,9 @@ add_task(async function setup() { await BrowserTestUtils.browserLoaded(browser); await SpecialPowers.spawn( - browser, [{ script: SW_SCRIPT, scope: SCOPE }], async function(opts) { + browser, + [{ script: SW_SCRIPT, scope: SCOPE }], + async function(opts) { let reg = await content.navigator.serviceWorker.register(opts.script, { scope: opts.scope, }); diff --git a/dom/serviceworkers/test/browser_unregister_with_containers.js b/dom/serviceworkers/test/browser_unregister_with_containers.js index 24984707bde7..0304f70c1db7 100644 --- a/dom/serviceworkers/test/browser_unregister_with_containers.js +++ b/dom/serviceworkers/test/browser_unregister_with_containers.js @@ -7,7 +7,9 @@ const SW_SCRIPT = BASE_URI + "empty.js"; function doRegister(browser) { return SpecialPowers.spawn( - browser, [{ script: SW_SCRIPT, scope: SCOPE }], async function(opts) { + browser, + [{ script: SW_SCRIPT, scope: SCOPE }], + async function(opts) { let reg = await content.navigator.serviceWorker.register(opts.script, { scope: opts.scope, }); diff --git a/dom/tests/browser/browser_autofocus_background.js b/dom/tests/browser/browser_autofocus_background.js index b1ea4cfc998e..f31a9532cd85 100644 --- a/dom/tests/browser/browser_autofocus_background.js +++ b/dom/tests/browser/browser_autofocus_background.js @@ -22,7 +22,9 @@ add_task(async function() { for (var i = 0; i < testingList.length; ++i) { // Get active element in the tab. let tagName = await SpecialPowers.spawn( - tabs[i + 1].linkedBrowser, [], async function() { + tabs[i + 1].linkedBrowser, + [], + async function() { return content.document.activeElement.tagName; } ); diff --git a/dom/tests/browser/browser_bug1008941_dismissGeolocationHanger.js b/dom/tests/browser/browser_bug1008941_dismissGeolocationHanger.js index fdadc6e95a66..a5527bd2dbf4 100644 --- a/dom/tests/browser/browser_bug1008941_dismissGeolocationHanger.js +++ b/dom/tests/browser/browser_bug1008941_dismissGeolocationHanger.js @@ -26,7 +26,9 @@ add_task(async function testDismissHanger() { info("Clicked outside the Geolocation panel to dismiss it"); let hasLocation = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { return content.document.body.innerHTML.includes("location..."); } ); diff --git a/dom/tests/browser/browser_bug1236512.js b/dom/tests/browser/browser_bug1236512.js index 10ad1b122867..0559082ab746 100644 --- a/dom/tests/browser/browser_bug1236512.js +++ b/dom/tests/browser/browser_bug1236512.js @@ -10,7 +10,9 @@ const testPageURL = async function testContentVisibilityState(aIsHidden, aBrowser) { await SpecialPowers.spawn( - aBrowser.selectedBrowser, [aIsHidden], aExpectedResult => { + aBrowser.selectedBrowser, + [aIsHidden], + aExpectedResult => { is(content.document.hidden, aExpectedResult, "document.hidden"); is( content.document.visibilityState, @@ -22,36 +24,38 @@ async function testContentVisibilityState(aIsHidden, aBrowser) { } async function waitContentVisibilityChange(aIsHidden, aBrowser) { - await SpecialPowers.spawn(aBrowser.selectedBrowser, [aIsHidden], async function( - aExpectedResult - ) { - let visibilityState = aExpectedResult ? "hidden" : "visible"; - if ( - content.document.hidden === aExpectedResult && - content.document.visibilityState === visibilityState - ) { - ok(true, "already changed to expected visibility state"); - return; - } - - info("wait visibilitychange event"); - await ContentTaskUtils.waitForEvent( - content.document, - "visibilitychange", - true /* capture */, - aEvent => { - info( - `visibilitychange: ${content.document.hidden} ${ - content.document.visibilityState - }` - ); - return ( - content.document.hidden === aExpectedResult && - content.document.visibilityState === visibilityState - ); + await SpecialPowers.spawn( + aBrowser.selectedBrowser, + [aIsHidden], + async function(aExpectedResult) { + let visibilityState = aExpectedResult ? "hidden" : "visible"; + if ( + content.document.hidden === aExpectedResult && + content.document.visibilityState === visibilityState + ) { + ok(true, "already changed to expected visibility state"); + return; } - ); - }); + + info("wait visibilitychange event"); + await ContentTaskUtils.waitForEvent( + content.document, + "visibilitychange", + true /* capture */, + aEvent => { + info( + `visibilitychange: ${content.document.hidden} ${ + content.document.visibilityState + }` + ); + return ( + content.document.hidden === aExpectedResult && + content.document.visibilityState === visibilityState + ); + } + ); + } + ); } /** diff --git a/dom/tests/browser/browser_bug396843.js b/dom/tests/browser/browser_bug396843.js index c9a9c972f73b..917bc0559dca 100644 --- a/dom/tests/browser/browser_bug396843.js +++ b/dom/tests/browser/browser_bug396843.js @@ -316,7 +316,9 @@ async function newTabTest(location) { browser ) { await SpecialPowers.spawn( - browser, [{ location, testInDocument_: testInDocument.toSource() }], async function({ location, testInDocument_ }) { + browser, + [{ location, testInDocument_: testInDocument.toSource() }], + async function({ location, testInDocument_ }) { // eslint-disable-next-line no-eval let testInDocument = eval(`(() => (${testInDocument_}))()`); testInDocument(content.document, location); diff --git a/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js b/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js index 19dba0d725eb..0c29493b2098 100644 --- a/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js +++ b/dom/tests/browser/browser_focus_steal_from_chrome_during_mousedown.js @@ -35,7 +35,9 @@ add_task(async function test() { "Failed to move focus away from search bar: button=" + button ); - await SpecialPowers.spawn(tab.linkedBrowser, [button], async function(button) { + await SpecialPowers.spawn(tab.linkedBrowser, [button], async function( + button + ) { let fm = Services.focus; let attempts = 10; diff --git a/dom/tests/browser/browser_hasbeforeunload.js b/dom/tests/browser/browser_hasbeforeunload.js index 8046f09bfcdc..2b2b8a2e97f1 100644 --- a/dom/tests/browser/browser_hasbeforeunload.js +++ b/dom/tests/browser/browser_hasbeforeunload.js @@ -359,7 +359,9 @@ async function prepareSubframes(browser, options) { browser.reload(); await BrowserTestUtils.browserLoaded(browser); - await SpecialPowers.spawn(browser, [{ options, PAGE_URL }], async function(args) { + await SpecialPowers.spawn(browser, [{ options, PAGE_URL }], async function( + args + ) { let { options: allSubframeOptions, PAGE_URL: contentPageURL } = args; function loadBeforeUnloadHelper(doc, subframeOptions) { let subframe = doc.getElementById("subframe"); diff --git a/dom/tests/browser/browser_localStorage_e10s.js b/dom/tests/browser/browser_localStorage_e10s.js index bce8da50a7f6..04f181e13dc9 100644 --- a/dom/tests/browser/browser_localStorage_e10s.js +++ b/dom/tests/browser/browser_localStorage_e10s.js @@ -108,7 +108,9 @@ function clearOriginStorageEnsuringNoPreload() { async function verifyTabPreload(knownTab, expectStorageExists) { let storageExists = await SpecialPowers.spawn( - knownTab.tab.linkedBrowser, [HELPER_PAGE_ORIGIN], function(origin) { + knownTab.tab.linkedBrowser, + [HELPER_PAGE_ORIGIN], + function(origin) { let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( origin ); @@ -131,7 +133,9 @@ async function verifyTabPreload(knownTab, expectStorageExists) { */ async function mutateTabStorage(knownTab, mutations, sentinelValue) { await SpecialPowers.spawn( - knownTab.tab.linkedBrowser, [{ mutations, sentinelValue }], function(args) { + knownTab.tab.linkedBrowser, + [{ mutations, sentinelValue }], + function(args) { return content.wrappedJSObject.mutateStorage(Cu.cloneInto(args, content)); } ); @@ -143,11 +147,13 @@ async function mutateTabStorage(knownTab, mutations, sentinelValue) { * check and assert the recorded events. */ async function recordTabStorageEvents(knownTab, sentinelValue) { - await SpecialPowers.spawn(knownTab.tab.linkedBrowser, [sentinelValue], function( - sentinelValue - ) { - return content.wrappedJSObject.listenForStorageEvents(sentinelValue); - }); + await SpecialPowers.spawn( + knownTab.tab.linkedBrowser, + [sentinelValue], + function(sentinelValue) { + return content.wrappedJSObject.listenForStorageEvents(sentinelValue); + } + ); } /** @@ -164,7 +170,9 @@ async function recordTabStorageEvents(knownTab, sentinelValue) { */ async function verifyTabStorageState(knownTab, expectedState, maybeSentinel) { let actualState = await SpecialPowers.spawn( - knownTab.tab.linkedBrowser, [maybeSentinel], function(maybeSentinel) { + knownTab.tab.linkedBrowser, + [maybeSentinel], + function(maybeSentinel) { return content.wrappedJSObject.getStorageState(maybeSentinel); } ); @@ -190,7 +198,9 @@ async function verifyTabStorageState(knownTab, expectedState, maybeSentinel) { */ async function verifyTabStorageEvents(knownTab, expectedEvents) { let actualEvents = await SpecialPowers.spawn( - knownTab.tab.linkedBrowser, [], function() { + knownTab.tab.linkedBrowser, + [], + function() { return content.wrappedJSObject.returnAndClearStorageEvents(); } ); diff --git a/dom/tests/browser/browser_localStorage_snapshotting_e10s.js b/dom/tests/browser/browser_localStorage_snapshotting_e10s.js index 50c1d6821695..7d8aefd2a357 100644 --- a/dom/tests/browser/browser_localStorage_snapshotting_e10s.js +++ b/dom/tests/browser/browser_localStorage_snapshotting_e10s.js @@ -39,7 +39,9 @@ async function applyMutations(knownTab, mutations) { async function verifyState(knownTab, expectedState) { let actualState = await SpecialPowers.spawn( - knownTab.tab.linkedBrowser, [], function() { + knownTab.tab.linkedBrowser, + [], + function() { return content.wrappedJSObject.getState(); } ); @@ -57,7 +59,9 @@ async function verifyState(knownTab, expectedState) { async function getKeys(knownTab) { let keys = await SpecialPowers.spawn( - knownTab.tab.linkedBrowser, [], function() { + knownTab.tab.linkedBrowser, + [], + function() { return content.wrappedJSObject.getKeys(); } ); diff --git a/dom/tests/browser/browser_windowProxy_transplant.js b/dom/tests/browser/browser_windowProxy_transplant.js index 785b57a24a4d..807aad0036b3 100644 --- a/dom/tests/browser/browser_windowProxy_transplant.js +++ b/dom/tests/browser/browser_windowProxy_transplant.js @@ -38,7 +38,9 @@ add_task(async function() { info("Chrome script has loaded initial URI."); await SpecialPowers.spawn( - browser, [{ URL1, URL2, URL3 }], async ({ URL1, URL2, URL3 }) => { + browser, + [{ URL1, URL2, URL3 }], + async ({ URL1, URL2, URL3 }) => { let iframe = content.document.createElement("iframe"); content.document.body.appendChild(iframe); diff --git a/dom/tests/browser/helper_largeAllocation.js b/dom/tests/browser/helper_largeAllocation.js index 2ae55b74a917..90d1f00ac01c 100644 --- a/dom/tests/browser/helper_largeAllocation.js +++ b/dom/tests/browser/helper_largeAllocation.js @@ -187,7 +187,9 @@ async function largeAllocSuccessTests() { await BrowserTestUtils.browserLoaded(aBrowser); await SpecialPowers.spawn( - aBrowser, [], () => (content.document.location = "about:blank") + aBrowser, + [], + () => (content.document.location = "about:blank") ); await BrowserTestUtils.browserLoaded(aBrowser); diff --git a/dom/tests/mochitest/ajax/offline/browser_disableAppcache.js b/dom/tests/mochitest/ajax/offline/browser_disableAppcache.js index 81b38a3e6eb5..41465087cf9b 100644 --- a/dom/tests/mochitest/ajax/offline/browser_disableAppcache.js +++ b/dom/tests/mochitest/ajax/offline/browser_disableAppcache.js @@ -1,5 +1,4 @@ -const PATH = - "http://example.com/browser/dom/tests/mochitest/ajax/offline/"; +const PATH = "http://example.com/browser/dom/tests/mochitest/ajax/offline/"; const URL = PATH + "file_simpleManifest.html"; const MANIFEST = PATH + "file_simpleManifest.cacheManifest"; const PREF_NETWORK_PROXY = "network.proxy.type"; @@ -8,8 +7,16 @@ add_task(async function test_pref_removes_api() { await BrowserTestUtils.openNewForegroundTab(gBrowser, URL); await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async () => { // Have to use in page checking as IsSecureContextOrObjectIsFromSecureContext is true for spawn() - is(content.document.getElementById("hasAppcache").textContent, "no", "Appcache is disabled"); - is(content.document.getElementById("hasOfflineResourceList").textContent, "no", "OfflineResourceList is disabled"); + is( + content.document.getElementById("hasAppcache").textContent, + "no", + "Appcache is disabled" + ); + is( + content.document.getElementById("hasOfflineResourceList").textContent, + "no", + "OfflineResourceList is disabled" + ); }); gBrowser.removeCurrentTab(); }); diff --git a/dom/u2f/tests/browser/browser_abort_visibility.js b/dom/u2f/tests/browser/browser_abort_visibility.js index ad94e9d25ac4..1eb915fc769e 100644 --- a/dom/u2f/tests/browser/browser_abort_visibility.js +++ b/dom/u2f/tests/browser/browser_abort_visibility.js @@ -9,7 +9,9 @@ const TEST_URL = async function assertStatus(tab, expected) { let actual = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { return content.document.getElementById("status").value; } ); @@ -61,7 +63,9 @@ function startGetAssertionRequest(tab) { /* eslint-disable no-shadow */ return SpecialPowers.spawn( - tab.linkedBrowser, [[challenge, keyHandle]], async function([challenge, keyHandle]) { + tab.linkedBrowser, + [[challenge, keyHandle]], + async function([challenge, keyHandle]) { let appId = content.location.origin; let key = { version: "U2F_V2", keyHandle }; diff --git a/dom/u2f/tests/browser/browser_appid_localhost.js b/dom/u2f/tests/browser/browser_appid_localhost.js index 846872fba516..3d38f7180e50 100644 --- a/dom/u2f/tests/browser/browser_appid_localhost.js +++ b/dom/u2f/tests/browser/browser_appid_localhost.js @@ -12,7 +12,9 @@ function promiseU2FRegister(tab, app_id) { /* eslint-disable no-shadow */ return SpecialPowers.spawn( - tab.linkedBrowser, [[app_id, challenge]], async function([app_id, challenge]) { + tab.linkedBrowser, + [[app_id, challenge]], + async function([app_id, challenge]) { return new Promise(resolve => { let version = "U2F_V2"; content.u2f.register(app_id, [{ version, challenge }], [], resolve); diff --git a/dom/webauthn/tests/browser/browser_abort_visibility.js b/dom/webauthn/tests/browser/browser_abort_visibility.js index 85ed7708f927..3fb47b59cf5e 100644 --- a/dom/webauthn/tests/browser/browser_abort_visibility.js +++ b/dom/webauthn/tests/browser/browser_abort_visibility.js @@ -9,7 +9,9 @@ const TEST_URL = async function assertStatus(tab, expected) { let actual = await SpecialPowers.spawn( - tab.linkedBrowser, [], async function() { + tab.linkedBrowser, + [], + async function() { info("visbility state: " + content.document.visibilityState); info("docshell active: " + docShell.isActive); return content.document.getElementById("status").value; diff --git a/dom/webauthn/tests/browser/browser_fido_appid_extension.js b/dom/webauthn/tests/browser/browser_fido_appid_extension.js index 175fe7de508c..ceda86eb9358 100644 --- a/dom/webauthn/tests/browser/browser_fido_appid_extension.js +++ b/dom/webauthn/tests/browser/browser_fido_appid_extension.js @@ -30,19 +30,20 @@ function promiseU2FRegister(tab, app_id) { let challenge = crypto.getRandomValues(new Uint8Array(16)); challenge = bytesToBase64UrlSafe(challenge); - return SpecialPowers.spawn(tab.linkedBrowser, [[app_id, challenge]], function([ - app_id, - challenge, - ]) { - return new Promise(resolve => { - content.u2f.register( - app_id, - [{ version: "U2F_V2", challenge }], - [], - resolve - ); - }); - }).then(res => { + return SpecialPowers.spawn( + tab.linkedBrowser, + [[app_id, challenge]], + function([app_id, challenge]) { + return new Promise(resolve => { + content.u2f.register( + app_id, + [{ version: "U2F_V2", challenge }], + [], + resolve + ); + }); + } + ).then(res => { is(res.errorCode, 0, "u2f.register() succeeded"); let data = base64ToBytesUrlSafe(res.registrationData); is(data[0], 0x05, "Reserved byte is correct"); @@ -84,7 +85,9 @@ function promiseWebAuthnRegister(tab, appid) { function promiseWebAuthnSign(tab, key_handle, extensions = {}) { return SpecialPowers.spawn( - tab.linkedBrowser, [[key_handle, extensions]], ([key_handle, extensions]) => { + tab.linkedBrowser, + [[key_handle, extensions]], + ([key_handle, extensions]) => { let challenge = content.crypto.getRandomValues(new Uint8Array(16)); let credential = { diff --git a/dom/webauthn/tests/browser/browser_webauthn_prompts.js b/dom/webauthn/tests/browser/browser_webauthn_prompts.js index 4cdc83bbfe94..f0fc74c0c36a 100644 --- a/dom/webauthn/tests/browser/browser_webauthn_prompts.js +++ b/dom/webauthn/tests/browser/browser_webauthn_prompts.js @@ -52,7 +52,9 @@ function verifyDirectCertificate(attestationObject) { function promiseWebAuthnRegister(tab, attestation = "indirect") { /* eslint-disable no-shadow */ return SpecialPowers.spawn( - tab.linkedBrowser, [[attestation]], ([attestation]) => { + tab.linkedBrowser, + [[attestation]], + ([attestation]) => { const cose_alg_ECDSA_w_SHA256 = -7; let challenge = content.crypto.getRandomValues(new Uint8Array(16)); diff --git a/dom/workers/test/browser_fileURL.js b/dom/workers/test/browser_fileURL.js index 4aac29c9129c..c109e1d30f7d 100644 --- a/dom/workers/test/browser_fileURL.js +++ b/dom/workers/test/browser_fileURL.js @@ -118,19 +118,21 @@ add_task(async function() { let browser = gBrowser.getBrowserForTab(tab); await BrowserTestUtils.browserLoaded(browser); - await SpecialPowers.spawn(browser, ["http://example.org" + WORKER_URL], function( - spec - ) { - return new content.Promise((resolve, reject) => { - let w = new content.window.Worker(spec); - w.onerror = _ => { - resolve(); - }; - w.onmessage = _ => { - reject(); - }; - }); - }); + await SpecialPowers.spawn( + browser, + ["http://example.org" + WORKER_URL], + function(spec) { + return new content.Promise((resolve, reject) => { + let w = new content.window.Worker(spec); + w.onerror = _ => { + resolve(); + }; + w.onmessage = _ => { + reject(); + }; + }); + } + ); ok( true, "The worker is not loaded when the script is from different origin." @@ -149,19 +151,21 @@ add_task(async function() { let browser = gBrowser.getBrowserForTab(tab); await BrowserTestUtils.browserLoaded(browser); - await SpecialPowers.spawn(browser, ["http://example.org" + WORKER_URL], function( - spec - ) { - return new content.Promise((resolve, reject) => { - let w = new content.window.Worker(spec); - w.onerror = _ => { - resolve(); - }; - w.onmessage = _ => { - reject(); - }; - }); - }); + await SpecialPowers.spawn( + browser, + ["http://example.org" + WORKER_URL], + function(spec) { + return new content.Promise((resolve, reject) => { + let w = new content.window.Worker(spec); + w.onerror = _ => { + resolve(); + }; + w.onmessage = _ => { + reject(); + }; + }); + } + ); ok( true, "The worker is not loaded when the script is from different origin." diff --git a/js/xpconnect/tests/browser/browser_dead_object.js b/js/xpconnect/tests/browser/browser_dead_object.js index c330c7f21d5f..ce2b0ea40395 100644 --- a/js/xpconnect/tests/browser/browser_dead_object.js +++ b/js/xpconnect/tests/browser/browser_dead_object.js @@ -6,21 +6,31 @@ // For bug 773980, test that Components.utils.isDeadWrapper works as expected. add_task(async function test() { - const url = "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_deadObjectOnUnload.html"; + const url = + "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_deadObjectOnUnload.html"; let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); let browser = gBrowser.selectedBrowser; let innerWindowId = browser.innerWindowID; - let contentDocDead = await SpecialPowers.spawn(browser, [{innerWindowId}], async function(args) { - let doc = content.document; - let {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm"); - let promise = TestUtils.topicObserved("inner-window-nuked", (subject, data) => { - let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; - return id == args.innerWindowId; - }); - content.location = "http://mochi.test:8888/"; - await promise; - return Cu.isDeadWrapper(doc); - }); + let contentDocDead = await SpecialPowers.spawn( + browser, + [{ innerWindowId }], + async function(args) { + let doc = content.document; + let { TestUtils } = ChromeUtils.import( + "resource://testing-common/TestUtils.jsm" + ); + let promise = TestUtils.topicObserved( + "inner-window-nuked", + (subject, data) => { + let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; + return id == args.innerWindowId; + } + ); + content.location = "http://mochi.test:8888/"; + await promise; + return Cu.isDeadWrapper(doc); + } + ); is(contentDocDead, true, "wrapper is dead"); BrowserTestUtils.removeTab(newTab); }); diff --git a/js/xpconnect/tests/browser/browser_exception_leak.js b/js/xpconnect/tests/browser/browser_exception_leak.js index 3f8f0373dc4c..374a02bd491e 100644 --- a/js/xpconnect/tests/browser/browser_exception_leak.js +++ b/js/xpconnect/tests/browser/browser_exception_leak.js @@ -6,47 +6,68 @@ // For bug 1471989, test that an exception saved by chrome code can't leak the page. add_task(async function test() { - const url = "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_consoleStack.html"; + const url = + "http://mochi.test:8888/browser/js/xpconnect/tests/browser/browser_consoleStack.html"; let newTab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url); let browser = gBrowser.selectedBrowser; let innerWindowId = browser.innerWindowID; - let stackTraceEmpty = await SpecialPowers.spawn(browser, [{innerWindowId}], async function(args) { - let {TestUtils} = ChromeUtils.import("resource://testing-common/TestUtils.jsm"); - let {Assert} = ChromeUtils.import("resource://testing-common/Assert.jsm"); + let stackTraceEmpty = await SpecialPowers.spawn( + browser, + [{ innerWindowId }], + async function(args) { + let { TestUtils } = ChromeUtils.import( + "resource://testing-common/TestUtils.jsm" + ); + let { Assert } = ChromeUtils.import( + "resource://testing-common/Assert.jsm" + ); - const ConsoleAPIStorage = Cc["@mozilla.org/consoleAPI-storage;1"].getService(Ci.nsIConsoleAPIStorage); - let consoleEvents = ConsoleAPIStorage.getEvents(args.innerWindowId); - Assert.equal(consoleEvents.length, 1, "Should only be one console event for the window"); + const ConsoleAPIStorage = Cc[ + "@mozilla.org/consoleAPI-storage;1" + ].getService(Ci.nsIConsoleAPIStorage); + let consoleEvents = ConsoleAPIStorage.getEvents(args.innerWindowId); + Assert.equal( + consoleEvents.length, + 1, + "Should only be one console event for the window" + ); - // Intentionally hold a reference to the console event. - let leakedConsoleEvent = consoleEvents[0]; + // Intentionally hold a reference to the console event. + let leakedConsoleEvent = consoleEvents[0]; - let doc = content.document; - let promise = TestUtils.topicObserved("inner-window-nuked", (subject, data) => { - let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; - return id == args.innerWindowId; - }); - content.location = "http://mochi.test:8888/"; - await promise; + let doc = content.document; + let promise = TestUtils.topicObserved( + "inner-window-nuked", + (subject, data) => { + let id = subject.QueryInterface(Ci.nsISupportsPRUint64).data; + return id == args.innerWindowId; + } + ); + content.location = "http://mochi.test:8888/"; + await promise; - // This string should be empty. For that to happen, two things - // need to be true: - // - // a) ConsoleCallData::mStack is not null. This means that the - // stack trace was not reified before the page was nuked. If it - // was, then the correct |filename| value would be stored on the - // object. (This is not a problem, except that it stops us from - // testing the next condition.) - // - // b) ConsoleData::mStack.mStack is null. This means that the - // JSStackFrame is keeping alive the JS object in the page after - // the page was nuked, which leaks the page. - return leakedConsoleEvent.stacktrace[0].filename; - }); + // This string should be empty. For that to happen, two things + // need to be true: + // + // a) ConsoleCallData::mStack is not null. This means that the + // stack trace was not reified before the page was nuked. If it + // was, then the correct |filename| value would be stored on the + // object. (This is not a problem, except that it stops us from + // testing the next condition.) + // + // b) ConsoleData::mStack.mStack is null. This means that the + // JSStackFrame is keeping alive the JS object in the page after + // the page was nuked, which leaks the page. + return leakedConsoleEvent.stacktrace[0].filename; + } + ); - is(stackTraceEmpty, "", - "JSStackFrame shouldn't leak mStack after window nuking"); + is( + stackTraceEmpty, + "", + "JSStackFrame shouldn't leak mStack after window nuking" + ); BrowserTestUtils.removeTab(newTab); }); diff --git a/layout/base/tests/browser_onbeforeunload_only_after_interaction.js b/layout/base/tests/browser_onbeforeunload_only_after_interaction.js index fc2552374ab7..efc830ecbb03 100644 --- a/layout/base/tests/browser_onbeforeunload_only_after_interaction.js +++ b/layout/base/tests/browser_onbeforeunload_only_after_interaction.js @@ -51,9 +51,13 @@ async function openPage(shouldClick) { if (shouldClick) { await BrowserTestUtils.synthesizeMouse("body", 2, 2, {}, browser); } - let hasInteractedWith = await SpecialPowers.spawn(browser, [""], function() { - return content.document.userHasInteracted; - }); + let hasInteractedWith = await SpecialPowers.spawn( + browser, + [""], + function() { + return content.document.userHasInteracted; + } + ); is( shouldClick, hasInteractedWith, diff --git a/layout/base/tests/browser_scroll_into_view_in_out_of_process_iframe.js b/layout/base/tests/browser_scroll_into_view_in_out_of_process_iframe.js index baab4c9ce926..edf926c4ca03 100644 --- a/layout/base/tests/browser_scroll_into_view_in_out_of_process_iframe.js +++ b/layout/base/tests/browser_scroll_into_view_in_out_of_process_iframe.js @@ -23,7 +23,9 @@ add_task(async () => { { gBrowser: fissionWindow.gBrowser, url }, async browser => { await SpecialPowers.spawn( - browser, [crossOriginIframeUrl], async iframeUrl => { + browser, + [crossOriginIframeUrl], + async iframeUrl => { const iframe = content.document.getElementById("iframe"); iframe.setAttribute("src", iframeUrl); diff --git a/layout/base/tests/browser_visual_viewport_iframe.js b/layout/base/tests/browser_visual_viewport_iframe.js index b638859bb161..6474b099bc68 100644 --- a/layout/base/tests/browser_visual_viewport_iframe.js +++ b/layout/base/tests/browser_visual_viewport_iframe.js @@ -31,7 +31,9 @@ add_task(async () => { { gBrowser: fissionWindow.gBrowser, url }, async browser => { await SpecialPowers.spawn( - browser, [crossOriginIframeUrl], async iframeUrl => { + browser, + [crossOriginIframeUrl], + async iframeUrl => { const iframe = content.document.getElementById("iframe"); iframe.setAttribute("src", iframeUrl); diff --git a/netwerk/cookie/test/browser/browser_originattributes.js b/netwerk/cookie/test/browser/browser_originattributes.js index 12a9645521cc..531ee5321c75 100644 --- a/netwerk/cookie/test/browser/browser_originattributes.js +++ b/netwerk/cookie/test/browser/browser_originattributes.js @@ -45,7 +45,9 @@ add_task(async function test() { let { tab, browser } = await openTabInUserContext(TEST_URL, userContextId); await SpecialPowers.spawn( - browser, [{ names: COOKIE_NAMES, value: USER_CONTEXTS[userContextId] }], function(opts) { + browser, + [{ names: COOKIE_NAMES, value: USER_CONTEXTS[userContextId] }], + function(opts) { for (let name of opts.names) { content.document.cookie = name + "=" + opts.value; } diff --git a/netwerk/cookie/test/browser/head.js b/netwerk/cookie/test/browser/head.js index 31610110a9e9..8f7fd915b0b3 100644 --- a/netwerk/cookie/test/browser/head.js +++ b/netwerk/cookie/test/browser/head.js @@ -104,15 +104,19 @@ this.CookiePolicyHelper = { await BrowserTestUtils.browserLoaded(browser); // Let's create an iframe. - await SpecialPowers.spawn(browser, [{ url: TEST_TOP_PAGE }], async obj => { - return new content.Promise(resolve => { - let ifr = content.document.createElement("iframe"); - ifr.setAttribute("id", "iframe"); - ifr.src = obj.url; - ifr.onload = resolve; - content.document.body.appendChild(ifr); - }); - }); + await SpecialPowers.spawn( + browser, + [{ url: TEST_TOP_PAGE }], + async obj => { + return new content.Promise(resolve => { + let ifr = content.document.createElement("iframe"); + ifr.setAttribute("id", "iframe"); + ifr.src = obj.url; + ifr.onload = resolve; + content.document.body.appendChild(ifr); + }); + } + ); // Let's exec the "good" callback. info( @@ -122,7 +126,9 @@ this.CookiePolicyHelper = { config.fromPermission ); await SpecialPowers.spawn( - browser, [{ callback: goodCb.toString() }], async obj => { + browser, + [{ callback: goodCb.toString() }], + async obj => { let runnableStr = `(() => {return (${obj.callback});})();`; let runnable = eval(runnableStr); // eslint-disable-line no-eval await runnable(content); @@ -146,7 +152,9 @@ this.CookiePolicyHelper = { config.toPermission ); await SpecialPowers.spawn( - browser, [{ callback: goodCb.toString() }], async obj => { + browser, + [{ callback: goodCb.toString() }], + async obj => { let runnableStr = `(() => {return (${obj.callback});})();`; let runnable = eval(runnableStr); // eslint-disable-line no-eval await runnable(content); @@ -169,7 +177,9 @@ this.CookiePolicyHelper = { // Let's exec the "bad" callback. info("Executing the test in a new tab"); await SpecialPowers.spawn( - browser, [{ callback: badCb.toString() }], async obj => { + browser, + [{ callback: badCb.toString() }], + async obj => { let runnableStr = `(() => {return (${obj.callback});})();`; let runnable = eval(runnableStr); // eslint-disable-line no-eval await runnable(content); diff --git a/netwerk/test/browser/browser_about_cache.js b/netwerk/test/browser/browser_about_cache.js index 190a982a47f9..0957c2882c0d 100644 --- a/netwerk/test/browser/browser_about_cache.js +++ b/netwerk/test/browser/browser_about_cache.js @@ -62,7 +62,9 @@ add_task(async function() { false, expectedPageCheck ); - await SpecialPowers.spawn(tab.linkedBrowser, [kTestPage], function(kTestPage) { + await SpecialPowers.spawn(tab.linkedBrowser, [kTestPage], function( + kTestPage + ) { ok( !content.document.nodePrincipal.isSystemPrincipal, "about:cache with query params should still not have system principal" diff --git a/parser/htmlparser/tests/mochitest/browser_viewsource.js b/parser/htmlparser/tests/mochitest/browser_viewsource.js index 977ec567786b..a6842502d3c3 100644 --- a/parser/htmlparser/tests/mochitest/browser_viewsource.js +++ b/parser/htmlparser/tests/mochitest/browser_viewsource.js @@ -15,7 +15,9 @@ add_task(async function() { }); let viewSourceContentPromise = SpecialPowers.spawn( - viewSourceTab.linkedBrowser, [], async function() { + viewSourceTab.linkedBrowser, + [], + async function() { return content.document.body.textContent; } ); diff --git a/remote/test/browser/head.js b/remote/test/browser/head.js index f60f204642f4..f543800e65a7 100644 --- a/remote/test/browser/head.js +++ b/remote/test/browser/head.js @@ -173,7 +173,9 @@ async function loadURL(url) { function getContentProperty(prop) { info(`Retrieve ${prop} on the content window`); return SpecialPowers.spawn( - gBrowser.selectedBrowser, [prop], _prop => content[_prop] + gBrowser.selectedBrowser, + [prop], + _prop => content[_prop] ); } diff --git a/remote/test/browser/input/browser_dispatchMouseEvent.js b/remote/test/browser/input/browser_dispatchMouseEvent.js index 2b0fd5569eab..8f5fe3c237aa 100644 --- a/remote/test/browser/input/browser_dispatchMouseEvent.js +++ b/remote/test/browser/input/browser_dispatchMouseEvent.js @@ -21,9 +21,13 @@ add_task(async function testDispatchMouseEvent(client) { }); }); - const { x, y } = await SpecialPowers.spawn(gBrowser.selectedBrowser, [], () => { - return content.document.querySelector("div").getBoundingClientRect(); - }); + const { x, y } = await SpecialPowers.spawn( + gBrowser.selectedBrowser, + [], + () => { + return content.document.querySelector("div").getBoundingClientRect(); + } + ); await Input.dispatchMouseEvent({ type: "mousePressed", diff --git a/remote/test/browser/page/browser_captureScreenshot.js b/remote/test/browser/page/browser_captureScreenshot.js index 139dc60c7ae4..645c9e1397b5 100644 --- a/remote/test/browser/page/browser_captureScreenshot.js +++ b/remote/test/browser/page/browser_captureScreenshot.js @@ -153,7 +153,9 @@ async function getImageDetails(image) { const mimeType = getMimeType(image); return SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ mimeType, image }], async function({ mimeType, image }) { + gBrowser.selectedBrowser, + [{ mimeType, image }], + async function({ mimeType, image }) { return new Promise(resolve => { const img = new content.Image(); img.addEventListener( diff --git a/security/sandbox/test/browser_content_sandbox_fs.js b/security/sandbox/test/browser_content_sandbox_fs.js index 3bf2ef89ae35..6fd7ab2df087 100644 --- a/security/sandbox/test/browser_content_sandbox_fs.js +++ b/security/sandbox/test/browser_content_sandbox_fs.js @@ -264,7 +264,11 @@ async function createTempFile() { ok(!fileDeleted, "deleting a file in content temp is not permitted"); let path = fileInTempDir().path; - let symlinkCreated = await SpecialPowers.spawn(browser, [path], createSymlink); + let symlinkCreated = await SpecialPowers.spawn( + browser, + [path], + createSymlink + ); ok(!symlinkCreated, "created a symlink in content temp is not permitted"); } else { ok(!!fileDeleted, "deleting a file in content temp is permitted"); @@ -614,7 +618,9 @@ async function testFileAccess() { } let result = await SpecialPowers.spawn( - test.browser, [test.file.path], test.func + test.browser, + [test.file.path], + test.func ); ok( diff --git a/security/sandbox/test/browser_content_sandbox_syscalls.js b/security/sandbox/test/browser_content_sandbox_syscalls.js index aa2a9ab0f19f..7b95bb061fae 100644 --- a/security/sandbox/test/browser_content_sandbox_syscalls.js +++ b/security/sandbox/test/browser_content_sandbox_syscalls.js @@ -205,7 +205,11 @@ add_task(async function() { // open a file for writing in $HOME, this should fail let path = fileInHomeDir().path; let flags = openWriteCreateFlags(); - let fd = await SpecialPowers.spawn(browser, [{ lib, path, flags }], callOpen); + let fd = await SpecialPowers.spawn( + browser, + [{ lib, path, flags }], + callOpen + ); ok(fd < 0, "opening a file for writing in home is not permitted"); } @@ -216,7 +220,11 @@ add_task(async function() { // the file for us let path = fileInTempDir().path; let flags = openWriteCreateFlags(); - let fd = await SpecialPowers.spawn(browser, [{ lib, path, flags }], callOpen); + let fd = await SpecialPowers.spawn( + browser, + [{ lib, path, flags }], + callOpen + ); if (isMac()) { ok( fd === -1, @@ -239,16 +247,24 @@ add_task(async function() { // remove support for macOS 10.9. if (isMac() && Services.sysinfo.getProperty("version") >= "14.0.0") { let rv = await SpecialPowers.spawn( - browser, [{ lib, name: "kern.boottime" }], callSysctl + browser, + [{ lib, name: "kern.boottime" }], + callSysctl ); ok(rv == -1, "calling sysctl('kern.boottime') is not permitted"); rv = await SpecialPowers.spawn( - browser, [{ lib, name: "net.inet.ip.ttl" }], callSysctl + browser, + [{ lib, name: "net.inet.ip.ttl" }], + callSysctl ); ok(rv == -1, "calling sysctl('net.inet.ip.ttl') is not permitted"); - rv = await SpecialPowers.spawn(browser, [{ lib, name: "hw.ncpu" }], callSysctl); + rv = await SpecialPowers.spawn( + browser, + [{ lib, name: "hw.ncpu" }], + callSysctl + ); ok(rv == 0, "calling sysctl('hw.ncpu') is permitted"); } }); diff --git a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm index cf37f9e910d9..2e7658702f29 100644 --- a/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/BrowserTestUtils.jsm @@ -852,14 +852,18 @@ var BrowserTestUtils = { // We cannot use the regular BrowserTestUtils helper for waiting here, since that // would try to insert the preloaded browser, which would only break things. - await gBrowser.preloadedBrowser.ownerGlobal.SpecialPowers.spawn(gBrowser.preloadedBrowser, [], async () => { - await ContentTaskUtils.waitForCondition(() => { - return ( - this.content.document && - this.content.document.readyState == "complete" - ); - }); - }); + await gBrowser.preloadedBrowser.ownerGlobal.SpecialPowers.spawn( + gBrowser.preloadedBrowser, + [], + async () => { + await ContentTaskUtils.waitForCondition(() => { + return ( + this.content.document && + this.content.document.readyState == "complete" + ); + }); + } + ); }, /** diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index cb423451853d..735a85243cdf 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -34,25 +34,28 @@ // placebo for compat. An easy way to differentiate this from the real thing // is whether the property is read-only or not. The real |Components| property // is read-only. -window.__defineGetter__('_EU_Ci', function() { - var c = Object.getOwnPropertyDescriptor(window, 'Components'); +window.__defineGetter__("_EU_Ci", function() { + var c = Object.getOwnPropertyDescriptor(window, "Components"); return c && c.value && !c.writable ? Ci : SpecialPowers.Ci; }); -window.__defineGetter__('_EU_Cc', function() { - var c = Object.getOwnPropertyDescriptor(window, 'Components'); +window.__defineGetter__("_EU_Cc", function() { + var c = Object.getOwnPropertyDescriptor(window, "Components"); return c && c.value && !c.writable ? Cc : SpecialPowers.Cc; }); -window.__defineGetter__('_EU_Cu', function() { - var c = Object.getOwnPropertyDescriptor(window, 'Components'); +window.__defineGetter__("_EU_Cu", function() { + var c = Object.getOwnPropertyDescriptor(window, "Components"); return c && c.value && !c.writable ? Cu : SpecialPowers.Cu; }); window.__defineGetter__("_EU_OS", function() { delete this._EU_OS; try { - this._EU_OS = this._EU_Cu.import("resource://gre/modules/AppConstants.jsm", {}).platform; + this._EU_OS = this._EU_Cu.import( + "resource://gre/modules/AppConstants.jsm", + {} + ).platform; } catch (ex) { this._EU_OS = null; } @@ -121,12 +124,12 @@ function _EU_maybeWrap(o) { // Not much we can do here. return o; } - var c = Object.getOwnPropertyDescriptor(window, 'Components'); + var c = Object.getOwnPropertyDescriptor(window, "Components"); return c && c.value && !c.writable ? o : SpecialPowers.wrap(o); } function _EU_maybeUnwrap(o) { - var c = Object.getOwnPropertyDescriptor(window, 'Components'); + var c = Object.getOwnPropertyDescriptor(window, "Components"); return c && c.value && !c.writable ? o : SpecialPowers.unwrap(o); } @@ -140,23 +143,33 @@ function _EU_maybeUnwrap(o) { * sendMouseEvent({type:'click'}, 'node'); */ function getElement(id) { - return ((typeof(id) == "string") ? - document.getElementById(id) : id); -}; + return typeof id == "string" ? document.getElementById(id) : id; +} this.$ = this.getElement; function computeButton(aEvent) { - if (typeof aEvent.button != 'undefined') { + if (typeof aEvent.button != "undefined") { return aEvent.button; } - return aEvent.type == 'contextmenu' ? 2 : 0; + return aEvent.type == "contextmenu" ? 2 : 0; } function sendMouseEvent(aEvent, aTarget, aWindow) { - if (!['click', 'contextmenu', 'dblclick', 'mousedown', 'mouseup', 'mouseover', - 'mouseout'].includes(aEvent.type)) { - throw new Error("sendMouseEvent doesn't know about event type '" + aEvent.type + "'"); + if ( + ![ + "click", + "contextmenu", + "dblclick", + "mousedown", + "mouseup", + "mouseover", + "mouseout", + ].includes(aEvent.type) + ) { + throw new Error( + "sendMouseEvent doesn't know about event type '" + aEvent.type + "'" + ); } if (!aWindow) { @@ -167,31 +180,49 @@ function sendMouseEvent(aEvent, aTarget, aWindow) { aTarget = aWindow.document.getElementById(aTarget); } - var event = aWindow.document.createEvent('MouseEvent'); + var event = aWindow.document.createEvent("MouseEvent"); - var typeArg = aEvent.type; - var canBubbleArg = true; - var cancelableArg = true; - var viewArg = aWindow; - var detailArg = aEvent.detail || (aEvent.type == 'click' || - aEvent.type == 'mousedown' || - aEvent.type == 'mouseup' ? 1 : - aEvent.type == 'dblclick'? 2 : 0); - var screenXArg = aEvent.screenX || 0; - var screenYArg = aEvent.screenY || 0; - var clientXArg = aEvent.clientX || 0; - var clientYArg = aEvent.clientY || 0; - var ctrlKeyArg = aEvent.ctrlKey || false; - var altKeyArg = aEvent.altKey || false; - var shiftKeyArg = aEvent.shiftKey || false; - var metaKeyArg = aEvent.metaKey || false; - var buttonArg = computeButton(aEvent); + var typeArg = aEvent.type; + var canBubbleArg = true; + var cancelableArg = true; + var viewArg = aWindow; + var detailArg = + aEvent.detail || + (aEvent.type == "click" || + aEvent.type == "mousedown" || + aEvent.type == "mouseup" + ? 1 + : aEvent.type == "dblclick" + ? 2 + : 0); + var screenXArg = aEvent.screenX || 0; + var screenYArg = aEvent.screenY || 0; + var clientXArg = aEvent.clientX || 0; + var clientYArg = aEvent.clientY || 0; + var ctrlKeyArg = aEvent.ctrlKey || false; + var altKeyArg = aEvent.altKey || false; + var shiftKeyArg = aEvent.shiftKey || false; + var metaKeyArg = aEvent.metaKey || false; + var buttonArg = computeButton(aEvent); var relatedTargetArg = aEvent.relatedTarget || null; - event.initMouseEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, - screenXArg, screenYArg, clientXArg, clientYArg, - ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, - buttonArg, relatedTargetArg); + event.initMouseEvent( + typeArg, + canBubbleArg, + cancelableArg, + viewArg, + detailArg, + screenXArg, + screenYArg, + clientXArg, + clientYArg, + ctrlKeyArg, + altKeyArg, + shiftKeyArg, + metaKeyArg, + buttonArg, + relatedTargetArg + ); // If documentURIObject exists or `window` is a stub object, we're in // a chrome scope, so don't bother trying to go through SpecialPowers. @@ -212,8 +243,20 @@ function isHidden(aElement) { * have. This includes the type of the drag event. */ function sendDragEvent(aEvent, aTarget, aWindow = window) { - if (!['drag', 'dragstart', 'dragend', 'dragover', 'dragenter', 'dragleave', 'drop'].includes(aEvent.type)) { - throw new Error("sendDragEvent doesn't know about event type '" + aEvent.type + "'"); + if ( + ![ + "drag", + "dragstart", + "dragend", + "dragover", + "dragenter", + "dragleave", + "drop", + ].includes(aEvent.type) + ) { + throw new Error( + "sendDragEvent doesn't know about event type '" + aEvent.type + "'" + ); } if (typeof aTarget == "string") { @@ -224,7 +267,7 @@ function sendDragEvent(aEvent, aTarget, aWindow = window) { * Drag event cannot be performed if the element is hidden, except 'dragend' * event where the element can becomes hidden after start dragging. */ - if (aEvent.type != 'dragend' && isHidden(aTarget)) { + if (aEvent.type != "dragend" && isHidden(aTarget)) { var targetName = aTarget.nodeName; if ("id" in aTarget && aTarget.id) { targetName += "#" + aTarget.id; @@ -232,29 +275,43 @@ function sendDragEvent(aEvent, aTarget, aWindow = window) { throw new Error(`${aEvent.type} event target ${targetName} is hidden`); } - var event = aWindow.document.createEvent('DragEvent'); + var event = aWindow.document.createEvent("DragEvent"); - var typeArg = aEvent.type; - var canBubbleArg = true; - var cancelableArg = true; - var viewArg = aWindow; - var detailArg = aEvent.detail || 0; - var screenXArg = aEvent.screenX || 0; - var screenYArg = aEvent.screenY || 0; - var clientXArg = aEvent.clientX || 0; - var clientYArg = aEvent.clientY || 0; - var ctrlKeyArg = aEvent.ctrlKey || false; - var altKeyArg = aEvent.altKey || false; - var shiftKeyArg = aEvent.shiftKey || false; - var metaKeyArg = aEvent.metaKey || false; - var buttonArg = computeButton(aEvent); + var typeArg = aEvent.type; + var canBubbleArg = true; + var cancelableArg = true; + var viewArg = aWindow; + var detailArg = aEvent.detail || 0; + var screenXArg = aEvent.screenX || 0; + var screenYArg = aEvent.screenY || 0; + var clientXArg = aEvent.clientX || 0; + var clientYArg = aEvent.clientY || 0; + var ctrlKeyArg = aEvent.ctrlKey || false; + var altKeyArg = aEvent.altKey || false; + var shiftKeyArg = aEvent.shiftKey || false; + var metaKeyArg = aEvent.metaKey || false; + var buttonArg = computeButton(aEvent); var relatedTargetArg = aEvent.relatedTarget || null; - var dataTransfer = aEvent.dataTransfer || null; + var dataTransfer = aEvent.dataTransfer || null; - event.initDragEvent(typeArg, canBubbleArg, cancelableArg, viewArg, detailArg, - screenXArg, screenYArg, clientXArg, clientYArg, - ctrlKeyArg, altKeyArg, shiftKeyArg, metaKeyArg, - buttonArg, relatedTargetArg, dataTransfer); + event.initDragEvent( + typeArg, + canBubbleArg, + cancelableArg, + viewArg, + detailArg, + screenXArg, + screenYArg, + clientXArg, + clientYArg, + ctrlKeyArg, + altKeyArg, + shiftKeyArg, + metaKeyArg, + buttonArg, + relatedTargetArg, + dataTransfer + ); if (aEvent._domDispatchOnly) { return aTarget.dispatchEvent(event); @@ -291,7 +348,7 @@ function sendChar(aChar, aWindow) { case "{": case "}": case ":": - case "\"": + case '"': case "|": case "<": case ">": @@ -299,8 +356,9 @@ function sendChar(aChar, aWindow) { hasShift = true; break; default: - hasShift = aChar.toLowerCase() != aChar.toUpperCase() && - aChar == aChar.toUpperCase(); + hasShift = + aChar.toLowerCase() != aChar.toUpperCase() && + aChar == aChar.toUpperCase(); break; } synthesizeKey(aChar, { shiftKey: hasShift }, aWindow); @@ -333,8 +391,7 @@ function sendKey(aKey, aWindow) { * Parse the key modifier flags from aEvent. Used to share code between * synthesizeMouse and synthesizeKey. */ -function _parseModifiers(aEvent, aWindow = window) -{ +function _parseModifiers(aEvent, aWindow = window) { var navigator = _getNavigator(aWindow); var nsIDOMWindowUtils = _EU_Ci.nsIDOMWindowUtils; var mval = 0; @@ -351,8 +408,9 @@ function _parseModifiers(aEvent, aWindow = window) mval |= nsIDOMWindowUtils.MODIFIER_META; } if (aEvent.accelKey) { - mval |= _EU_isMac(aWindow) ? - nsIDOMWindowUtils.MODIFIER_META : nsIDOMWindowUtils.MODIFIER_CONTROL; + mval |= _EU_isMac(aWindow) + ? nsIDOMWindowUtils.MODIFIER_META + : nsIDOMWindowUtils.MODIFIER_CONTROL; } if (aEvent.altGrKey) { mval |= nsIDOMWindowUtils.MODIFIER_ALTGRAPH; @@ -400,17 +458,23 @@ function _parseModifiers(aEvent, aWindow = window) * * Returns whether the event had preventDefault() called on it. */ -function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) -{ +function synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) { var rect = aTarget.getBoundingClientRect(); - return synthesizeMouseAtPoint(rect.left + aOffsetX, rect.top + aOffsetY, - aEvent, aWindow); + return synthesizeMouseAtPoint( + rect.left + aOffsetX, + rect.top + aOffsetY, + aEvent, + aWindow + ); } -function synthesizeTouch(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) -{ +function synthesizeTouch(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) { var rect = aTarget.getBoundingClientRect(); - return synthesizeTouchAtPoint(rect.left + aOffsetX, rect.top + aOffsetY, - aEvent, aWindow); + return synthesizeTouchAtPoint( + rect.left + aOffsetX, + rect.top + aOffsetY, + aEvent, + aWindow + ); } /* @@ -424,8 +488,7 @@ function synthesizeTouch(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) * * aWindow is optional, and defaults to the current window object. */ -function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) -{ +function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) { var utils = _getDOMWindowUtils(aWindow); var defaultPrevented = false; @@ -433,53 +496,89 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) var button = computeButton(aEvent); var clickCount = aEvent.clickCount || 1; var modifiers = _parseModifiers(aEvent, aWindow); - var pressure = ("pressure" in aEvent) ? aEvent.pressure : 0; + var pressure = "pressure" in aEvent ? aEvent.pressure : 0; // aWindow might be cross-origin from us. var MouseEvent = _EU_maybeWrap(aWindow).MouseEvent; // Default source to mouse. - var inputSource = ("inputSource" in aEvent) ? aEvent.inputSource : - MouseEvent.MOZ_SOURCE_MOUSE; + var inputSource = + "inputSource" in aEvent + ? aEvent.inputSource + : MouseEvent.MOZ_SOURCE_MOUSE; // Compute a pointerId if needed. var id; if ("id" in aEvent) { id = aEvent.id; } else { var isFromPen = inputSource === MouseEvent.MOZ_SOURCE_PEN; - id = isFromPen ? utils.DEFAULT_PEN_POINTER_ID : - utils.DEFAULT_MOUSE_POINTER_ID; + id = isFromPen + ? utils.DEFAULT_PEN_POINTER_ID + : utils.DEFAULT_MOUSE_POINTER_ID; } var isDOMEventSynthesized = - ("isSynthesized" in aEvent) ? aEvent.isSynthesized : true; + "isSynthesized" in aEvent ? aEvent.isSynthesized : true; var isWidgetEventSynthesized = - ("isWidgetEventSynthesized" in aEvent) ? aEvent.isWidgetEventSynthesized : false; - var buttons = ("buttons" in aEvent) ? aEvent.buttons : - utils.MOUSE_BUTTONS_NOT_SPECIFIED; - if (("type" in aEvent) && aEvent.type) { - defaultPrevented = utils.sendMouseEvent(aEvent.type, left, top, button, - clickCount, modifiers, false, - pressure, inputSource, - isDOMEventSynthesized, - isWidgetEventSynthesized, - buttons, id); - } - else { - utils.sendMouseEvent("mousedown", left, top, button, clickCount, modifiers, - false, pressure, inputSource, isDOMEventSynthesized, - isWidgetEventSynthesized, buttons, id); - utils.sendMouseEvent("mouseup", left, top, button, clickCount, modifiers, - false, pressure, inputSource, isDOMEventSynthesized, - isWidgetEventSynthesized, buttons, id); + "isWidgetEventSynthesized" in aEvent + ? aEvent.isWidgetEventSynthesized + : false; + var buttons = + "buttons" in aEvent ? aEvent.buttons : utils.MOUSE_BUTTONS_NOT_SPECIFIED; + if ("type" in aEvent && aEvent.type) { + defaultPrevented = utils.sendMouseEvent( + aEvent.type, + left, + top, + button, + clickCount, + modifiers, + false, + pressure, + inputSource, + isDOMEventSynthesized, + isWidgetEventSynthesized, + buttons, + id + ); + } else { + utils.sendMouseEvent( + "mousedown", + left, + top, + button, + clickCount, + modifiers, + false, + pressure, + inputSource, + isDOMEventSynthesized, + isWidgetEventSynthesized, + buttons, + id + ); + utils.sendMouseEvent( + "mouseup", + left, + top, + button, + clickCount, + modifiers, + false, + pressure, + inputSource, + isDOMEventSynthesized, + isWidgetEventSynthesized, + buttons, + id + ); } } return defaultPrevented; } -function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window) -{ +function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window) { var utils = _getDOMWindowUtils(aWindow); let defaultPrevented = false; @@ -491,29 +590,60 @@ function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window) var force = aEvent.force || 1; var modifiers = _parseModifiers(aEvent, aWindow); - if (("type" in aEvent) && aEvent.type) { - defaultPrevented = utils.sendTouchEvent(aEvent.type, [id], [left], [top], [rx], [ry], [angle], [force], modifiers); - } - else { - utils.sendTouchEvent("touchstart", [id], [left], [top], [rx], [ry], [angle], [force], modifiers); - utils.sendTouchEvent("touchend", [id], [left], [top], [rx], [ry], [angle], [force], modifiers); + if ("type" in aEvent && aEvent.type) { + defaultPrevented = utils.sendTouchEvent( + aEvent.type, + [id], + [left], + [top], + [rx], + [ry], + [angle], + [force], + modifiers + ); + } else { + utils.sendTouchEvent( + "touchstart", + [id], + [left], + [top], + [rx], + [ry], + [angle], + [force], + modifiers + ); + utils.sendTouchEvent( + "touchend", + [id], + [left], + [top], + [rx], + [ry], + [angle], + [force], + modifiers + ); } } return defaultPrevented; } // Call synthesizeMouse with coordinates at the center of aTarget. -function synthesizeMouseAtCenter(aTarget, aEvent, aWindow) -{ +function synthesizeMouseAtCenter(aTarget, aEvent, aWindow) { var rect = aTarget.getBoundingClientRect(); - return synthesizeMouse(aTarget, rect.width / 2, rect.height / 2, aEvent, - aWindow); + return synthesizeMouse( + aTarget, + rect.width / 2, + rect.height / 2, + aEvent, + aWindow + ); } -function synthesizeTouchAtCenter(aTarget, aEvent, aWindow) -{ +function synthesizeTouchAtCenter(aTarget, aEvent, aWindow) { var rect = aTarget.getBoundingClientRect(); - synthesizeTouch(aTarget, rect.width / 2, rect.height / 2, aEvent, - aWindow); + synthesizeTouch(aTarget, rect.width / 2, rect.height / 2, aEvent, aWindow); } /** @@ -533,8 +663,7 @@ function synthesizeTouchAtCenter(aTarget, aEvent, aWindow) * * aWindow is optional, and defaults to the current window object. */ -function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) -{ +function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return; @@ -583,17 +712,29 @@ function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) } var lineOrPageDeltaX = - aEvent.lineOrPageDeltaX != null ? aEvent.lineOrPageDeltaX : - aEvent.deltaX > 0 ? Math.floor(aEvent.deltaX) : - Math.ceil(aEvent.deltaX); + aEvent.lineOrPageDeltaX != null + ? aEvent.lineOrPageDeltaX + : aEvent.deltaX > 0 + ? Math.floor(aEvent.deltaX) + : Math.ceil(aEvent.deltaX); var lineOrPageDeltaY = - aEvent.lineOrPageDeltaY != null ? aEvent.lineOrPageDeltaY : - aEvent.deltaY > 0 ? Math.floor(aEvent.deltaY) : - Math.ceil(aEvent.deltaY); - utils.sendWheelEvent(aLeft, aTop, - aEvent.deltaX, aEvent.deltaY, aEvent.deltaZ, - aEvent.deltaMode, modifiers, - lineOrPageDeltaX, lineOrPageDeltaY, options); + aEvent.lineOrPageDeltaY != null + ? aEvent.lineOrPageDeltaY + : aEvent.deltaY > 0 + ? Math.floor(aEvent.deltaY) + : Math.ceil(aEvent.deltaY); + utils.sendWheelEvent( + aLeft, + aTop, + aEvent.deltaX, + aEvent.deltaY, + aEvent.deltaZ, + aEvent.deltaMode, + modifiers, + lineOrPageDeltaX, + lineOrPageDeltaY, + options + ); } /** @@ -614,25 +755,32 @@ function synthesizeWheelAtPoint(aLeft, aTop, aEvent, aWindow = window) * * aWindow is optional, and defaults to the current window object. */ -function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) -{ +function synthesizeWheel(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) { var rect = aTarget.getBoundingClientRect(); - synthesizeWheelAtPoint(rect.left + aOffsetX, rect.top + aOffsetY, - aEvent, aWindow); + synthesizeWheelAtPoint( + rect.left + aOffsetX, + rect.top + aOffsetY, + aEvent, + aWindow + ); } const _FlushModes = { FLUSH: 0, - NOFLUSH: 1 + NOFLUSH: 1, }; -function _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, - aEvent, aCallback, - aFlushMode = _FlushModes.FLUSH, - aWindow = window) { +function _sendWheelAndPaint( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aCallback, + aFlushMode = _FlushModes.FLUSH, + aWindow = window +) { var utils = _getDOMWindowUtils(aWindow); - if (!utils) - return; + if (!utils) return; if (utils.isMozAfterPaintPending) { // If a paint is pending, then APZ may be waiting for a scroll acknowledgement @@ -640,10 +788,15 @@ function _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, // by APZ (or its scroll offset could be overridden). To avoid problems we // just wait for the paint to complete. aWindow.waitForAllPaintsFlushed(function() { - _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, - aEvent, aCallback, - aFlushMode, - aWindow); + _sendWheelAndPaint( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aCallback, + aFlushMode, + aWindow + ); }); return; } @@ -661,15 +814,21 @@ function _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, return; } - var waitForPaints = function () { - SpecialPowers.Services.obs.removeObserver(waitForPaints, "apz-repaints-flushed"); + var waitForPaints = function() { + SpecialPowers.Services.obs.removeObserver( + waitForPaints, + "apz-repaints-flushed" + ); aWindow.waitForAllPaintsFlushed(function() { utils.restoreNormalRefresh(); aCallback(); }); - } + }; - SpecialPowers.Services.obs.addObserver(waitForPaints, "apz-repaints-flushed"); + SpecialPowers.Services.obs.addObserver( + waitForPaints, + "apz-repaints-flushed" + ); if (!utils.flushApzRepaints(aWindow)) { waitForPaints(); } @@ -698,13 +857,23 @@ function _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, * determining scroll completion and the refresh driver is not automatically * restored. */ -function sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, - aEvent, aCallback, - aWindow = window) { - _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, - aEvent, aCallback, - _FlushModes.FLUSH, - aWindow); +function sendWheelAndPaint( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aCallback, + aWindow = window +) { + _sendWheelAndPaint( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aCallback, + _FlushModes.FLUSH, + aWindow + ); } /** @@ -712,24 +881,52 @@ function sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, * |aTarget| position in |aWindow| before sending the wheel event. * |aOffsetX| and |aOffsetY| should be offsets against aWindow. */ -function sendWheelAndPaintNoFlush(aTarget, aOffsetX, aOffsetY, - aEvent, aCallback, - aWindow = window) { - _sendWheelAndPaint(aTarget, aOffsetX, aOffsetY, - aEvent, aCallback, - _FlushModes.NOFLUSH, - aWindow); +function sendWheelAndPaintNoFlush( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aCallback, + aWindow = window +) { + _sendWheelAndPaint( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aCallback, + _FlushModes.NOFLUSH, + aWindow + ); } -function synthesizeNativeTapAtCenter(aTarget, aLongTap = false, aCallback = null, aWindow = window) { +function synthesizeNativeTapAtCenter( + aTarget, + aLongTap = false, + aCallback = null, + aWindow = window +) { let rect = aTarget.getBoundingClientRect(); - return synthesizeNativeTap(aTarget, rect.width / 2, rect.height / 2, aLongTap, aCallback, aWindow); + return synthesizeNativeTap( + aTarget, + rect.width / 2, + rect.height / 2, + aLongTap, + aCallback, + aWindow + ); } -function synthesizeNativeTap(aTarget, aOffsetX, aOffsetY, aLongTap = false, aCallback = null, aWindow = window) { +function synthesizeNativeTap( + aTarget, + aOffsetX, + aOffsetY, + aLongTap = false, + aCallback = null, + aWindow = window +) { let utils = _getDOMWindowUtils(aWindow); - if (!utils) - return; + if (!utils) return; let scale = utils.screenPixelsPerCSSPixel; let rect = aTarget.getBoundingClientRect(); @@ -741,15 +938,20 @@ function synthesizeNativeTap(aTarget, aOffsetX, aOffsetY, aLongTap = false, aCal if (aCallback && topic == "mouseevent") { aCallback(data); } - } + }, }; utils.sendNativeTouchTap(x, y, aLongTap, observer); } -function synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, aCallback, aWindow = window) { +function synthesizeNativeMouseMove( + aTarget, + aOffsetX, + aOffsetY, + aCallback, + aWindow = window +) { var utils = _getDOMWindowUtils(aWindow); - if (!utils) - return; + if (!utils) return; var rect = aTarget.getBoundingClientRect(); var x = aOffsetX + window.mozInnerScreenX + rect.left; @@ -761,7 +963,7 @@ function synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, aCallback, aWind if (aCallback && topic == "mouseevent") { aCallback(data); } - } + }, }; utils.sendNativeMouseMove(x * scale, y * scale, null, observer); } @@ -773,31 +975,43 @@ function synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, aCallback, aWind * This API is supposed to be used in those test cases that synthesize some * input events to chrome process and have some checks in content. */ -function synthesizeAndWaitNativeMouseMove(aTarget, aOffsetX, aOffsetY, - aCallback, aWindow = window) { +function synthesizeAndWaitNativeMouseMove( + aTarget, + aOffsetX, + aOffsetY, + aCallback, + aWindow = window +) { let browser = gBrowser.selectedTab.linkedBrowser; let mm = browser.messageManager; - let ContentTask = - _EU_Cu.import("resource://testing-common/ContentTask.jsm", null).ContentTask; + let ContentTask = _EU_Cu.import( + "resource://testing-common/ContentTask.jsm", + null + ).ContentTask; let eventRegisteredPromise = new Promise(resolve => { - mm.addMessageListener("Test:MouseMoveRegistered", function processed(message) { + mm.addMessageListener("Test:MouseMoveRegistered", function processed( + message + ) { mm.removeMessageListener("Test:MouseMoveRegistered", processed); resolve(); }); }); - let eventReceivedPromise = ContentTask.spawn(browser, [aOffsetX, aOffsetY], - ([clientX, clientY]) => { - return new Promise(resolve => { - addEventListener("mousemove", function onMouseMoveEvent(e) { - if (e.clientX == clientX && e.clientY == clientY) { - removeEventListener("mousemove", onMouseMoveEvent); - resolve(); - } + let eventReceivedPromise = ContentTask.spawn( + browser, + [aOffsetX, aOffsetY], + ([clientX, clientY]) => { + return new Promise(resolve => { + addEventListener("mousemove", function onMouseMoveEvent(e) { + if (e.clientX == clientX && e.clientY == clientY) { + removeEventListener("mousemove", onMouseMoveEvent); + resolve(); + } + }); + sendAsyncMessage("Test:MouseMoveRegistered"); }); - sendAsyncMessage("Test:MouseMoveRegistered"); - }); - }); + } + ); eventRegisteredPromise.then(() => { synthesizeNativeMouseMove(aTarget, aOffsetX, aOffsetY, null, aWindow); }); @@ -848,8 +1062,7 @@ function synthesizeAndWaitNativeMouseMove(aTarget, aOffsetX, aOffsetY, * aWindow is optional, and defaults to the current window object. * aCallback is optional, use the callback for receiving notifications of TIP. */ -function synthesizeKey(aKey, aEvent = undefined, aWindow = window, aCallback) -{ +function synthesizeKey(aKey, aEvent = undefined, aWindow = window, aCallback) { var event = aEvent === undefined || aEvent === null ? {} : aEvent; var TIP = _getTIP(aWindow, aCallback); @@ -863,7 +1076,7 @@ function synthesizeKey(aKey, aEvent = undefined, aWindow = window, aCallback) var dispatchKeydown = !("type" in event) || event.type === "keydown" || !event.type; var dispatchKeyup = - !("type" in event) || event.type === "keyup" || !event.type; + !("type" in event) || event.type === "keyup" || !event.type; try { if (dispatchKeydown) { @@ -892,13 +1105,21 @@ function synthesizeKey(aKey, aEvent = undefined, aWindow = window, aCallback) * This API is supposed to be used in those test cases that synthesize some * input events to chrome process and have some checks in content. */ -function synthesizeAndWaitKey(aKey, aEvent, aWindow = window, - checkBeforeSynthesize, checkAfterSynthesize) -{ +function synthesizeAndWaitKey( + aKey, + aEvent, + aWindow = window, + checkBeforeSynthesize, + checkAfterSynthesize +) { let browser = gBrowser.selectedTab.linkedBrowser; let mm = browser.messageManager; - let keyCode = _createKeyboardEventDictionary(aKey, aEvent, null, aWindow).dictionary.keyCode; - let ContentTask = _EU_Cu.import("resource://testing-common/ContentTask.jsm", null).ContentTask; + let keyCode = _createKeyboardEventDictionary(aKey, aEvent, null, aWindow) + .dictionary.keyCode; + let ContentTask = _EU_Cu.import( + "resource://testing-common/ContentTask.jsm", + null + ).ContentTask; let keyRegisteredPromise = new Promise(resolve => { mm.addMessageListener("Test:KeyRegistered", function processed(message) { @@ -906,7 +1127,7 @@ function synthesizeAndWaitKey(aKey, aEvent, aWindow = window, resolve(); }); }); - let keyReceivedPromise = ContentTask.spawn(browser, keyCode, (keyCode) => { + let keyReceivedPromise = ContentTask.spawn(browser, keyCode, keyCode => { return new Promise(resolve => { addEventListener("keyup", function onKeyEvent(e) { if (e.keyCode == keyCode) { @@ -929,8 +1150,7 @@ function synthesizeAndWaitKey(aKey, aEvent, aWindow = window, return keyReceivedPromise; } -function _parseNativeModifiers(aModifiers, aWindow = window) -{ +function _parseNativeModifiers(aModifiers, aWindow = window) { var navigator = _getNavigator(aWindow); var modifiers; if (aModifiers.capsLockKey) { @@ -991,57 +1211,108 @@ function _parseNativeModifiers(aModifiers, aWindow = window) // Win: These constants can be found by inspecting registry keys under // HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Keyboard Layouts -const KEYBOARD_LAYOUT_ARABIC = - { name: "Arabic", Mac: 6, - Win: 0x00000401, hasAltGrOnWin: false }; -const KEYBOARD_LAYOUT_ARABIC_PC = - { name: "Arabic - PC", Mac: 7, - Win: null, hasAltGrOnWin: false }; -const KEYBOARD_LAYOUT_BRAZILIAN_ABNT = - { name: "Brazilian ABNT", Mac: null, - Win: 0x00000416, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_DVORAK_QWERTY = - { name: "Dvorak-QWERTY", Mac: 4, - Win: null, hasAltGrOnWin: false }; -const KEYBOARD_LAYOUT_EN_US = - { name: "US", Mac: 0, - Win: 0x00000409, hasAltGrOnWin: false }; -const KEYBOARD_LAYOUT_FRENCH = - { name: "French", Mac: 8, - Win: 0x0000040C, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_GREEK = - { name: "Greek", Mac: 1, - Win: 0x00000408, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_GERMAN = - { name: "German", Mac: 2, - Win: 0x00000407, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_HEBREW = - { name: "Hebrew", Mac: 9, - Win: 0x0000040D, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_JAPANESE = - { name: "Japanese", Mac: null, - Win: 0x00000411, hasAltGrOnWin: false }; -const KEYBOARD_LAYOUT_KHMER = - { name: "Khmer", Mac: null, - Win: 0x00000453, hasAltGrOnWin: true }; // available on Win7 or later. -const KEYBOARD_LAYOUT_LITHUANIAN = - { name: "Lithuanian", Mac: 10, - Win: 0x00010427, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_NORWEGIAN = - { name: "Norwegian", Mac: 11, - Win: 0x00000414, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC = - { name: "Russian - Mnemonic", Mac: null, - Win: 0x00020419, hasAltGrOnWin: true }; // available on Win8 or later. -const KEYBOARD_LAYOUT_SPANISH = - { name: "Spanish", Mac: 12, - Win: 0x0000040A, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_SWEDISH = - { name: "Swedish", Mac: 3, - Win: 0x0000041D, hasAltGrOnWin: true }; -const KEYBOARD_LAYOUT_THAI = - { name: "Thai", Mac: 5, - Win: 0x0002041E, hasAltGrOnWin: false }; +const KEYBOARD_LAYOUT_ARABIC = { + name: "Arabic", + Mac: 6, + Win: 0x00000401, + hasAltGrOnWin: false, +}; +const KEYBOARD_LAYOUT_ARABIC_PC = { + name: "Arabic - PC", + Mac: 7, + Win: null, + hasAltGrOnWin: false, +}; +const KEYBOARD_LAYOUT_BRAZILIAN_ABNT = { + name: "Brazilian ABNT", + Mac: null, + Win: 0x00000416, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_DVORAK_QWERTY = { + name: "Dvorak-QWERTY", + Mac: 4, + Win: null, + hasAltGrOnWin: false, +}; +const KEYBOARD_LAYOUT_EN_US = { + name: "US", + Mac: 0, + Win: 0x00000409, + hasAltGrOnWin: false, +}; +const KEYBOARD_LAYOUT_FRENCH = { + name: "French", + Mac: 8, + Win: 0x0000040c, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_GREEK = { + name: "Greek", + Mac: 1, + Win: 0x00000408, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_GERMAN = { + name: "German", + Mac: 2, + Win: 0x00000407, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_HEBREW = { + name: "Hebrew", + Mac: 9, + Win: 0x0000040d, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_JAPANESE = { + name: "Japanese", + Mac: null, + Win: 0x00000411, + hasAltGrOnWin: false, +}; +const KEYBOARD_LAYOUT_KHMER = { + name: "Khmer", + Mac: null, + Win: 0x00000453, + hasAltGrOnWin: true, +}; // available on Win7 or later. +const KEYBOARD_LAYOUT_LITHUANIAN = { + name: "Lithuanian", + Mac: 10, + Win: 0x00010427, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_NORWEGIAN = { + name: "Norwegian", + Mac: 11, + Win: 0x00000414, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_RUSSIAN_MNEMONIC = { + name: "Russian - Mnemonic", + Mac: null, + Win: 0x00020419, + hasAltGrOnWin: true, +}; // available on Win8 or later. +const KEYBOARD_LAYOUT_SPANISH = { + name: "Spanish", + Mac: 12, + Win: 0x0000040a, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_SWEDISH = { + name: "Swedish", + Mac: 3, + Win: 0x0000041d, + hasAltGrOnWin: true, +}; +const KEYBOARD_LAYOUT_THAI = { + name: "Thai", + Mac: 5, + Win: 0x0002041e, + hasAltGrOnWin: false, +}; /** * synthesizeNativeKey() dispatches native key event on active window. @@ -1069,9 +1340,15 @@ const KEYBOARD_LAYOUT_THAI = * native key event. Otherwise, false. */ -function synthesizeNativeKey(aKeyboardLayout, aNativeKeyCode, aModifiers, - aChars, aUnmodifiedChars, aCallback, aWindow = window) -{ +function synthesizeNativeKey( + aKeyboardLayout, + aNativeKeyCode, + aModifiers, + aChars, + aUnmodifiedChars, + aCallback, + aWindow = window +) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return false; @@ -1092,11 +1369,16 @@ function synthesizeNativeKey(aKeyboardLayout, aNativeKeyCode, aModifiers, if (aCallback && aTopic == "keyevent") { aCallback(aData); } - } + }, }; - utils.sendNativeKeyEvent(nativeKeyboardLayout, aNativeKeyCode, - _parseNativeModifiers(aModifiers, aWindow), - aChars, aUnmodifiedChars, observer); + utils.sendNativeKeyEvent( + nativeKeyboardLayout, + aNativeKeyCode, + _parseNativeModifiers(aModifiers, aWindow), + aChars, + aUnmodifiedChars, + observer + ); return true; } @@ -1107,19 +1389,25 @@ var _gSeenEvent = false; * a type of aExpectedEvent is expected to be fired, or not expected to * be fired. */ -function _expectEvent(aExpectedTarget, aExpectedEvent, aTestName) -{ - if (!aExpectedTarget || !aExpectedEvent) - return null; +function _expectEvent(aExpectedTarget, aExpectedEvent, aTestName) { + if (!aExpectedTarget || !aExpectedEvent) return null; _gSeenEvent = false; - var type = (aExpectedEvent.charAt(0) == "!") ? - aExpectedEvent.substring(1) : aExpectedEvent; + var type = + aExpectedEvent.charAt(0) == "!" + ? aExpectedEvent.substring(1) + : aExpectedEvent; var eventHandler = function(event) { - var epassed = (!_gSeenEvent && event.originalTarget == aExpectedTarget && - event.type == type); - is(epassed, true, aTestName + " " + type + " event target " + (_gSeenEvent ? "twice" : "")); + var epassed = + !_gSeenEvent && + event.originalTarget == aExpectedTarget && + event.type == type; + is( + epassed, + true, + aTestName + " " + type + " event target " + (_gSeenEvent ? "twice" : "") + ); _gSeenEvent = true; }; @@ -1131,15 +1419,18 @@ function _expectEvent(aExpectedTarget, aExpectedEvent, aTestName) * Check if the event was fired or not. The event handler aEventHandler * will be removed. */ -function _checkExpectedEvent(aExpectedTarget, aExpectedEvent, aEventHandler, aTestName) -{ +function _checkExpectedEvent( + aExpectedTarget, + aExpectedEvent, + aEventHandler, + aTestName +) { if (aEventHandler) { - var expectEvent = (aExpectedEvent.charAt(0) != "!"); + var expectEvent = aExpectedEvent.charAt(0) != "!"; var type = expectEvent ? aExpectedEvent : aExpectedEvent.substring(1); aExpectedTarget.removeEventListener(type, aEventHandler); var desc = type + " event"; - if (!expectEvent) - desc += " not"; + if (!expectEvent) desc += " not"; is(_gSeenEvent, expectEvent, aTestName + " " + desc + " fired"); } @@ -1160,10 +1451,16 @@ function _checkExpectedEvent(aExpectedTarget, aExpectedEvent, aEventHandler, aTe * * aWindow is optional, and defaults to the current window object. */ -function synthesizeMouseExpectEvent(aTarget, aOffsetX, aOffsetY, aEvent, - aExpectedTarget, aExpectedEvent, aTestName, - aWindow) -{ +function synthesizeMouseExpectEvent( + aTarget, + aOffsetX, + aOffsetY, + aEvent, + aExpectedTarget, + aExpectedEvent, + aTestName, + aWindow +) { var eventHandler = _expectEvent(aExpectedTarget, aExpectedEvent, aTestName); synthesizeMouse(aTarget, aOffsetX, aOffsetY, aEvent, aWindow); _checkExpectedEvent(aExpectedTarget, aExpectedEvent, eventHandler, aTestName); @@ -1182,22 +1479,25 @@ function synthesizeMouseExpectEvent(aTarget, aOffsetX, aOffsetY, aEvent, * * aWindow is optional, and defaults to the current window object. */ -function synthesizeKeyExpectEvent(key, aEvent, aExpectedTarget, aExpectedEvent, - aTestName, aWindow) -{ +function synthesizeKeyExpectEvent( + key, + aEvent, + aExpectedTarget, + aExpectedEvent, + aTestName, + aWindow +) { var eventHandler = _expectEvent(aExpectedTarget, aExpectedEvent, aTestName); synthesizeKey(key, aEvent, aWindow); _checkExpectedEvent(aExpectedTarget, aExpectedEvent, eventHandler, aTestName); } -function disableNonTestMouseEvents(aDisable) -{ +function disableNonTestMouseEvents(aDisable) { var domutils = _getDOMWindowUtils(); domutils.disableNonTestMouseEvents(aDisable); } -function _getDOMWindowUtils(aWindow = window) -{ +function _getDOMWindowUtils(aWindow = window) { // Leave this here as something, somewhere, passes a falsy argument // to this, causing the |window| default argument not to get picked up. if (!aWindow) { @@ -1229,7 +1529,7 @@ function _defineConstant(name, value) { Object.defineProperty(this, name, { value: value, enumerable: true, - writable: false + writable: false, }); } @@ -1238,18 +1538,26 @@ const COMPOSITION_ATTR_RAW_CLAUSE = _defineConstant("COMPOSITION_ATTR_RAW_CLAUSE", COMPOSITION_ATTR_RAW_CLAUSE); const COMPOSITION_ATTR_SELECTED_RAW_CLAUSE = _EU_Ci.nsITextInputProcessor.ATTR_SELECTED_RAW_CLAUSE; -_defineConstant("COMPOSITION_ATTR_SELECTED_RAW_CLAUSE", COMPOSITION_ATTR_SELECTED_RAW_CLAUSE); +_defineConstant( + "COMPOSITION_ATTR_SELECTED_RAW_CLAUSE", + COMPOSITION_ATTR_SELECTED_RAW_CLAUSE +); const COMPOSITION_ATTR_CONVERTED_CLAUSE = _EU_Ci.nsITextInputProcessor.ATTR_CONVERTED_CLAUSE; -_defineConstant("COMPOSITION_ATTR_CONVERTED_CLAUSE", COMPOSITION_ATTR_CONVERTED_CLAUSE); +_defineConstant( + "COMPOSITION_ATTR_CONVERTED_CLAUSE", + COMPOSITION_ATTR_CONVERTED_CLAUSE +); const COMPOSITION_ATTR_SELECTED_CLAUSE = _EU_Ci.nsITextInputProcessor.ATTR_SELECTED_CLAUSE; -_defineConstant("COMPOSITION_ATTR_SELECTED_CLAUSE", COMPOSITION_ATTR_SELECTED_CLAUSE); +_defineConstant( + "COMPOSITION_ATTR_SELECTED_CLAUSE", + COMPOSITION_ATTR_SELECTED_CLAUSE +); var TIPMap = new WeakMap(); -function _getTIP(aWindow, aCallback) -{ +function _getTIP(aWindow, aCallback) { if (!aWindow) { aWindow = window; } @@ -1257,9 +1565,9 @@ function _getTIP(aWindow, aCallback) if (TIPMap.has(aWindow)) { tip = TIPMap.get(aWindow); } else { - tip = - _EU_Cc["@mozilla.org/text-input-processor;1"]. - createInstance(_EU_Ci.nsITextInputProcessor); + tip = _EU_Cc["@mozilla.org/text-input-processor;1"].createInstance( + _EU_Ci.nsITextInputProcessor + ); TIPMap.set(aWindow, tip); } if (!tip.beginInputTransactionForTests(aWindow, aCallback)) { @@ -1269,8 +1577,7 @@ function _getTIP(aWindow, aCallback) return tip; } -function _getKeyboardEvent(aWindow = window) -{ +function _getKeyboardEvent(aWindow = window) { if (typeof KeyboardEvent != "undefined") { try { // See if the object can be instantiated; sometimes this yields @@ -1279,22 +1586,20 @@ function _getKeyboardEvent(aWindow = window) return KeyboardEvent; } catch (ex) {} } - if (typeof content != "undefined" && ("KeyboardEvent" in content)) { + if (typeof content != "undefined" && "KeyboardEvent" in content) { return content.KeyboardEvent; } return aWindow.KeyboardEvent; } -function _getNavigator(aWindow = window) -{ +function _getNavigator(aWindow = window) { if (typeof navigator != "undefined") { return navigator; } return aWindow.navigator; } -function _guessKeyNameFromKeyCode(aKeyCode, aWindow = window) -{ +function _guessKeyNameFromKeyCode(aKeyCode, aWindow = window) { var KeyboardEvent = _getKeyboardEvent(aWindow); switch (aKeyCode) { case KeyboardEvent.DOM_VK_CANCEL: @@ -1442,14 +1747,18 @@ function _guessKeyNameFromKeyCode(aKeyCode, aWindow = window) } } -function _createKeyboardEventDictionary(aKey, aKeyEvent, - aTIP = null, - aWindow = window) { +function _createKeyboardEventDictionary( + aKey, + aKeyEvent, + aTIP = null, + aWindow = window +) { var result = { dictionary: null, flags: 0 }; var keyCodeIsDefined = "keyCode" in aKeyEvent; var keyCode = - (keyCodeIsDefined && aKeyEvent.keyCode >= 0 && aKeyEvent.keyCode <= 255) ? - aKeyEvent.keyCode : 0; + keyCodeIsDefined && aKeyEvent.keyCode >= 0 && aKeyEvent.keyCode <= 255 + ? aKeyEvent.keyCode + : 0; var keyName = "Unidentified"; var code = aKeyEvent.code; if (!aTIP) { @@ -1459,8 +1768,10 @@ function _createKeyboardEventDictionary(aKey, aKeyEvent, keyName = aKey.substr("KEY_".length); result.flags |= _EU_Ci.nsITextInputProcessor.KEY_NON_PRINTABLE_KEY; if (code === undefined) { - code = - aTIP.computeCodeValueOfNonPrintableKey(keyName, aKeyEvent.location); + code = aTIP.computeCodeValueOfNonPrintableKey( + keyName, + aKeyEvent.location + ); } } else if (aKey.indexOf("VK_") == 0) { keyCode = _getKeyboardEvent(aWindow)["DOM_" + aKey]; @@ -1470,15 +1781,18 @@ function _createKeyboardEventDictionary(aKey, aKeyEvent, keyName = _guessKeyNameFromKeyCode(keyCode, aWindow); result.flags |= _EU_Ci.nsITextInputProcessor.KEY_NON_PRINTABLE_KEY; if (code === undefined) { - code = - aTIP.computeCodeValueOfNonPrintableKey(keyName, aKeyEvent.location); + code = aTIP.computeCodeValueOfNonPrintableKey( + keyName, + aKeyEvent.location + ); } } else if (aKey != "") { keyName = aKey; if (!keyCodeIsDefined) { - keyCode = - aTIP.guessKeyCodeValueOfPrintableKeyInUSEnglishKeyboardLayout( - aKey, aKeyEvent.location); + keyCode = aTIP.guessKeyCodeValueOfPrintableKeyInUSEnglishKeyboardLayout( + aKey, + aKeyEvent.location + ); } if (!keyCode) { result.flags |= _EU_Ci.nsITextInputProcessor.KEY_KEEP_KEYCODE_ZERO; @@ -1486,7 +1800,9 @@ function _createKeyboardEventDictionary(aKey, aKeyEvent, result.flags |= _EU_Ci.nsITextInputProcessor.KEY_FORCE_PRINTABLE_KEY; if (code === undefined) { code = aTIP.guessCodeValueOfPrintableKeyInUSEnglishKeyboardLayout( - keyName, aKeyEvent.location); + keyName, + aKeyEvent.location + ); } } var locationIsDefined = "location" in aKeyEvent; @@ -1510,8 +1826,7 @@ function _createKeyboardEventDictionary(aKey, aKeyEvent, return result; } -function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) -{ +function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) { if (!aKeyEvent) { return null; } @@ -1520,25 +1835,24 @@ function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) var modifiers = { normal: [ - { key: "Alt", attr: "altKey" }, - { key: "AltGraph", attr: "altGraphKey" }, - { key: "Control", attr: "ctrlKey" }, - { key: "Fn", attr: "fnKey" }, - { key: "Meta", attr: "metaKey" }, - { key: "OS", attr: "osKey" }, - { key: "Shift", attr: "shiftKey" }, - { key: "Symbol", attr: "symbolKey" }, - { key: _EU_isMac(aWindow) ? "Meta" : "Control", - attr: "accelKey" }, + { key: "Alt", attr: "altKey" }, + { key: "AltGraph", attr: "altGraphKey" }, + { key: "Control", attr: "ctrlKey" }, + { key: "Fn", attr: "fnKey" }, + { key: "Meta", attr: "metaKey" }, + { key: "OS", attr: "osKey" }, + { key: "Shift", attr: "shiftKey" }, + { key: "Symbol", attr: "symbolKey" }, + { key: _EU_isMac(aWindow) ? "Meta" : "Control", attr: "accelKey" }, ], lockable: [ - { key: "CapsLock", attr: "capsLockKey" }, - { key: "FnLock", attr: "fnLockKey" }, - { key: "NumLock", attr: "numLockKey" }, + { key: "CapsLock", attr: "capsLockKey" }, + { key: "FnLock", attr: "fnLockKey" }, + { key: "NumLock", attr: "numLockKey" }, { key: "ScrollLock", attr: "scrollLockKey" }, { key: "SymbolLock", attr: "symbolLockKey" }, - ] - } + ], + }; for (var i = 0; i < modifiers.normal.length; i++) { if (!aKeyEvent[modifiers.normal[i].attr]) { @@ -1548,8 +1862,10 @@ function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) continue; // already activated. } var event = new KeyboardEvent("", { key: modifiers.normal[i].key }); - aTIP.keydown(event, - aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT); + aTIP.keydown( + event, + aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT + ); modifiers.normal[i].activated = true; } for (var i = 0; i < modifiers.lockable.length; i++) { @@ -1560,17 +1876,20 @@ function _emulateToActivateModifiers(aTIP, aKeyEvent, aWindow = window) continue; // already activated. } var event = new KeyboardEvent("", { key: modifiers.lockable[i].key }); - aTIP.keydown(event, - aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT); - aTIP.keyup(event, - aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT); + aTIP.keydown( + event, + aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT + ); + aTIP.keyup( + event, + aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT + ); modifiers.lockable[i].activated = true; } return modifiers; } -function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) -{ +function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) { if (!aModifiers) { return; } @@ -1580,8 +1899,10 @@ function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) continue; } var event = new KeyboardEvent("", { key: aModifiers.normal[i].key }); - aTIP.keyup(event, - aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT); + aTIP.keyup( + event, + aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT + ); } for (var i = 0; i < aModifiers.lockable.length; i++) { if (!aModifiers.lockable[i].activated) { @@ -1591,10 +1912,14 @@ function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) continue; // who already inactivated this? } var event = new KeyboardEvent("", { key: aModifiers.lockable[i].key }); - aTIP.keydown(event, - aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT); - aTIP.keyup(event, - aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT); + aTIP.keydown( + event, + aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT + ); + aTIP.keyup( + event, + aTIP.KEY_NON_PRINTABLE_KEY | aTIP.KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT + ); } } @@ -1644,8 +1969,7 @@ function _emulateToInactivateModifiers(aTIP, aModifiers, aWindow = window) * @param aCallback Optional (If non-null, use the callback for * receiving notifications to IME) */ -function synthesizeComposition(aEvent, aWindow = window, aCallback) -{ +function synthesizeComposition(aEvent, aWindow = window, aCallback) { var TIP = _getTIP(aWindow, aCallback); if (!TIP) { return false; @@ -1653,20 +1977,31 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) var KeyboardEvent = _getKeyboardEvent(aWindow); var modifiers = _emulateToActivateModifiers(TIP, aEvent.key, aWindow); var ret = false; - var keyEventDict = {dictionary: null, flags: 0}; + var keyEventDict = { dictionary: null, flags: 0 }; var keyEvent = null; if (aEvent.key && typeof aEvent.key.key === "string") { - keyEventDict = - _createKeyboardEventDictionary(aEvent.key.key, aEvent.key, TIP, aWindow); - keyEvent = new KeyboardEvent(aEvent.key.type === "keydown" ? - "keydown" : - aEvent.key.type === "keyup" ? - "keyup" : "", - keyEventDict.dictionary) + keyEventDict = _createKeyboardEventDictionary( + aEvent.key.key, + aEvent.key, + TIP, + aWindow + ); + keyEvent = new KeyboardEvent( + aEvent.key.type === "keydown" + ? "keydown" + : aEvent.key.type === "keyup" + ? "keyup" + : "", + keyEventDict.dictionary + ); } else if (aEvent.key === undefined) { - keyEventDict = - _createKeyboardEventDictionary("KEY_Process", {}, TIP, aWindow); - keyEvent = new KeyboardEvent("", keyEventDict.dictionary) + keyEventDict = _createKeyboardEventDictionary( + "KEY_Process", + {}, + TIP, + aWindow + ); + keyEvent = new KeyboardEvent("", keyEventDict.dictionary); } try { switch (aEvent.type) { @@ -1677,8 +2012,11 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) ret = TIP.commitComposition(keyEvent, keyEventDict.flags); break; case "compositioncommit": - ret = TIP.commitCompositionWith(aEvent.data, keyEvent, - keyEventDict.flags); + ret = TIP.commitCompositionWith( + aEvent.data, + keyEvent, + keyEventDict.flags + ); break; } } finally { @@ -1749,16 +2087,18 @@ function synthesizeComposition(aEvent, aWindow = window, aCallback) * @param aCallback Optional (If non-null, use the callback for receiving * notifications to IME) */ -function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) -{ +function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) { var TIP = _getTIP(aWindow, aCallback); if (!TIP) { return; } var KeyboardEvent = _getKeyboardEvent(aWindow); - if (!aEvent.composition || !aEvent.composition.clauses || - !aEvent.composition.clauses[0]) { + if ( + !aEvent.composition || + !aEvent.composition.clauses || + !aEvent.composition.clauses[0] + ) { return; } @@ -1771,8 +2111,9 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) case TIP.ATTR_CONVERTED_CLAUSE: case TIP.ATTR_SELECTED_CLAUSE: TIP.appendClauseToPendingComposition( - aEvent.composition.clauses[i].length, - aEvent.composition.clauses[i].attr); + aEvent.composition.clauses[i].length, + aEvent.composition.clauses[i].attr + ); break; case 0: // Ignore dummy clause for the argument. @@ -1790,21 +2131,31 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) var modifiers = _emulateToActivateModifiers(TIP, aEvent.key, aWindow); try { - var keyEventDict = {dictionary: null, flags: 0}; + var keyEventDict = { dictionary: null, flags: 0 }; var keyEvent = null; if (aEvent.key && typeof aEvent.key.key === "string") { - keyEventDict = - _createKeyboardEventDictionary(aEvent.key.key, aEvent.key, - TIP, aWindow); - keyEvent = new KeyboardEvent(aEvent.key.type === "keydown" ? - "keydown" : - aEvent.key.type === "keyup" ? - "keyup" : "", - keyEventDict.dictionary) + keyEventDict = _createKeyboardEventDictionary( + aEvent.key.key, + aEvent.key, + TIP, + aWindow + ); + keyEvent = new KeyboardEvent( + aEvent.key.type === "keydown" + ? "keydown" + : aEvent.key.type === "keyup" + ? "keyup" + : "", + keyEventDict.dictionary + ); } else if (aEvent.key === undefined) { - keyEventDict = - _createKeyboardEventDictionary("KEY_Process", {}, TIP, aWindow); - keyEvent = new KeyboardEvent("", keyEventDict.dictionary) + keyEventDict = _createKeyboardEventDictionary( + "KEY_Process", + {}, + TIP, + aWindow + ); + keyEvent = new KeyboardEvent("", keyEventDict.dictionary); } TIP.flushPendingComposition(keyEvent, keyEventDict.flags); } finally { @@ -1813,25 +2164,25 @@ function synthesizeCompositionChange(aEvent, aWindow = window, aCallback) } // Must be synchronized with nsIDOMWindowUtils. -const QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; -const QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK = 0x0001; +const QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; +const QUERY_CONTENT_FLAG_USE_XP_LINE_BREAK = 0x0001; -const QUERY_CONTENT_FLAG_SELECTION_NORMAL = 0x0000; -const QUERY_CONTENT_FLAG_SELECTION_SPELLCHECK = 0x0002; -const QUERY_CONTENT_FLAG_SELECTION_IME_RAWINPUT = 0x0004; -const QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDRAWTEXT = 0x0008; -const QUERY_CONTENT_FLAG_SELECTION_IME_CONVERTEDTEXT = 0x0010; +const QUERY_CONTENT_FLAG_SELECTION_NORMAL = 0x0000; +const QUERY_CONTENT_FLAG_SELECTION_SPELLCHECK = 0x0002; +const QUERY_CONTENT_FLAG_SELECTION_IME_RAWINPUT = 0x0004; +const QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDRAWTEXT = 0x0008; +const QUERY_CONTENT_FLAG_SELECTION_IME_CONVERTEDTEXT = 0x0010; const QUERY_CONTENT_FLAG_SELECTION_IME_SELECTEDCONVERTEDTEXT = 0x0020; -const QUERY_CONTENT_FLAG_SELECTION_ACCESSIBILITY = 0x0040; -const QUERY_CONTENT_FLAG_SELECTION_FIND = 0x0080; -const QUERY_CONTENT_FLAG_SELECTION_URLSECONDARY = 0x0100; -const QUERY_CONTENT_FLAG_SELECTION_URLSTRIKEOUT = 0x0200; +const QUERY_CONTENT_FLAG_SELECTION_ACCESSIBILITY = 0x0040; +const QUERY_CONTENT_FLAG_SELECTION_FIND = 0x0080; +const QUERY_CONTENT_FLAG_SELECTION_URLSECONDARY = 0x0100; +const QUERY_CONTENT_FLAG_SELECTION_URLSTRIKEOUT = 0x0200; -const QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT = 0x0400; +const QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT = 0x0400; -const SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; -const SELECTION_SET_FLAG_USE_XP_LINE_BREAK = 0x0001; -const SELECTION_SET_FLAG_REVERSE = 0x0002; +const SELECTION_SET_FLAG_USE_NATIVE_LINE_BREAK = 0x0000; +const SELECTION_SET_FLAG_USE_XP_LINE_BREAK = 0x0001; +const SELECTION_SET_FLAG_REVERSE = 0x0002; /** * Synthesize a query text content event. @@ -1846,8 +2197,7 @@ const SELECTION_SET_FLAG_REVERSE = 0x0002; * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) -{ +function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return nullptr; @@ -1856,8 +2206,14 @@ function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) if (aIsRelative === true) { flags |= QUERY_CONTENT_FLAG_OFFSET_RELATIVE_TO_INSERTION_POINT; } - return utils.sendQueryContentEvent(utils.QUERY_TEXT_CONTENT, - aOffset, aLength, 0, 0, flags); + return utils.sendQueryContentEvent( + utils.QUERY_TEXT_CONTENT, + aOffset, + aLength, + 0, + 0, + flags + ); } /** @@ -1870,8 +2226,7 @@ function synthesizeQueryTextContent(aOffset, aLength, aIsRelative, aWindow) * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeQuerySelectedText(aSelectionType, aWindow) -{ +function synthesizeQuerySelectedText(aSelectionType, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return null; @@ -1882,8 +2237,14 @@ function synthesizeQuerySelectedText(aSelectionType, aWindow) flags |= aSelectionType; } - return utils.sendQueryContentEvent(utils.QUERY_SELECTED_TEXT, 0, 0, 0, 0, - flags); + return utils.sendQueryContentEvent( + utils.QUERY_SELECTED_TEXT, + 0, + 0, + 0, + 0, + flags + ); } /** @@ -1895,15 +2256,19 @@ function synthesizeQuerySelectedText(aSelectionType, aWindow) * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeQueryCaretRect(aOffset, aWindow) -{ +function synthesizeQueryCaretRect(aOffset, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return null; } - return utils.sendQueryContentEvent(utils.QUERY_CARET_RECT, - aOffset, 0, 0, 0, - QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK); + return utils.sendQueryContentEvent( + utils.QUERY_CARET_RECT, + aOffset, + 0, + 0, + 0, + QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK + ); } /** @@ -1918,8 +2283,7 @@ function synthesizeQueryCaretRect(aOffset, aWindow) * @param aWindow Optional (If null, current |window| will be used) * @return True, if succeeded. Otherwise false. */ -function synthesizeSelectionSet(aOffset, aLength, aReverse, aWindow) -{ +function synthesizeSelectionSet(aOffset, aLength, aReverse, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return false; @@ -1937,13 +2301,16 @@ function synthesizeSelectionSet(aOffset, aLength, aReverse, aWindow) * when the library or any of function are not found, or something goes wrong * in native functions. */ -function synthesizeNativeOSXClick(x, y) -{ +function synthesizeNativeOSXClick(x, y) { var { ctypes } = _EU_Cu.import("resource://gre/modules/ctypes.jsm", {}); // Library - var CoreFoundation = ctypes.open("/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation"); - var CoreGraphics = ctypes.open("/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics"); + var CoreFoundation = ctypes.open( + "/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation" + ); + var CoreGraphics = ctypes.open( + "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics" + ); // Contants var kCGEventLeftMouseDown = 1; @@ -1963,36 +2330,48 @@ function synthesizeNativeOSXClick(x, y) var CGFloat = ctypes.voidptr_t.size == 4 ? ctypes.float : ctypes.double; var CGMouseButton = ctypes.uint32_t; - var CGPoint = new ctypes.StructType( - "CGPoint", - [ { "x" : CGFloat }, - { "y" : CGFloat } ]); + var CGPoint = new ctypes.StructType("CGPoint", [ + { x: CGFloat }, + { y: CGFloat }, + ]); // Functions var CGEventSourceCreate = CoreGraphics.declare( "CGEventSourceCreate", ctypes.default_abi, - CGEventSourceRef, CGEventSourceStateID); + CGEventSourceRef, + CGEventSourceStateID + ); var CGEventCreateMouseEvent = CoreGraphics.declare( "CGEventCreateMouseEvent", ctypes.default_abi, CGEventRef, - CGEventSourceRef, CGEventType, CGPoint, CGMouseButton); + CGEventSourceRef, + CGEventType, + CGPoint, + CGMouseButton + ); var CGEventSetIntegerValueField = CoreGraphics.declare( "CGEventSetIntegerValueField", ctypes.default_abi, ctypes.void_t, - CGEventRef, CGEventField, ctypes.int64_t); + CGEventRef, + CGEventField, + ctypes.int64_t + ); var CGEventPost = CoreGraphics.declare( "CGEventPost", ctypes.default_abi, ctypes.void_t, - CGEventTapLocation, CGEventRef); + CGEventTapLocation, + CGEventRef + ); var CFRelease = CoreFoundation.declare( "CFRelease", ctypes.default_abi, ctypes.void_t, - CGEventRef); + CGEventRef + ); var source = CGEventSourceCreate(kCGEventSourceStateHIDSystemState); if (!source) { @@ -2000,23 +2379,37 @@ function synthesizeNativeOSXClick(x, y) } var loc = new CGPoint({ x: x, y: y }); - var event = CGEventCreateMouseEvent(source, kCGEventLeftMouseDown, loc, - kCGMouseButtonLeft); + var event = CGEventCreateMouseEvent( + source, + kCGEventLeftMouseDown, + loc, + kCGMouseButtonLeft + ); if (!event) { throw new Error("CGEventCreateMouseEvent returns null"); } - CGEventSetIntegerValueField(event, kCGMouseEventClickState, - new ctypes.Int64(1)); + CGEventSetIntegerValueField( + event, + kCGMouseEventClickState, + new ctypes.Int64(1) + ); CGEventPost(kCGHIDEventTap, event); CFRelease(event); - event = CGEventCreateMouseEvent(source, kCGEventLeftMouseUp, loc, - kCGMouseButtonLeft); + event = CGEventCreateMouseEvent( + source, + kCGEventLeftMouseUp, + loc, + kCGMouseButtonLeft + ); if (!event) { throw new Error("CGEventCreateMouseEvent returns null"); } - CGEventSetIntegerValueField(event, kCGMouseEventClickState, - new ctypes.Int64(1)); + CGEventSetIntegerValueField( + event, + kCGMouseEventClickState, + new ctypes.Int64(1) + ); CGEventPost(kCGHIDEventTap, event); CFRelease(event); @@ -2046,10 +2439,8 @@ function synthesizeNativeOSXClick(x, y) * see bug 462172 for example of use * */ -function synthesizeDragStart(element, expectedDragData, aWindow, x, y) -{ - if (!aWindow) - aWindow = window; +function synthesizeDragStart(element, expectedDragData, aWindow, x, y) { + if (!aWindow) aWindow = window; x = x || 2; y = y || 2; const step = 9; @@ -2060,38 +2451,42 @@ function synthesizeDragStart(element, expectedDragData, aWindow, x, y) // We must wrap only in plain mochitests, not chrome var dataTransfer = _EU_maybeWrap(event.dataTransfer); result = null; - if (!dataTransfer) - throw "no dataTransfer"; - if (expectedDragData == null || - dataTransfer.mozItemCount != expectedDragData.length) + if (!dataTransfer) throw "no dataTransfer"; + if ( + expectedDragData == null || + dataTransfer.mozItemCount != expectedDragData.length + ) throw dataTransfer; for (var i = 0; i < dataTransfer.mozItemCount; i++) { var dtTypes = dataTransfer.mozTypesAt(i); - if (dtTypes.length != expectedDragData[i].length) - throw dataTransfer; + if (dtTypes.length != expectedDragData[i].length) throw dataTransfer; for (var j = 0; j < dtTypes.length; j++) { - if (dtTypes[j] != expectedDragData[i][j].type) - throw dataTransfer; - var dtData = dataTransfer.mozGetDataAt(dtTypes[j],i); + if (dtTypes[j] != expectedDragData[i][j].type) throw dataTransfer; + var dtData = dataTransfer.mozGetDataAt(dtTypes[j], i); if (expectedDragData[i][j].eqTest) { - if (!expectedDragData[i][j].eqTest(dtData, expectedDragData[i][j].data)) + if ( + !expectedDragData[i][j].eqTest( + dtData, + expectedDragData[i][j].data + ) + ) throw dataTransfer; - } - else if (expectedDragData[i][j].data != dtData) - throw dataTransfer; + } else if (expectedDragData[i][j].data != dtData) throw dataTransfer; } } - } catch(ex) { + } catch (ex) { result = ex; } event.preventDefault(); event.stopPropagation(); - } + }; aWindow.addEventListener("dragstart", trapDrag); synthesizeMouse(element, x, y, { type: "mousedown" }, aWindow); - x += step; y += step; + x += step; + y += step; synthesizeMouse(element, x, y, { type: "mousemove" }, aWindow); - x += step; y += step; + x += step; + y += step; synthesizeMouse(element, x, y, { type: "mousemove" }, aWindow); aWindow.removeEventListener("dragstart", trapDrag); synthesizeMouse(element, x, y, { type: "mouseup" }, aWindow); @@ -2109,15 +2504,19 @@ function synthesizeDragStart(element, expectedDragData, aWindow, x, y) * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeQueryTextRect(aOffset, aLength, aWindow) -{ +function synthesizeQueryTextRect(aOffset, aLength, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return nullptr; } - return utils.sendQueryContentEvent(utils.QUERY_TEXT_RECT, - aOffset, aLength, 0, 0, - QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK); + return utils.sendQueryContentEvent( + utils.QUERY_TEXT_RECT, + aOffset, + aLength, + 0, + 0, + QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK + ); } /** @@ -2131,15 +2530,19 @@ function synthesizeQueryTextRect(aOffset, aLength, aWindow) * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) -{ +function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return nullptr; } - return utils.sendQueryContentEvent(utils.QUERY_TEXT_RECT_ARRAY, - aOffset, aLength, 0, 0, - QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK); + return utils.sendQueryContentEvent( + utils.QUERY_TEXT_RECT_ARRAY, + aOffset, + aLength, + 0, + 0, + QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK + ); } /** @@ -2149,14 +2552,19 @@ function synthesizeQueryTextRectArray(aOffset, aLength, aWindow) * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeQueryEditorRect(aWindow) -{ +function synthesizeQueryEditorRect(aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return nullptr; } - return utils.sendQueryContentEvent(utils.QUERY_EDITOR_RECT, 0, 0, 0, 0, - QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK); + return utils.sendQueryContentEvent( + utils.QUERY_EDITOR_RECT, + 0, + 0, + 0, + 0, + QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK + ); } /** @@ -2167,15 +2575,19 @@ function synthesizeQueryEditorRect(aWindow) * @return An nsIQueryContentEventResult object. If this failed, * the result might be null. */ -function synthesizeCharAtPoint(aX, aY, aWindow) -{ +function synthesizeCharAtPoint(aX, aY, aWindow) { var utils = _getDOMWindowUtils(aWindow); if (!utils) { return nullptr; } - return utils.sendQueryContentEvent(utils.QUERY_CHARACTER_AT_POINT, - 0, 0, aX, aY, - QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK); + return utils.sendQueryContentEvent( + utils.QUERY_CHARACTER_AT_POINT, + 0, + 0, + aX, + aY, + QUERY_CONTENT_FLAG_USE_NATIVE_LINE_BREAK + ); } /** @@ -2191,9 +2603,13 @@ function synthesizeCharAtPoint(aX, aY, aWindow) * object * @return An object to pass to sendDragEvent. */ -function createDragEventObject(aType, aDestElement, aDestWindow, aDataTransfer, - aDragEvent) -{ +function createDragEventObject( + aType, + aDestElement, + aDestWindow, + aDataTransfer, + aDragEvent +) { var destRect = aDestElement.getBoundingClientRect(); var destClientX = destRect.left + destRect.width / 2; var destClientY = destRect.top + destRect.height / 2; @@ -2207,20 +2623,27 @@ function createDragEventObject(aType, aDestElement, aDestWindow, aDataTransfer, } // Wrap only in plain mochitests - let dataTransfer = _EU_maybeUnwrap(_EU_maybeWrap(aDataTransfer).mozCloneForEvent(aType)); + let dataTransfer = _EU_maybeUnwrap( + _EU_maybeWrap(aDataTransfer).mozCloneForEvent(aType) + ); // Copy over the drop effect. This isn't copied over by Clone, as it uses more // complex logic in the actual implementation (see // nsContentUtils::SetDataTransferInEvent for actual impl). dataTransfer.dropEffect = aDataTransfer.dropEffect; - return Object.assign({ - type: aType, - screenX: destScreenX, screenY: destScreenY, - clientX: destClientX, clientY: destClientY, - dataTransfer: dataTransfer, - _domDispatchOnly: aDragEvent._domDispatchOnly, - }, aDragEvent); + return Object.assign( + { + type: aType, + screenX: destScreenX, + screenY: destScreenY, + clientX: destClientX, + clientY: destClientY, + dataTransfer: dataTransfer, + _domDispatchOnly: aDragEvent._domDispatchOnly, + }, + aDragEvent + ); } /** @@ -2245,8 +2668,15 @@ function createDragEventObject(aType, aDestElement, aDestWindow, aDataTransfer, * dragover event, and the second element is the * dataTransfer for the current drag session. */ -function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, aWindow, aDestWindow, aDragEvent={}) -{ +function synthesizeDragOver( + aSrcElement, + aDestElement, + aDragData, + aDropEffect, + aWindow, + aDestWindow, + aDragEvent = {} +) { if (!aWindow) { aWindow = window; } @@ -2254,8 +2684,12 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a aDestWindow = aWindow; } - const obs = _EU_Cc["@mozilla.org/observer-service;1"].getService(_EU_Ci.nsIObserverService); - const ds = _EU_Cc["@mozilla.org/widget/dragservice;1"].getService(_EU_Ci.nsIDragService); + const obs = _EU_Cc["@mozilla.org/observer-service;1"].getService( + _EU_Ci.nsIObserverService + ); + const ds = _EU_Cc["@mozilla.org/widget/dragservice;1"].getService( + _EU_Ci.nsIDragService + ); var sess = ds.getCurrentSession(); // This method runs before other callbacks, and acts as a way to inject the @@ -2265,7 +2699,11 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a for (var i = 0; i < aDragData.length; i++) { var item = aDragData[i]; for (var j = 0; j < item.length; j++) { - _EU_maybeWrap(event.dataTransfer).mozSetDataAt(item[j].type, item[j].data, i); + _EU_maybeWrap(event.dataTransfer).mozSetDataAt( + item[j].type, + item[j].data, + i + ); } } } @@ -2275,7 +2713,9 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a function trapDrag(subject, topic) { if (topic == "on-datatransfer-available") { - sess.dataTransfer = _EU_maybeUnwrap(_EU_maybeWrap(subject).mozCloneForEvent("drop")); + sess.dataTransfer = _EU_maybeUnwrap( + _EU_maybeWrap(subject).mozCloneForEvent("drop") + ); sess.dataTransfer.dropEffect = subject.dropEffect; } } @@ -2289,7 +2729,7 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a var x = rect.width / 2; var y = rect.height / 2; synthesizeMouse(aSrcElement, x, y, { type: "mousemove" }, aWindow); - synthesizeMouse(aSrcElement, x+10, y+10, { type: "mousemove" }, aWindow); + synthesizeMouse(aSrcElement, x + 10, y + 10, { type: "mousemove" }, aWindow); aWindow.removeEventListener("dragstart", fillDrag, true); obs.removeObserver(trapDrag, "on-datatransfer-available"); @@ -2299,8 +2739,13 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a } // The EventStateManager will fire our dragenter event if it needs to. - var event = createDragEventObject("dragover", aDestElement, aDestWindow, - dataTransfer, aDragEvent); + var event = createDragEventObject( + "dragover", + aDestElement, + aDestWindow, + dataTransfer, + aDragEvent + ); var result = sendDragEvent(event, aDestElement, aDestWindow); return [result, dataTransfer]; @@ -2321,8 +2766,13 @@ function synthesizeDragOver(aSrcElement, aDestElement, aDragData, aDropEffect, a * @return "none" if aResult is true, * aDataTransfer.dropEffect otherwise. */ -function synthesizeDropAfterDragOver(aResult, aDataTransfer, aDestElement, aDestWindow, aDragEvent={}) -{ +function synthesizeDropAfterDragOver( + aResult, + aDataTransfer, + aDestElement, + aDestWindow, + aDragEvent = {} +) { if (!aDestWindow) { aDestWindow = window; } @@ -2333,8 +2783,13 @@ function synthesizeDropAfterDragOver(aResult, aDataTransfer, aDestElement, aDest if (aResult) { effect = "none"; } else if (effect != "none") { - event = createDragEventObject("drop", aDestElement, aDestWindow, - aDataTransfer, aDragEvent); + event = createDragEventObject( + "drop", + aDestElement, + aDestWindow, + aDataTransfer, + aDragEvent + ); sendDragEvent(event, aDestElement, aDestWindow); } synthesizeMouse(aDestElement, 2, 2, { type: "mouseup" }, aDestWindow); @@ -2362,8 +2817,15 @@ function synthesizeDropAfterDragOver(aResult, aDataTransfer, aDestElement, aDest * passed to sendDragEvent. * @return The drop effect that was desired. */ -function synthesizeDrop(aSrcElement, aDestElement, aDragData, aDropEffect, aWindow, aDestWindow, aDragEvent={}) -{ +function synthesizeDrop( + aSrcElement, + aDestElement, + aDragData, + aDropEffect, + aWindow, + aDestWindow, + aDragEvent = {} +) { if (!aWindow) { aWindow = window; } @@ -2371,18 +2833,29 @@ function synthesizeDrop(aSrcElement, aDestElement, aDragData, aDropEffect, aWind aDestWindow = aWindow; } - var ds = _EU_Cc["@mozilla.org/widget/dragservice;1"] - .getService(_EU_Ci.nsIDragService); + var ds = _EU_Cc["@mozilla.org/widget/dragservice;1"].getService( + _EU_Ci.nsIDragService + ); ds.startDragSession(); try { - var [result, dataTransfer] = synthesizeDragOver(aSrcElement, aDestElement, - aDragData, aDropEffect, - aWindow, aDestWindow, - aDragEvent); - return synthesizeDropAfterDragOver(result, dataTransfer, aDestElement, - aDestWindow, aDragEvent); + var [result, dataTransfer] = synthesizeDragOver( + aSrcElement, + aDestElement, + aDragData, + aDropEffect, + aWindow, + aDestWindow, + aDragEvent + ); + return synthesizeDropAfterDragOver( + result, + dataTransfer, + aDestElement, + aDestWindow, + aDragEvent + ); } finally { ds.endDragSession(true, _parseModifiers(aDragEvent)); } @@ -2411,8 +2884,7 @@ function synthesizeDrop(aSrcElement, aDestElement, aDragData, aDropEffect, aWind * defaults to the current window object * } */ -async function synthesizePlainDragAndDrop(aParams) -{ +async function synthesizePlainDragAndDrop(aParams) { let { srcElement, destElement, @@ -2426,8 +2898,9 @@ async function synthesizePlainDragAndDrop(aParams) destWindow = window, } = aParams; - const ds = _EU_Cc["@mozilla.org/widget/dragservice;1"] - .getService(_EU_Ci.nsIDragService); + const ds = _EU_Cc["@mozilla.org/widget/dragservice;1"].getService( + _EU_Ci.nsIDragService + ); ds.startDragSession(); try { @@ -2442,12 +2915,14 @@ async function synthesizePlainDragAndDrop(aParams) // (e.g. menu) work like the real user input. await new Promise(r => setTimeout(r, 0)); - srcX += stepX; srcY += stepY; + srcX += stepX; + srcY += stepY; synthesizeMouse(srcElement, srcX, srcY, { type: "mousemove" }, srcWindow); await new Promise(r => setTimeout(r, 0)); - srcX += stepX; srcY += stepY; + srcX += stepX; + srcY += stepY; synthesizeMouse(srcElement, srcX, srcY, { type: "mousemove" }, srcWindow); await new Promise(r => setTimeout(r, 0)); @@ -2461,35 +2936,48 @@ async function synthesizePlainDragAndDrop(aParams) // dragover and drop are only fired to a valid drop target. If the // destElement parameter is null, this function is being used to // simulate a drag'n'drop over an invalid drop target. - event = createDragEventObject("dragover", destElement, destWindow, - dataTransfer, {}); + event = createDragEventObject( + "dragover", + destElement, + destWindow, + dataTransfer, + {} + ); sendDragEvent(event, destElement, destWindow); await new Promise(r => setTimeout(r, 0)); - event = createDragEventObject("drop", destElement, destWindow, - dataTransfer, {}); + event = createDragEventObject( + "drop", + destElement, + destWindow, + dataTransfer, + {} + ); sendDragEvent(event, destElement, destWindow); } // dragend is fired, by definition, on the srcElement - event = createDragEventObject("dragend", srcElement, srcWindow, - dataTransfer, {clientX: finalX, clientY: finalY}); + event = createDragEventObject( + "dragend", + srcElement, + srcWindow, + dataTransfer, + { clientX: finalX, clientY: finalY } + ); sendDragEvent(event, srcElement, srcWindow); await new Promise(r => setTimeout(r, 0)); - } finally { ds.endDragSession(true, 0); } } -var PluginUtils = -{ - withTestPlugin : function(callback) - { - var ph = _EU_Cc["@mozilla.org/plugin/host;1"] - .getService(_EU_Ci.nsIPluginHost); +var PluginUtils = { + withTestPlugin: function(callback) { + var ph = _EU_Cc["@mozilla.org/plugin/host;1"].getService( + _EU_Ci.nsIPluginHost + ); var tags = ph.getPluginTags(); // Find the test plugin @@ -2501,7 +2989,7 @@ var PluginUtils = } todo(false, "Need a test plugin on this platform"); return false; - } + }, }; class EventCounter { @@ -2515,14 +3003,17 @@ class EventCounter { // SpecialPowers is picky and needs to be passed an explicit reference to // the function to be called. To avoid having to bind "this", we therefore // define the method this way, via a property. - this.handleEvent = (aEvent) => { - this.eventCount++; + this.handleEvent = aEvent => { + this.eventCount++; }; if (aOptions.mozSystemGroup) { - SpecialPowers.addSystemEventListener(aTarget, aType, - this.handleEvent, - aOptions.capture); + SpecialPowers.addSystemEventListener( + aTarget, + aType, + this.handleEvent, + aOptions.capture + ); } else { aTarget.addEventListener(aType, this, aOptions); } @@ -2530,9 +3021,12 @@ class EventCounter { unregister() { if (this.options.mozSystemGroup) { - SpecialPowers.removeSystemEventListener(this.target, this.type, - this.handleEvent, - this.options.capture); + SpecialPowers.removeSystemEventListener( + this.target, + this.type, + this.handleEvent, + this.options.capture + ); } else { this.target.removeEventListener(this.type, this, this.options); } diff --git a/toolkit/components/antitracking/test/browser/antitracking_head.js b/toolkit/components/antitracking/test/browser/antitracking_head.js index 4f13d620da17..aaf11136ef4e 100644 --- a/toolkit/components/antitracking/test/browser/antitracking_head.js +++ b/toolkit/components/antitracking/test/browser/antitracking_head.js @@ -507,18 +507,22 @@ this.AntiTracking = { options.cookieBehavior == BEHAVIOR_REJECT_TRACKER && !options.allowList; let id = await SpecialPowers.spawn( - browser, [{ - page: thirdPartyPage, - nextPage: TEST_4TH_PARTY_PAGE, - callback: options.callback.toString(), - callbackAfterRemoval: options.callbackAfterRemoval - ? options.callbackAfterRemoval.toString() - : null, - accessRemoval: options.accessRemoval, - iframeSandbox: options.iframeSandbox, - allowList: options.allowList, - doAccessRemovalChecks, - }], async function(obj) { + browser, + [ + { + page: thirdPartyPage, + nextPage: TEST_4TH_PARTY_PAGE, + callback: options.callback.toString(), + callbackAfterRemoval: options.callbackAfterRemoval + ? options.callbackAfterRemoval.toString() + : null, + accessRemoval: options.accessRemoval, + iframeSandbox: options.iframeSandbox, + allowList: options.allowList, + doAccessRemovalChecks, + }, + ], + async function(obj) { let id = "id" + Math.random(); await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); @@ -625,12 +629,16 @@ this.AntiTracking = { await pageshow; await SpecialPowers.spawn( - browser, [{ - id, - callbackAfterRemoval: options.callbackAfterRemoval - ? options.callbackAfterRemoval.toString() - : null, - }], async function(obj) { + browser, + [ + { + id, + callbackAfterRemoval: options.callbackAfterRemoval + ? options.callbackAfterRemoval.toString() + : null, + }, + ], + async function(obj) { let ifr = content.document.getElementById(obj.id); ifr.contentWindow.postMessage(obj.callbackAfterRemoval, "*"); @@ -768,12 +776,16 @@ this.AntiTracking = { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: pageURL, - blockingCallback: blockingCallback.toString(), - nonBlockingCallback: nonBlockingCallback.toString(), - iframeSandbox, - }], async function(obj) { + browser, + [ + { + page: pageURL, + blockingCallback: blockingCallback.toString(), + nonBlockingCallback: nonBlockingCallback.toString(), + iframeSandbox, + }, + ], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = function() { @@ -847,12 +859,16 @@ this.AntiTracking = { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_UI, - popup: TEST_POPUP_PAGE, - blockingCallback: blockingCallback.toString(), - iframeSandbox, - }], async function(obj) { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_UI, + popup: TEST_POPUP_PAGE, + blockingCallback: blockingCallback.toString(), + iframeSandbox, + }, + ], + async function(obj) { let ifr = content.document.createElement("iframe"); let loading = new content.Promise(resolve => { ifr.onload = resolve; @@ -947,12 +963,16 @@ this.AntiTracking = { await AntiTracking.interactWithTracker(); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_UI, - popup: TEST_POPUP_PAGE, - nonBlockingCallback: nonBlockingCallback.toString(), - iframeSandbox, - }], async function(obj) { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_UI, + popup: TEST_POPUP_PAGE, + nonBlockingCallback: nonBlockingCallback.toString(), + iframeSandbox, + }, + ], + async function(obj) { let ifr = content.document.createElement("iframe"); let loading = new content.Promise(resolve => { ifr.onload = resolve; diff --git a/toolkit/components/antitracking/test/browser/browser_allowListNotifications.js b/toolkit/components/antitracking/test/browser/browser_allowListNotifications.js index 5199ed45257f..0143eb243c96 100644 --- a/toolkit/components/antitracking/test/browser/browser_allowListNotifications.js +++ b/toolkit/components/antitracking/test/browser/browser_allowListNotifications.js @@ -48,11 +48,15 @@ add_task(async function() { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE, - blockingCallback: (async _ => {}).toString(), - nonBlockingCallback: (async _ => {}).toString(), - }], async function(obj) { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE, + blockingCallback: (async _ => {}).toString(), + nonBlockingCallback: (async _ => {}).toString(), + }, + ], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = function() { diff --git a/toolkit/components/antitracking/test/browser/browser_backgroundImageAssertion.js b/toolkit/components/antitracking/test/browser/browser_backgroundImageAssertion.js index 334aa6499493..35712f27c4e5 100644 --- a/toolkit/components/antitracking/test/browser/browser_backgroundImageAssertion.js +++ b/toolkit/components/antitracking/test/browser/browser_backgroundImageAssertion.js @@ -27,7 +27,9 @@ add_task(async function() { await BrowserTestUtils.browserLoaded(browser); await SpecialPowers.spawn( - browser, [{ page: TEST_3RD_PARTY_PAGE_WITH_SVG }], async function(obj) { + browser, + [{ page: TEST_3RD_PARTY_PAGE_WITH_SVG }], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); diff --git a/toolkit/components/antitracking/test/browser/browser_doublyNestedTracker.js b/toolkit/components/antitracking/test/browser/browser_doublyNestedTracker.js index 8ce3d9137f25..4715b83d195f 100644 --- a/toolkit/components/antitracking/test/browser/browser_doublyNestedTracker.js +++ b/toolkit/components/antitracking/test/browser/browser_doublyNestedTracker.js @@ -67,7 +67,9 @@ add_task(async function() { } await SpecialPowers.spawn( - browser, [{ page: TEST_ANOTHER_3RD_PARTY_PAGE, callback: loadSubpage.toString() }], async function(obj) { + browser, + [{ page: TEST_ANOTHER_3RD_PARTY_PAGE, callback: loadSubpage.toString() }], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = _ => { diff --git a/toolkit/components/antitracking/test/browser/browser_existingCookiesForSubresources.js b/toolkit/components/antitracking/test/browser/browser_existingCookiesForSubresources.js index 75bdc5085b32..78dfaccef606 100644 --- a/toolkit/components/antitracking/test/browser/browser_existingCookiesForSubresources.js +++ b/toolkit/components/antitracking/test/browser/browser_existingCookiesForSubresources.js @@ -116,7 +116,9 @@ add_task(async function() { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ page: TEST_3RD_PARTY_PAGE, callback: (async _ => {}).toString() }], async function(obj) { + browser, + [{ page: TEST_3RD_PARTY_PAGE, callback: (async _ => {}).toString() }], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = function() { diff --git a/toolkit/components/antitracking/test/browser/browser_localStorageEvents.js b/toolkit/components/antitracking/test/browser/browser_localStorageEvents.js index d3787f951bcc..c77465114f37 100644 --- a/toolkit/components/antitracking/test/browser/browser_localStorageEvents.js +++ b/toolkit/components/antitracking/test/browser/browser_localStorageEvents.js @@ -28,9 +28,13 @@ add_task(async function testLocalStorageEventPropagation() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_DOMAIN + TEST_PATH + "localStorage.html", - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_DOMAIN + TEST_PATH + "localStorage.html", + }, + ], + async obj => { info("Creating tracker iframe"); let ifr = content.document.createElement("iframe"); @@ -109,9 +113,13 @@ add_task(async function testBlockedLocalStorageEventPropagation() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_DOMAIN + TEST_PATH + "localStorage.html", - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_DOMAIN + TEST_PATH + "localStorage.html", + }, + ], + async obj => { info("Creating tracker iframe"); let ifr = content.document.createElement("iframe"); diff --git a/toolkit/components/antitracking/test/browser/browser_onModifyRequestNotificationForTrackingResources.js b/toolkit/components/antitracking/test/browser/browser_onModifyRequestNotificationForTrackingResources.js index c65b2e65a561..8a890e8c487f 100644 --- a/toolkit/components/antitracking/test/browser/browser_onModifyRequestNotificationForTrackingResources.js +++ b/toolkit/components/antitracking/test/browser/browser_onModifyRequestNotificationForTrackingResources.js @@ -77,7 +77,9 @@ add_task(async function() { info("Verify the number of tracking nodes found"); await SpecialPowers.spawn( - browser, [{ expected: gExpectedResourcesSeen }], async function(obj) { + browser, + [{ expected: gExpectedResourcesSeen }], + async function(obj) { is( content.document.blockedNodeByClassifierCount, obj.expected, diff --git a/toolkit/components/antitracking/test/browser/browser_partitionedLocalStorage_events.js b/toolkit/components/antitracking/test/browser/browser_partitionedLocalStorage_events.js index ab56a627b4fa..566306119aba 100644 --- a/toolkit/components/antitracking/test/browser/browser_partitionedLocalStorage_events.js +++ b/toolkit/components/antitracking/test/browser/browser_partitionedLocalStorage_events.js @@ -95,9 +95,13 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + }, + ], + async obj => { let ifr = content.document.createElement("iframe"); ifr.setAttribute("id", "ifr"); ifr.setAttribute("src", obj.page); @@ -211,11 +215,15 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - withStoragePrincipalEnabled: test.withStoragePrincipalEnabled, - dynamicFPITest: test.dynamicFPITest, - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + withStoragePrincipalEnabled: test.withStoragePrincipalEnabled, + dynamicFPITest: test.dynamicFPITest, + }, + ], + async obj => { let ifr1 = content.document.createElement("iframe"); ifr1.setAttribute("id", "ifr1"); ifr1.setAttribute("src", obj.page); @@ -328,9 +336,13 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + }, + ], + async obj => { let ifr1 = content.document.createElement("iframe"); ifr1.setAttribute("id", "ifr1"); ifr1.setAttribute("src", obj.page); @@ -435,11 +447,15 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - withStoragePrincipalEnabled: test.withStoragePrincipalEnabled, - dynamicFPITest: test.dynamicFPITest, - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + withStoragePrincipalEnabled: test.withStoragePrincipalEnabled, + dynamicFPITest: test.dynamicFPITest, + }, + ], + async obj => { let ifr = content.document.createElement("iframe"); ifr.setAttribute("id", "ifr"); ifr.setAttribute("src", obj.page); @@ -529,9 +545,13 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + }, + ], + async obj => { let ifr = content.document.createElement("iframe"); ifr.setAttribute("id", "ifr"); ifr.setAttribute("src", obj.page); @@ -619,11 +639,15 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - withStoragePrincipalEnabled: test.withStoragePrincipalEnabled, - dynamicFPITest: test.dynamicFPITest, - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + withStoragePrincipalEnabled: test.withStoragePrincipalEnabled, + dynamicFPITest: test.dynamicFPITest, + }, + ], + async obj => { let ifr = content.document.createElement("iframe"); ifr.setAttribute("id", "ifr"); ifr.setAttribute("src", obj.page); @@ -713,9 +737,13 @@ function runAllTests(withStoragePrincipalEnabled, prefValue) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - normalBrowser, [{ - page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", - }], async obj => { + normalBrowser, + [ + { + page: thirdPartyDomain + TEST_PATH + "localStorageEvents.html", + }, + ], + async obj => { let ifr = content.document.createElement("iframe"); ifr.setAttribute("id", "ifr"); ifr.setAttribute("src", obj.page); diff --git a/toolkit/components/antitracking/test/browser/browser_script.js b/toolkit/components/antitracking/test/browser/browser_script.js index 423693d21306..b1dcb246e1c3 100644 --- a/toolkit/components/antitracking/test/browser/browser_script.js +++ b/toolkit/components/antitracking/test/browser/browser_script.js @@ -31,10 +31,14 @@ add_task(async function() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - scriptURL: TEST_DOMAIN + TEST_PATH + "tracker.js", - page: TEST_3RD_PARTY_PAGE, - }], async obj => { + browser, + [ + { + scriptURL: TEST_DOMAIN + TEST_PATH + "tracker.js", + page: TEST_3RD_PARTY_PAGE, + }, + ], + async obj => { info("Checking if permission is denied"); let callbackBlocked = async _ => { try { @@ -101,10 +105,14 @@ add_task(async function() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - scriptURL: TEST_DOMAIN + TEST_PATH + "tracker.js", - page: TEST_3RD_PARTY_PAGE, - }], async obj => { + browser, + [ + { + scriptURL: TEST_DOMAIN + TEST_PATH + "tracker.js", + page: TEST_3RD_PARTY_PAGE, + }, + ], + async obj => { info("Checking if permission is denied"); let callbackBlocked = async _ => { try { diff --git a/toolkit/components/antitracking/test/browser/browser_socialtracking.js b/toolkit/components/antitracking/test/browser/browser_socialtracking.js index ebe56014bffa..ae0a42f5ef52 100644 --- a/toolkit/components/antitracking/test/browser/browser_socialtracking.js +++ b/toolkit/components/antitracking/test/browser/browser_socialtracking.js @@ -6,12 +6,18 @@ function runTest(obj) { await SpecialPowers.pushPrefEnv({ set: [ ["dom.ipc.processCount", 1], - ["network.cookie.cookieBehavior", Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER], + [ + "network.cookie.cookieBehavior", + Ci.nsICookieService.BEHAVIOR_REJECT_TRACKER, + ], ["privacy.trackingprotection.enabled", false], ["privacy.trackingprotection.pbmode.enabled", false], ["privacy.trackingprotection.annotate_channels", true], ["privacy.storagePrincipal.enabledForTrackers", false], - ["privacy.trackingprotection.socialtracking.enabled", obj.protectionEnabled], + [ + "privacy.trackingprotection.socialtracking.enabled", + obj.protectionEnabled, + ], ["privacy.socialtracking.block_cookies.enabled", obj.cookieBlocking], ], }); @@ -25,12 +31,16 @@ function runTest(obj) { info("The non-tracker page opens a tracker iframe"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_DOMAIN_STP + TEST_PATH + "localStorage.html", - image: TEST_3RD_PARTY_DOMAIN_STP + TEST_PATH + "raptor.jpg", - loading: obj.loading, - result: obj.result, - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_DOMAIN_STP + TEST_PATH + "localStorage.html", + image: TEST_3RD_PARTY_DOMAIN_STP + TEST_PATH + "raptor.jpg", + loading: obj.loading, + result: obj.result, + }, + ], + async obj => { let loading = await new content.Promise(resolve => { let image = new content.Image(); image.src = obj.image + "?" + Math.random(); @@ -52,8 +62,13 @@ function runTest(obj) { }); let p = new Promise(resolve => { - content.addEventListener("message", e => { resolve(e.data); }, - { once: true }); + content.addEventListener( + "message", + e => { + resolve(e.data); + }, + { once: true } + ); }); info("Setting localStorage value..."); @@ -90,19 +105,21 @@ function runTest(obj) { } runTest({ - testName: "Socialtracking-annotation feature enabled but not considered for tracking detection.", + testName: + "Socialtracking-annotation feature enabled but not considered for tracking detection.", protectionEnabled: false, loading: true, cookieBlocking: false, result: true, expectedLogItems: [ [Ci.nsIWebProgressListener.STATE_COOKIES_LOADED, true, 1], - [Ci.nsIWebProgressListener.STATE_COOKIES_LOADED_SOCIALTRACKER, true, 1] + [Ci.nsIWebProgressListener.STATE_COOKIES_LOADED_SOCIALTRACKER, true, 1], ], }); runTest({ - testName: "Socialtracking-annotation feature enabled and considered for tracking detection.", + testName: + "Socialtracking-annotation feature enabled and considered for tracking detection.", protectionEnabled: false, loading: true, cookieBlocking: true, @@ -111,7 +128,7 @@ runTest({ [Ci.nsIWebProgressListener.STATE_COOKIES_LOADED, true, 1], [Ci.nsIWebProgressListener.STATE_COOKIES_LOADED_SOCIALTRACKER, true, 1], [Ci.nsIWebProgressListener.STATE_LOADED_SOCIALTRACKING_CONTENT, true, 2], - [Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_SOCIALTRACKER, true, 2] + [Ci.nsIWebProgressListener.STATE_COOKIES_BLOCKED_SOCIALTRACKER, true, 2], ], }); @@ -122,6 +139,6 @@ runTest({ cookieBlocking: true, result: false, expectedLogItems: [ - [Ci.nsIWebProgressListener.STATE_BLOCKED_SOCIALTRACKING_CONTENT, true, 1] + [Ci.nsIWebProgressListener.STATE_BLOCKED_SOCIALTRACKING_CONTENT, true, 1], ], }); diff --git a/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js b/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js index a09aad297050..e14791722f18 100644 --- a/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js +++ b/toolkit/components/antitracking/test/browser/browser_storageAccessDoorHanger.js @@ -179,7 +179,9 @@ async function testDoorHanger( let url = TEST_3RD_PARTY_PAGE + "?disableWaitUntilPermission"; let ct = SpecialPowers.spawn( - browser, [{ page: url, callback: runChecks.toString(), choice, useEscape }], async function(obj) { + browser, + [{ page: url, callback: runChecks.toString(), choice, useEscape }], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = function() { diff --git a/toolkit/components/antitracking/test/browser/browser_storageAccessWithHeuristics.js b/toolkit/components/antitracking/test/browser/browser_storageAccessWithHeuristics.js index e214a1223eb9..0e775890b6bb 100644 --- a/toolkit/components/antitracking/test/browser/browser_storageAccessWithHeuristics.js +++ b/toolkit/components/antitracking/test/browser/browser_storageAccessWithHeuristics.js @@ -36,9 +36,13 @@ add_task(async function testWindowOpenHeuristic() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_WO, - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_WO, + }, + ], + async obj => { let msg = {}; msg.blockingCallback = (async _ => { /* import-globals-from storageAccessAPIHelpers.js */ @@ -109,10 +113,14 @@ add_task(async function testUserInteractionHeuristic() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_UI, - popup: TEST_POPUP_PAGE, - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_UI, + popup: TEST_POPUP_PAGE, + }, + ], + async obj => { let msg = {}; msg.blockingCallback = (async _ => { /* import-globals-from storageAccessAPIHelpers.js */ @@ -204,10 +212,14 @@ add_task(async function testUserInteractionHeuristic() { info("Loading tracking scripts"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_UI, - popup: TEST_POPUP_PAGE, - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_UI, + popup: TEST_POPUP_PAGE, + }, + ], + async obj => { let msg = {}; msg.blockingCallback = (async _ => { await noStorageAccessInitially(); diff --git a/toolkit/components/antitracking/test/browser/browser_subResources.js b/toolkit/components/antitracking/test/browser/browser_subResources.js index 34ee9f60d5eb..0608f5193afc 100644 --- a/toolkit/components/antitracking/test/browser/browser_subResources.js +++ b/toolkit/components/antitracking/test/browser/browser_subResources.js @@ -92,11 +92,15 @@ add_task(async function() { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_WO, - blockingCallback: (async _ => {}).toString(), - nonBlockingCallback: (async _ => {}).toString(), - }], async function(obj) { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_WO, + blockingCallback: (async _ => {}).toString(), + nonBlockingCallback: (async _ => {}).toString(), + }, + ], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = function() { diff --git a/toolkit/components/antitracking/test/browser/browser_subResourcesPartitioned.js b/toolkit/components/antitracking/test/browser/browser_subResourcesPartitioned.js index 8763079300b3..9efbf1273ab9 100644 --- a/toolkit/components/antitracking/test/browser/browser_subResourcesPartitioned.js +++ b/toolkit/components/antitracking/test/browser/browser_subResourcesPartitioned.js @@ -71,11 +71,15 @@ async function runTests(topPage) { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_PAGE_WO, - blockingCallback: (async _ => {}).toString(), - nonBlockingCallback: (async _ => {}).toString(), - }], async function(obj) { + browser, + [ + { + page: TEST_3RD_PARTY_PAGE_WO, + blockingCallback: (async _ => {}).toString(), + nonBlockingCallback: (async _ => {}).toString(), + }, + ], + async function(obj) { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = function() { diff --git a/toolkit/components/antitracking/test/browser/dynamicfpi_head.js b/toolkit/components/antitracking/test/browser/dynamicfpi_head.js index 15689fde449a..f086dc5e4f0f 100644 --- a/toolkit/components/antitracking/test/browser/dynamicfpi_head.js +++ b/toolkit/components/antitracking/test/browser/dynamicfpi_head.js @@ -56,10 +56,14 @@ this.DynamicFPIHelper = { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: TEST_4TH_PARTY_STORAGE_PAGE, - callback: callback.toString(), - }], async obj => { + browser, + [ + { + page: TEST_4TH_PARTY_STORAGE_PAGE, + callback: callback.toString(), + }, + ], + async obj => { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = __ => { diff --git a/toolkit/components/antitracking/test/browser/partitionedstorage_head.js b/toolkit/components/antitracking/test/browser/partitionedstorage_head.js index be53bbe6f0a3..25511b6a0bc0 100644 --- a/toolkit/components/antitracking/test/browser/partitionedstorage_head.js +++ b/toolkit/components/antitracking/test/browser/partitionedstorage_head.js @@ -171,11 +171,15 @@ this.PartitionedStorageHelper = { async function getDataFromThirdParty(browser, result) { await SpecialPowers.spawn( - browser, [{ - page: TEST_4TH_PARTY_PARTITIONED_PAGE + "?variant=" + variant, - getDataCallback: getDataCallback.toString(), - result, - }], async obj => { + browser, + [ + { + page: TEST_4TH_PARTY_PARTITIONED_PAGE + "?variant=" + variant, + getDataCallback: getDataCallback.toString(), + result, + }, + ], + async obj => { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = __ => { @@ -205,11 +209,15 @@ this.PartitionedStorageHelper = { async function getDataFromFirstParty(browser, result) { await SpecialPowers.spawn( - browser, [{ - getDataCallback: getDataCallback.toString(), - result, - variant, - }], async obj => { + browser, + [ + { + getDataCallback: getDataCallback.toString(), + result, + variant, + }, + ], + async obj => { let runnableStr = `(() => {return (${obj.getDataCallback});})();`; let runnable = eval(runnableStr); // eslint-disable-line no-eval let win = content; @@ -242,11 +250,15 @@ this.PartitionedStorageHelper = { async function createDataInThirdParty(browser, value) { await SpecialPowers.spawn( - browser, [{ - page: TEST_4TH_PARTY_PARTITIONED_PAGE + "?variant=" + variant, - addDataCallback: addDataCallback.toString(), - value, - }], async obj => { + browser, + [ + { + page: TEST_4TH_PARTY_PARTITIONED_PAGE + "?variant=" + variant, + addDataCallback: addDataCallback.toString(), + value, + }, + ], + async obj => { await new content.Promise(resolve => { let ifr = content.document.getElementsByTagName("iframe")[0]; content.addEventListener( @@ -272,11 +284,15 @@ this.PartitionedStorageHelper = { async function createDataInFirstParty(browser, value) { await SpecialPowers.spawn( - browser, [{ - addDataCallback: addDataCallback.toString(), - value, - variant, - }], async obj => { + browser, + [ + { + addDataCallback: addDataCallback.toString(), + value, + variant, + }, + ], + async obj => { let runnableStr = `(() => {return (${obj.addDataCallback});})();`; let runnable = eval(runnableStr); // eslint-disable-line no-eval let win = content; diff --git a/toolkit/components/antitracking/test/browser/storageprincipal_head.js b/toolkit/components/antitracking/test/browser/storageprincipal_head.js index 7244cb3bfebe..203af5d89b61 100644 --- a/toolkit/components/antitracking/test/browser/storageprincipal_head.js +++ b/toolkit/components/antitracking/test/browser/storageprincipal_head.js @@ -58,10 +58,14 @@ this.StoragePrincipalHelper = { info("Creating a 3rd party content"); await SpecialPowers.spawn( - browser, [{ - page: TEST_3RD_PARTY_STORAGE_PAGE, - callback: callback.toString(), - }], async obj => { + browser, + [ + { + page: TEST_3RD_PARTY_STORAGE_PAGE, + callback: callback.toString(), + }, + ], + async obj => { await new content.Promise(resolve => { let ifr = content.document.createElement("iframe"); ifr.onload = __ => { diff --git a/toolkit/components/certviewer/tests/browser/browser_aboutcertificateviewer.js b/toolkit/components/certviewer/tests/browser/browser_aboutcertificateviewer.js index 3ceaaaa63e93..fb90d1492cd6 100644 --- a/toolkit/components/certviewer/tests/browser/browser_aboutcertificateviewer.js +++ b/toolkit/components/certviewer/tests/browser/browser_aboutcertificateviewer.js @@ -19,7 +19,9 @@ async function checkForErrorSection(infoMessage, url, errorMessage, testType) { await BrowserTestUtils.withNewTab(url, async function(browser) { await SpecialPowers.spawn( - browser, [{ errorMessage, testType }], async function({ errorMessage, testType }) { + browser, + [{ errorMessage, testType }], + async function({ errorMessage, testType }) { let errorSection; if (testType === "invalid") { diff --git a/toolkit/components/certviewer/tests/browser/browser_openTabAndSendCertInfo.js b/toolkit/components/certviewer/tests/browser/browser_openTabAndSendCertInfo.js index 8512c85a9bea..2f065e979e63 100644 --- a/toolkit/components/certviewer/tests/browser/browser_openTabAndSendCertInfo.js +++ b/toolkit/components/certviewer/tests/browser/browser_openTabAndSendCertInfo.js @@ -95,7 +95,9 @@ add_task(async function openFromPopUp() { function injectErrorPageFrame(tab, src) { return SpecialPowers.spawn( - tab.linkedBrowser, [{ frameSrc: src }], async function({ frameSrc }) { + tab.linkedBrowser, + [{ frameSrc: src }], + async function({ frameSrc }) { let loaded = ContentTaskUtils.waitForEvent( content.wrappedJSObject, "DOMFrameContentLoaded" diff --git a/toolkit/components/cleardata/SiteDataTestUtils.jsm b/toolkit/components/cleardata/SiteDataTestUtils.jsm index fb71934191aa..e2bdee95d51d 100644 --- a/toolkit/components/cleardata/SiteDataTestUtils.jsm +++ b/toolkit/components/cleardata/SiteDataTestUtils.jsm @@ -10,7 +10,6 @@ const { XPCOMUtils } = ChromeUtils.import( "resource://gre/modules/XPCOMUtils.jsm" ); const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -; const { BrowserTestUtils } = ChromeUtils.import( "resource://testing-common/BrowserTestUtils.jsm" ); @@ -117,22 +116,26 @@ var SiteDataTestUtils = { let uri = Services.io.newURI(path); // Register a dummy ServiceWorker. return BrowserTestUtils.withNewTab(uri.prePath, async function(browser) { - return browser.ownerGlobal.SpecialPowers.spawn(browser, [{ path }], async ({ path: p }) => { - // eslint-disable-next-line no-undef - let r = await content.navigator.serviceWorker.register(p); - return new Promise(resolve => { - let worker = r.installing || r.waiting || r.active; - if (worker.state == "activated") { - resolve(); - } else { - worker.addEventListener("statechange", () => { - if (worker.state == "activated") { - resolve(); - } - }); - } - }); - }); + return browser.ownerGlobal.SpecialPowers.spawn( + browser, + [{ path }], + async ({ path: p }) => { + // eslint-disable-next-line no-undef + let r = await content.navigator.serviceWorker.register(p); + return new Promise(resolve => { + let worker = r.installing || r.waiting || r.active; + if (worker.state == "activated") { + resolve(); + } else { + worker.addEventListener("statechange", () => { + if (worker.state == "activated") { + resolve(); + } + }); + } + }); + } + ); }); }, diff --git a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm index 9d2b9075459c..872257588ec0 100644 --- a/toolkit/components/extensions/ExtensionXPCShellUtils.jsm +++ b/toolkit/components/extensions/ExtensionXPCShellUtils.jsm @@ -278,7 +278,11 @@ class ContentPage { } spawn(params, task) { - return this.browser.ownerGlobal.SpecialPowers.spawn(this.browser, [params], task); + return this.browser.ownerGlobal.SpecialPowers.spawn( + this.browser, + [params], + task + ); } async close() { diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors.js b/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors.js index 6c85a8092759..3e5d78970999 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors.js @@ -17,7 +17,9 @@ async function test_ntp_theme(theme, isBrightText) { let browser = gBrowser.selectedBrowser; let { originalBackground, originalColor } = await SpecialPowers.spawn( - browser, [], function() { + browser, + [], + function() { let doc = content.document; ok( !doc.body.hasAttribute("lwt-newtab"), @@ -42,11 +44,15 @@ async function test_ntp_theme(theme, isBrightText) { Services.ppmm.sharedData.flush(); await SpecialPowers.spawn( - browser, [{ - isBrightText, - background: hexToCSS(theme.colors.ntp_background), - color: hexToCSS(theme.colors.ntp_text), - }], function({ isBrightText, background, color }) { + browser, + [ + { + isBrightText, + background: hexToCSS(theme.colors.ntp_background), + color: hexToCSS(theme.colors.ntp_text), + }, + ], + function({ isBrightText, background, color }) { let doc = content.document; ok( doc.body.hasAttribute("lwt-newtab"), @@ -78,10 +84,14 @@ async function test_ntp_theme(theme, isBrightText) { Services.ppmm.sharedData.flush(); await SpecialPowers.spawn( - browser, [{ - originalBackground, - originalColor, - }], function({ originalBackground, originalColor }) { + browser, + [ + { + originalBackground, + originalColor, + }, + ], + function({ originalBackground, originalColor }) { let doc = content.document; ok( !doc.body.hasAttribute("lwt-newtab"), diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors_perwindow.js b/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors_perwindow.js index 87e5828f5cb3..a8cfcf33c1e6 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors_perwindow.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_ntp_colors_perwindow.js @@ -12,11 +12,15 @@ function test_ntp_theme(browser, theme, isBrightText) { Services.ppmm.sharedData.flush(); return SpecialPowers.spawn( - browser, [{ - isBrightText, - background: hexToCSS(theme.colors.ntp_background), - color: hexToCSS(theme.colors.ntp_text), - }], function({ isBrightText, background, color }) { + browser, + [ + { + isBrightText, + background: hexToCSS(theme.colors.ntp_background), + color: hexToCSS(theme.colors.ntp_text), + }, + ], + function({ isBrightText, background, color }) { let doc = content.document; ok( doc.body.hasAttribute("lwt-newtab"), @@ -52,10 +56,14 @@ function test_ntp_theme(browser, theme, isBrightText) { function test_ntp_default_theme(browser) { Services.ppmm.sharedData.flush(); return SpecialPowers.spawn( - browser, [{ - background: hexToCSS("#F9F9FA"), - color: hexToCSS("#0C0C0D"), - }], function({ background, color }) { + browser, + [ + { + background: hexToCSS("#F9F9FA"), + color: hexToCSS("#0C0C0D"), + }, + ], + function({ background, color }) { let doc = content.document; ok( !doc.body.hasAttribute("lwt-newtab"), diff --git a/toolkit/components/normandy/test/browser/browser_about_studies.js b/toolkit/components/normandy/test/browser/browser_about_studies.js index 2356e8f0dd86..b2a5097b13fe 100644 --- a/toolkit/components/normandy/test/browser/browser_about_studies.js +++ b/toolkit/components/normandy/test/browser/browser_about_studies.js @@ -133,7 +133,9 @@ decorate_task( withAboutStudies, async function testStudyListing(addonStudies, prefStudies, browser) { await SpecialPowers.spawn( - browser, [{ addonStudies, prefStudies }], async ({ addonStudies, prefStudies }) => { + browser, + [{ addonStudies, prefStudies }], + async ({ addonStudies, prefStudies }) => { const doc = content.document; function getStudyRow(docElem, slug) { @@ -400,7 +402,9 @@ decorate_task( }); await SpecialPowers.spawn( - browser, [{ addonStudy, prefStudy }], async ({ addonStudy, prefStudy }) => { + browser, + [{ addonStudy, prefStudy }], + async ({ addonStudy, prefStudy }) => { const doc = content.document; function getStudyRow(docElem, slug) { @@ -487,7 +491,9 @@ decorate_task( async function testOtherTabsUpdated([addonStudy], [prefStudy], browser) { // Ensure that both our studies are active in the current tab. await SpecialPowers.spawn( - browser, [{ addonStudy, prefStudy }], async ({ addonStudy, prefStudy }) => { + browser, + [{ addonStudy, prefStudy }], + async ({ addonStudy, prefStudy }) => { const doc = content.document; await ContentTaskUtils.waitForCondition( () => doc.querySelectorAll(".remove-button").length == 2, @@ -517,7 +523,9 @@ decorate_task( await BrowserTestUtils.withNewTab("about:studies", async browser => { // Delete both studies in this tab; this should pass if previous tests have passed. await SpecialPowers.spawn( - browser, [{ addonStudy, prefStudy }], async ({ addonStudy, prefStudy }) => { + browser, + [{ addonStudy, prefStudy }], + async ({ addonStudy, prefStudy }) => { const doc = content.document; function getStudyRow(docElem, slug) { @@ -582,7 +590,9 @@ decorate_task( // Ensure that the original tab has updated correctly. await SpecialPowers.spawn( - browser, [{ addonStudy, prefStudy }], async ({ addonStudy, prefStudy }) => { + browser, + [{ addonStudy, prefStudy }], + async ({ addonStudy, prefStudy }) => { const doc = content.document; await ContentTaskUtils.waitForCondition( () => doc.querySelectorAll(".inactive-study-list .study").length == 2, diff --git a/toolkit/components/passwordmgr/test/browser/browser_autofill_hidden_document.js b/toolkit/components/passwordmgr/test/browser/browser_autofill_hidden_document.js index f89ec71554ba..c044bc1fe0d9 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_autofill_hidden_document.js +++ b/toolkit/components/passwordmgr/test/browser/browser_autofill_hidden_document.js @@ -120,7 +120,9 @@ testUrls.forEach(testUrl => { // the form should have been autofilled with the login let fieldValues = await SpecialPowers.spawn( - tab1.linkedBrowser, [], function() { + tab1.linkedBrowser, + [], + function() { let doc = content.document; return { username: doc.getElementById("form-basic-username").value, diff --git a/toolkit/components/passwordmgr/test/browser/browser_autofill_track_filled_logins.js b/toolkit/components/passwordmgr/test/browser/browser_autofill_track_filled_logins.js index 1591e4f6ce95..7434be3e26e4 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_autofill_track_filled_logins.js +++ b/toolkit/components/passwordmgr/test/browser/browser_autofill_track_filled_logins.js @@ -42,7 +42,9 @@ add_task(async function test() { // Convert the login object to a plain JS object for passing across process boundaries. login = LoginHelper.loginToVanillaObject(login); await SpecialPowers.spawn( - tab.linkedBrowser, [{ login, usernameRequested }], async ({ login: addedLogin, usernameRequested: aUsernameRequested }) => { + tab.linkedBrowser, + [{ login, usernameRequested }], + async ({ login: addedLogin, usernameRequested: aUsernameRequested }) => { const { LoginFormFactory } = ChromeUtils.import( "resource://gre/modules/LoginFormFactory.jsm" ); diff --git a/toolkit/components/passwordmgr/test/browser/browser_context_menu.js b/toolkit/components/passwordmgr/test/browser/browser_context_menu.js index c8f2f97096e3..b4d2691b58cf 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_context_menu.js +++ b/toolkit/components/passwordmgr/test/browser/browser_context_menu.js @@ -143,7 +143,9 @@ add_task(async function test_context_menu_password_fill() { }, async function(browser) { let formDescriptions = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let forms = Array.from( content.document.getElementsByClassName("test-form") ); @@ -155,7 +157,9 @@ add_task(async function test_context_menu_password_fill() { info("Testing form: " + description); let passwordInputIds = await SpecialPowers.spawn( - browser, [{ description }], async function({ description }) { + browser, + [{ description }], + async function({ description }) { let formElement = content.document.querySelector( `[description="${description}"]` ); @@ -175,7 +179,9 @@ add_task(async function test_context_menu_password_fill() { "#" + inputId, async function() { let inputDisabled = await SpecialPowers.spawn( - browser, [{ inputId }], async function({ inputId }) { + browser, + [{ inputId }], + async function({ inputId }) { let input = content.document.getElementById(inputId); return input.disabled || input.readOnly; } @@ -231,7 +237,9 @@ add_task(async function test_context_menu_username_login_fill() { }, async function(browser) { let formDescriptions = await SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let forms = Array.from( content.document.getElementsByClassName("test-form") ); @@ -242,7 +250,9 @@ add_task(async function test_context_menu_username_login_fill() { for (let description of formDescriptions) { info("Testing form: " + description); let usernameInputIds = await SpecialPowers.spawn( - browser, [{ description }], async function({ description }) { + browser, + [{ description }], + async function({ description }) { let formElement = content.document.querySelector( `[description="${description}"]` ); @@ -266,7 +276,9 @@ add_task(async function test_context_menu_username_login_fill() { let data = { description, inputId, headerHidden, headerDisabled }; let shouldContinue = await SpecialPowers.spawn( - browser, [data], async function(data) { + browser, + [data], + async function(data) { let { description, inputId, @@ -317,7 +329,9 @@ add_task(async function test_context_menu_username_login_fill() { } let passwordFieldId = await SpecialPowers.spawn( - browser, [{ description }], async function({ description }) { + browser, + [{ description }], + async function({ description }) { let formElement = content.document.querySelector( `[description="${description}"]` ); @@ -334,20 +348,22 @@ add_task(async function test_context_menu_username_login_fill() { 1 ); - await SpecialPowers.spawn(browser, [{ passwordFieldId }], async function({ - passwordFieldId, - }) { - let passwordField = content.document.getElementById( - passwordFieldId - ); - if (!passwordField.hasAttribute("expectedFail")) { - Assert.equal( - passwordField.value, - "password1", - "Check upgraded login was actually used" + await SpecialPowers.spawn( + browser, + [{ passwordFieldId }], + async function({ passwordFieldId }) { + let passwordField = content.document.getElementById( + passwordFieldId ); + if (!passwordField.hasAttribute("expectedFail")) { + Assert.equal( + passwordField.value, + "password1", + "Check upgraded login was actually used" + ); + } } - }); + ); await closePopup(CONTEXT_MENU); } @@ -433,7 +449,9 @@ async function assertContextMenuFill( formId, unchangedSelector, }; - let continuePromise = SpecialPowers.spawn(browser, [data], async function(data) { + let continuePromise = SpecialPowers.spawn(browser, [data], async function( + data + ) { let { username, password, diff --git a/toolkit/components/passwordmgr/test/browser/browser_context_menu_generated_password.js b/toolkit/components/passwordmgr/test/browser/browser_context_menu_generated_password.js index 90c5a7ad62c9..9de53f71bd6c 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_context_menu_generated_password.js +++ b/toolkit/components/passwordmgr/test/browser/browser_context_menu_generated_password.js @@ -125,7 +125,9 @@ add_task(async function fill_generated_password_empty_field() { async function(browser) { await SimpleTest.promiseFocus(browser.ownerGlobal); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkInitialFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkInitialFieldValue(inputSelector) { const input = content.document.querySelector(inputSelector); is(input.value.length, 0, "Password field is empty"); is( @@ -141,7 +143,9 @@ add_task(async function fill_generated_password_empty_field() { passwordInputSelector ); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkFinalFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkFinalFieldValue(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); @@ -189,7 +193,9 @@ add_task(async function fill_generated_password_nonempty_field() { async function(browser) { await SimpleTest.promiseFocus(browser.ownerGlobal); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkInitialFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkInitialFieldValue(inputSelector) { const input = content.document.querySelector(inputSelector); input.setUserInput("aa"); is( @@ -205,7 +211,9 @@ add_task(async function fill_generated_password_nonempty_field() { passwordInputSelector ); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkFinalFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkFinalFieldValue(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); @@ -253,7 +261,9 @@ add_task(async function fill_generated_password_with_matching_logins() { await SimpleTest.promiseFocus(browser.ownerGlobal); await formFilled; await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkInitialFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkInitialFieldValue(inputSelector) { is( content.document.querySelector(inputSelector).value, "pass1", @@ -267,7 +277,9 @@ add_task(async function fill_generated_password_with_matching_logins() { passwordInputSelector ); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkFinalFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkFinalFieldValue(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); @@ -290,7 +302,9 @@ add_task(async function fill_generated_password_with_matching_logins() { // Execute the command of the first login menuitem found at the context menu. let passwordChangedPromise = SpecialPowers.spawn( - browser, [], async function() { + browser, + [], + async function() { let passwordInput = content.document.getElementById( "form-basic-password" ); @@ -318,7 +332,9 @@ add_task(async function fill_generated_password_with_matching_logins() { ); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkFieldNotGeneratedPassword(inputSelector) { + browser, + [[passwordInputSelector]], + function checkFieldNotGeneratedPassword(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); @@ -361,7 +377,9 @@ add_task(async function test_edited_generated_password_in_new_tab() { async function(browser) { await SimpleTest.promiseFocus(browser.ownerGlobal); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkInitialFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkInitialFieldValue(inputSelector) { const input = content.document.querySelector(inputSelector); is(input.value.length, 0, "Password field is empty"); is( @@ -377,7 +395,9 @@ add_task(async function test_edited_generated_password_in_new_tab() { passwordInputSelector ); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkAndEditFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkAndEditFieldValue(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); @@ -429,7 +449,9 @@ add_task(async function test_edited_generated_password_in_new_tab() { ); await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkAndEditFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkAndEditFieldValue(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); diff --git a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_generated_password.js b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_generated_password.js index 99f33ee83bab..9e02a3016c7f 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_generated_password.js +++ b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_generated_password.js @@ -77,7 +77,9 @@ async function verifyGeneratedPasswordWasFilled( passwordInputSelector ) { await SpecialPowers.spawn( - browser, [[passwordInputSelector]], function checkFinalFieldValue(inputSelector) { + browser, + [[passwordInputSelector]], + function checkFinalFieldValue(inputSelector) { let { LoginTestUtils: LTU } = ChromeUtils.import( "resource://testing-common/LoginTestUtils.jsm" ); @@ -117,7 +119,9 @@ async function openFormInNewTab(url, formValues, taskFn) { await formFilled; await SpecialPowers.spawn( - browser, [formValues], async function prepareAndCheckForm({ + browser, + [formValues], + async function prepareAndCheckForm({ password: passwordProps, username: usernameProps, }) { @@ -744,7 +748,9 @@ add_task(async function contextmenu_fill_generated_password_and_set_username() { "popupshown" ); await SpecialPowers.spawn( - browser, [[passwordInputSelector, usernameInputSelector]], function checkEmptyPasswordField([passwordSelector, usernameSelector]) { + browser, + [[passwordInputSelector, usernameInputSelector]], + function checkEmptyPasswordField([passwordSelector, usernameSelector]) { is( content.document.querySelector(passwordSelector).value, "", diff --git a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_save_password.js b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_save_password.js index 6fbe8b6e054d..6bbceadb7d79 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_save_password.js +++ b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_save_password.js @@ -93,19 +93,20 @@ add_task(async function test_save_change() { async function(browser) { // Submit the form in the content page with the credentials from the test // case. This will cause the doorhanger notification to be displayed. - await SpecialPowers.spawn(browser, [[username, password]], async function([ - contentUsername, - contentPassword, - ]) { - let doc = content.document; - doc - .getElementById("form-basic-username") - .setUserInput(contentUsername); - doc - .getElementById("form-basic-password") - .setUserInput(contentPassword); - doc.getElementById("form-basic").submit(); - }); + await SpecialPowers.spawn( + browser, + [[username, password]], + async function([contentUsername, contentPassword]) { + let doc = content.document; + doc + .getElementById("form-basic-username") + .setUserInput(contentUsername); + doc + .getElementById("form-basic-password") + .setUserInput(contentPassword); + doc.getElementById("form-basic").submit(); + } + ); // Simulate the action on the notification to request the login to be // saved, and wait for the data to be updated or saved based on the type diff --git a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_username_edits.js b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_username_edits.js index e152b6168f5b..3684e994e28f 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_doorhanger_username_edits.js +++ b/toolkit/components/passwordmgr/test/browser/browser_doorhanger_username_edits.js @@ -90,7 +90,9 @@ add_task(async function test_edit_username() { event => event.target == PopupNotifications.panel ); await SpecialPowers.spawn( - browser, [testCase.usernameInPage], async function(usernameInPage) { + browser, + [testCase.usernameInPage], + async function(usernameInPage) { let doc = content.document; doc .getElementById("form-basic-username") diff --git a/toolkit/components/passwordmgr/test/browser/browser_focus_before_first_DOMContentLoaded.js b/toolkit/components/passwordmgr/test/browser/browser_focus_before_first_DOMContentLoaded.js index dc4ab2205bd1..4451fb94062b 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_focus_before_first_DOMContentLoaded.js +++ b/toolkit/components/passwordmgr/test/browser/browser_focus_before_first_DOMContentLoaded.js @@ -50,7 +50,9 @@ add_task(async function test_autocompleteFromUsername() { }); await SpecialPowers.spawn( - newTab.linkedBrowser, [], function checkInitialValues() { + newTab.linkedBrowser, + [], + function checkInitialValues() { let doc = content.document; let uname = doc.querySelector("#uname"); let pword = doc.querySelector("#pword"); diff --git a/toolkit/components/passwordmgr/test/browser/browser_private_window.js b/toolkit/components/passwordmgr/test/browser/browser_private_window.js index 85dc43e90ff3..ae72123430ef 100644 --- a/toolkit/components/passwordmgr/test/browser/browser_private_window.js +++ b/toolkit/components/passwordmgr/test/browser/browser_private_window.js @@ -703,16 +703,20 @@ add_task(async function test_normal_http_basic_auth() { ok(true, "Auth-required page loaded"); // verify result in the response document - let fieldValues = await SpecialPowers.spawn(browser, [[]], async function() { - let username = content.document.getElementById("user").textContent; - let password = content.document.getElementById("pass").textContent; - let ok = content.document.getElementById("ok").textContent; - return { - username, - password, - ok, - }; - }); + let fieldValues = await SpecialPowers.spawn( + browser, + [[]], + async function() { + let username = content.document.getElementById("user").textContent; + let password = content.document.getElementById("pass").textContent; + let ok = content.document.getElementById("ok").textContent; + return { + username, + password, + ok, + }; + } + ); is(fieldValues.ok, "PASS", "Checking authorization passed"); is(fieldValues.username, "test", "Checking authorized username"); is(fieldValues.password, "testpass", "Checking authorized password"); diff --git a/toolkit/components/passwordmgr/test/browser/head.js b/toolkit/components/passwordmgr/test/browser/head.js index 08589b75f552..13ade3c61b84 100644 --- a/toolkit/components/passwordmgr/test/browser/head.js +++ b/toolkit/components/passwordmgr/test/browser/head.js @@ -142,7 +142,9 @@ async function submitFormAndGetResults( form.submit(); } await SpecialPowers.spawn( - browser, [[formAction, selectorValues]], contentSubmitForm + browser, + [[formAction, selectorValues]], + contentSubmitForm ); let result = await getFormSubmitResponseResult( browser, @@ -167,11 +169,15 @@ async function getFormSubmitResponseResult( ) { // default selectors are for the response page produced by formsubmit.sjs let fieldValues = await SpecialPowers.spawn( - browser, [{ - resultURL, - usernameSelector: username, - passwordSelector: password, - }], async function({ resultURL, usernameSelector, passwordSelector }) { + browser, + [ + { + resultURL, + usernameSelector: username, + passwordSelector: password, + }, + ], + async function({ resultURL, usernameSelector, passwordSelector }) { await ContentTaskUtils.waitForCondition(() => { return ( content.location.pathname.endsWith(resultURL) && @@ -529,11 +535,13 @@ async function openACPopup(popup, browser, inputSelector) { info("content window focused"); // Focus the username field to open the popup. - await SpecialPowers.spawn(browser, [[inputSelector]], function openAutocomplete( - sel - ) { - content.document.querySelector(sel).focus(); - }); + await SpecialPowers.spawn( + browser, + [[inputSelector]], + function openAutocomplete(sel) { + content.document.querySelector(sel).focus(); + } + ); let shown = await promiseShown; ok(shown, "autocomplete popup shown"); diff --git a/toolkit/components/pictureinpicture/tests/browser_contextMenu.js b/toolkit/components/pictureinpicture/tests/browser_contextMenu.js index e312edf5e10e..0857b579ba28 100644 --- a/toolkit/components/pictureinpicture/tests/browser_contextMenu.js +++ b/toolkit/components/pictureinpicture/tests/browser_contextMenu.js @@ -100,7 +100,9 @@ add_task(async () => { await closeContextMenu(menu); let videoNotCloning = SpecialPowers.spawn( - browser, [videoID], async videoID => { + browser, + [videoID], + async videoID => { let video = content.document.getElementById(videoID); await ContentTaskUtils.waitForCondition(() => { return !video.isCloningElementVisually; diff --git a/toolkit/components/pictureinpicture/tests/browser_removeVideoElement.js b/toolkit/components/pictureinpicture/tests/browser_removeVideoElement.js index c7eb565fd7bf..46ca986ed877 100644 --- a/toolkit/components/pictureinpicture/tests/browser_removeVideoElement.js +++ b/toolkit/components/pictureinpicture/tests/browser_removeVideoElement.js @@ -32,17 +32,25 @@ add_task(async () => { eventFired = true; }; - docShell.chromeEventHandler.addEventListener("MozStopPictureInPicture", listener, { - capture: true, - }); + docShell.chromeEventHandler.addEventListener( + "MozStopPictureInPicture", + listener, + { + capture: true, + } + ); otherVideo.remove(); Assert.ok( !eventFired, "Should not have seen MozStopPictureInPicture for other video" ); - docShell.chromeEventHandler.removeEventListener("MozStopPictureInPicture", listener, { - capture: true, - }); + docShell.chromeEventHandler.removeEventListener( + "MozStopPictureInPicture", + listener, + { + capture: true, + } + ); }); Assert.ok(!pipWin.closed, "PiP window should still be open."); diff --git a/toolkit/components/remotebrowserutils/tests/browser/browser_httpToFileHistory.js b/toolkit/components/remotebrowserutils/tests/browser/browser_httpToFileHistory.js index f0a368822a8d..f7cb24b9b283 100644 --- a/toolkit/components/remotebrowserutils/tests/browser/browser_httpToFileHistory.js +++ b/toolkit/components/remotebrowserutils/tests/browser/browser_httpToFileHistory.js @@ -39,28 +39,28 @@ async function runTest() { count++; index++; - await SpecialPowers.spawn(aBrowser, [{ count, index, url }], async function({ - count, - index, - url, - }) { - docShell.QueryInterface(Ci.nsIWebNavigation); + await SpecialPowers.spawn( + aBrowser, + [{ count, index, url }], + async function({ count, index, url }) { + docShell.QueryInterface(Ci.nsIWebNavigation); - is( - docShell.sessionHistory.count, - count, - "Initial Navigation Count Match" - ); - is( - docShell.sessionHistory.index, - index, - "Initial Navigation Index Match" - ); + is( + docShell.sessionHistory.count, + count, + "Initial Navigation Count Match" + ); + is( + docShell.sessionHistory.index, + index, + "Initial Navigation Index Match" + ); - let real = Services.io.newURI(content.location.href); - let expect = Services.io.newURI(url); - is(real.scheme, expect.scheme, "Initial Navigation URL Scheme"); - }); + let real = Services.io.newURI(content.location.href); + let expect = Services.io.newURI(url); + is(real.scheme, expect.scheme, "Initial Navigation URL Scheme"); + } + ); } // Go back to the first entry. @@ -75,20 +75,20 @@ async function runTest() { }); index--; - await SpecialPowers.spawn(aBrowser, [{ count, index, url }], async function({ - count, - index, - url, - }) { - docShell.QueryInterface(Ci.nsIWebNavigation); + await SpecialPowers.spawn( + aBrowser, + [{ count, index, url }], + async function({ count, index, url }) { + docShell.QueryInterface(Ci.nsIWebNavigation); - is(docShell.sessionHistory.count, count, "Go Back Count Match"); - is(docShell.sessionHistory.index, index, "Go Back Index Match"); + is(docShell.sessionHistory.count, count, "Go Back Count Match"); + is(docShell.sessionHistory.index, index, "Go Back Index Match"); - let real = Services.io.newURI(content.location.href); - let expect = Services.io.newURI(url); - is(real.scheme, expect.scheme, "Go Back URL Scheme"); - }); + let real = Services.io.newURI(content.location.href); + let expect = Services.io.newURI(url); + is(real.scheme, expect.scheme, "Go Back URL Scheme"); + } + ); } // Go forward to the last entry. @@ -103,20 +103,20 @@ async function runTest() { }); index++; - await SpecialPowers.spawn(aBrowser, [{ count, index, url }], async function({ - count, - index, - url, - }) { - docShell.QueryInterface(Ci.nsIWebNavigation); + await SpecialPowers.spawn( + aBrowser, + [{ count, index, url }], + async function({ count, index, url }) { + docShell.QueryInterface(Ci.nsIWebNavigation); - is(docShell.sessionHistory.count, count, "Go Forward Count Match"); - is(docShell.sessionHistory.index, index, "Go Forward Index Match"); + is(docShell.sessionHistory.count, count, "Go Forward Count Match"); + is(docShell.sessionHistory.index, index, "Go Forward Index Match"); - let real = Services.io.newURI(content.location.href); - let expect = Services.io.newURI(url); - is(real.scheme, expect.scheme, "Go Forward URL Scheme"); - }); + let real = Services.io.newURI(content.location.href); + let expect = Services.io.newURI(url); + is(real.scheme, expect.scheme, "Go Forward URL Scheme"); + } + ); } }); } diff --git a/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js b/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js index 96ded21a70c6..aefc6c642a6c 100644 --- a/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js +++ b/toolkit/components/remotebrowserutils/tests/browser/browser_oopProcessSwap.js @@ -20,7 +20,9 @@ add_task(async function oopProcessSwap() { info("creating an in-process frame"); let frameId = await SpecialPowers.spawn( - browser, [{ FILE }], async ({ FILE }) => { + browser, + [{ FILE }], + async ({ FILE }) => { let iframe = content.document.createElement("iframe"); iframe.setAttribute("src", FILE); content.document.body.appendChild(iframe); @@ -36,7 +38,9 @@ add_task(async function oopProcessSwap() { info("navigating to x-process frame"); let oopinfo = await SpecialPowers.spawn( - browser, [{ WEB }], async ({ WEB }) => { + browser, + [{ WEB }], + async ({ WEB }) => { let iframe = content.document.querySelector("iframe"); iframe.contentWindow.location = WEB; @@ -101,7 +105,9 @@ add_task(async function oopOriginProcessSwap() { info("creating an in-process frame"); let frameId = await SpecialPowers.spawn( - browser, [{ COM_DUMMY }], async ({ COM_DUMMY }) => { + browser, + [{ COM_DUMMY }], + async ({ COM_DUMMY }) => { let iframe = content.document.createElement("iframe"); iframe.setAttribute("src", COM_DUMMY); content.document.body.appendChild(iframe); @@ -117,7 +123,9 @@ add_task(async function oopOriginProcessSwap() { info("navigating to x-process frame"); let oopinfo = await SpecialPowers.spawn( - browser, [{ ORG_POSTMSG }], async ({ ORG_POSTMSG }) => { + browser, + [{ ORG_POSTMSG }], + async ({ ORG_POSTMSG }) => { let iframe = content.document.querySelector("iframe"); iframe.contentWindow.location = ORG_POSTMSG; diff --git a/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js b/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js index e1cc8bf2ef17..e7ef6a3e23ab 100644 --- a/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js +++ b/toolkit/components/telemetry/tests/browser/browser_DynamicScalars.js @@ -201,7 +201,9 @@ add_task(async function test_aggregation() { { gBrowser, url: "about:blank", forceNewProcess: true }, async function(browser) { // Accumulate from the content process into both dynamic scalars. - await SpecialPowers.spawn(browser, [SCALAR_FULL_NAME], async function(aName) { + await SpecialPowers.spawn(browser, [SCALAR_FULL_NAME], async function( + aName + ) { Services.telemetry.scalarAdd(aName, 3); }); } diff --git a/toolkit/components/tooltiptext/tests/browser_bug581947.js b/toolkit/components/tooltiptext/tests/browser_bug581947.js index 43e76f25c1f3..fe071dadf7c3 100644 --- a/toolkit/components/tooltiptext/tests/browser_bug581947.js +++ b/toolkit/components/tooltiptext/tests/browser_bug581947.js @@ -1,6 +1,8 @@ function check(aBrowser, aElementName, aBarred, aType) { return SpecialPowers.spawn( - aBrowser, [[aElementName, aBarred, aType]], async function([aElementName, aBarred, aType]) { + aBrowser, + [[aElementName, aBarred, aType]], + async function([aElementName, aBarred, aType]) { let e = content.document.createElement(aElementName); let contentElement = content.document.getElementById("content"); contentElement.appendChild(e); @@ -50,25 +52,26 @@ function check(aBrowser, aElementName, aBarred, aType) { } function todo_check(aBrowser, aElementName, aBarred) { - return SpecialPowers.spawn(aBrowser, [[aElementName, aBarred]], async function([ - aElementName, - aBarred, - ]) { - let e = content.document.createElement(aElementName); - let contentElement = content.document.getElementById("content"); - contentElement.appendChild(e); + return SpecialPowers.spawn( + aBrowser, + [[aElementName, aBarred]], + async function([aElementName, aBarred]) { + let e = content.document.createElement(aElementName); + let contentElement = content.document.getElementById("content"); + contentElement.appendChild(e); - let caught = false; - try { - e.setCustomValidity("foo"); - } catch (e) { - caught = true; + let caught = false; + try { + e.setCustomValidity("foo"); + } catch (e) { + caught = true; + } + + todo(!caught, "setCustomValidity should exist for " + aElementName); + + e.remove(); } - - todo(!caught, "setCustomValidity should exist for " + aElementName); - - e.remove(); - }); + ); } add_task(async function() { diff --git a/toolkit/components/viewsource/test/browser/browser_bug464222.js b/toolkit/components/viewsource/test/browser/browser_bug464222.js index 69cf73d0a426..7a702c2851fc 100644 --- a/toolkit/components/viewsource/test/browser/browser_bug464222.js +++ b/toolkit/components/viewsource/test/browser/browser_bug464222.js @@ -5,7 +5,9 @@ add_task(async function() { let viewSourceTab = await openDocumentSelect(source, "a"); let href = await SpecialPowers.spawn( - viewSourceTab.linkedBrowser, [], async function() { + viewSourceTab.linkedBrowser, + [], + async function() { return content.document.querySelectorAll("a[href]")[0].href; } ); diff --git a/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js b/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js index 31afc6df0d44..358ba7fd5c83 100644 --- a/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js +++ b/toolkit/components/viewsource/test/browser/browser_viewsourceprefs.js @@ -174,12 +174,14 @@ async function simulateClick(browser, id) { } var checkStyle = async function(browser, styleProperty, expected) { - let value = await SpecialPowers.spawn(browser, [styleProperty], async function( - styleProperty - ) { - let style = content.getComputedStyle(content.document.body); - return style.getPropertyValue(styleProperty); - }); + let value = await SpecialPowers.spawn( + browser, + [styleProperty], + async function(styleProperty) { + let style = content.getComputedStyle(content.document.body); + return style.getPropertyValue(styleProperty); + } + ); is(value, expected, "Correct value of " + styleProperty); }; diff --git a/toolkit/components/viewsource/test/browser/head.js b/toolkit/components/viewsource/test/browser/head.js index 29179072bb08..c129dc62e51a 100644 --- a/toolkit/components/viewsource/test/browser/head.js +++ b/toolkit/components/viewsource/test/browser/head.js @@ -186,7 +186,9 @@ async function openDocumentSelect(aURI, aCSSSelector) { }); await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ selector: aCSSSelector }], async function(arg) { + gBrowser.selectedBrowser, + [{ selector: aCSSSelector }], + async function(arg) { let element = content.document.querySelector(arg.selector); content.getSelection().selectAllChildren(element); } diff --git a/toolkit/components/windowcreator/test/browser_save_form_input_state.js b/toolkit/components/windowcreator/test/browser_save_form_input_state.js index a020f192fcd3..d46b62161202 100644 --- a/toolkit/components/windowcreator/test/browser_save_form_input_state.js +++ b/toolkit/components/windowcreator/test/browser_save_form_input_state.js @@ -41,7 +41,9 @@ add_task(async function checkFormStateSaved() { }); await BrowserTestUtils.withNewTab(fileURISpec, async otherBrowser => { await SpecialPowers.spawn( - otherBrowser, [{ textareas, textboxes }], checkform + otherBrowser, + [{ textareas, textboxes }], + checkform ); }); } diff --git a/toolkit/content/tests/browser/browser_audioCompeting.js b/toolkit/content/tests/browser/browser_audioCompeting.js index 7bb7d7130d58..de5f9d54dc51 100644 --- a/toolkit/content/tests/browser/browser_audioCompeting.js +++ b/toolkit/content/tests/browser/browser_audioCompeting.js @@ -90,12 +90,16 @@ add_task(async function cross_tabs_audio_competing() { "about:blank" ); await SpecialPowers.spawn( - tab2.linkedBrowser, [], audio_should_keep_playing_even_go_to_background + tab2.linkedBrowser, + [], + audio_should_keep_playing_even_go_to_background ); info("- play audio from background tab 1 -"); await SpecialPowers.spawn( - tab1.linkedBrowser, [], play_audio_from_invisible_tab + tab1.linkedBrowser, + [], + play_audio_from_invisible_tab ); info("- remove tabs -"); diff --git a/toolkit/content/tests/browser/browser_audioCompeting_onlyForActiveAgent.js b/toolkit/content/tests/browser/browser_audioCompeting_onlyForActiveAgent.js index 7074ff027d65..c9aa2dee361e 100644 --- a/toolkit/content/tests/browser/browser_audioCompeting_onlyForActiveAgent.js +++ b/toolkit/content/tests/browser/browser_audioCompeting_onlyForActiveAgent.js @@ -151,7 +151,9 @@ async function audio_competing_for_active_agent(url, browser) { info("- the default suspended state of all audio should be non-suspened -"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); info("- only pause playing audio in the page -"); @@ -159,40 +161,44 @@ async function audio_competing_for_active_agent(url, browser) { info("- page shouldn't have any playing audio -"); await wait_for_event(browser, "DOMAudioPlaybackStopped"); + await SpecialPowers.spawn(browser, [true], check_all_audio_pause_state); await SpecialPowers.spawn( - browser, [true], check_all_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], check_all_audio_suspended + browser, + [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], + check_all_audio_suspended ); info("- resume audio1 from page -"); await SpecialPowers.spawn(browser, [], play_audio1_from_page); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio1_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio1_suspended ); info("- audio2 should still be suspended -"); await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], check_audio2_suspended - ); - await SpecialPowers.spawn( - browser, [true], check_audio2_pause_state + browser, + [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], + check_audio2_suspended ); + await SpecialPowers.spawn(browser, [true], check_audio2_pause_state); info("- stop audio1 from page -"); await SpecialPowers.spawn(browser, [], stop_audio1_from_page); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio1_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio1_suspended ); info("- audio2 should still be suspended -"); await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], check_audio2_suspended - ); - await SpecialPowers.spawn( - browser, [true], check_audio2_pause_state + browser, + [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], + check_audio2_suspended ); + await SpecialPowers.spawn(browser, [true], check_audio2_pause_state); } add_task(async function setup_test_preference() { diff --git a/toolkit/content/tests/browser/browser_autoplay_policy.js b/toolkit/content/tests/browser/browser_autoplay_policy.js index 2c38a7854b36..6d4b60501b6d 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy.js @@ -55,7 +55,11 @@ add_task(async function testAutoplayPolicy() { isAllowedAutoplay = false; isAllowedMuted = true; await setupTestPreferences(isAllowedAutoplay, isAllowedMuted); - await SpecialPowers.spawn(browser, ["allowed-muted"], checkAutoplayPolicy); + await SpecialPowers.spawn( + browser, + ["allowed-muted"], + checkAutoplayPolicy + ); info(`- Disable autoplay for all kinds of media -`); isAllowedAutoplay = false; diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js b/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js index 54e9bf23a0ba..2e6aa920ff54 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_user_gestures.js @@ -244,7 +244,9 @@ async function testWebAudioWithUserGesture(gesture) { info("- check whether audio context starts running -"); try { await SpecialPowers.spawn( - tab.linkedBrowser, [], checkingAudioContextRunningState + tab.linkedBrowser, + [], + checkingAudioContextRunningState ); } catch (error) { ok(false, error.toString()); @@ -253,7 +255,9 @@ async function testWebAudioWithUserGesture(gesture) { info("- calling resume() -"); try { await SpecialPowers.spawn( - tab.linkedBrowser, [], resumeWithoutExpectedSuccess + tab.linkedBrowser, + [], + resumeWithoutExpectedSuccess ); } catch (error) { ok(false, error.toString()); diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js index 4efd59d46e9c..8ea6033c9929 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio.js @@ -133,7 +133,9 @@ async function testAutoplayExistingPermission({ name, permission }) { info(`- check AudioContext status -`); const isAllowedToStart = permission === Services.perms.ALLOW_ACTION; await SpecialPowers.spawn( - browser, [isAllowedToStart], checkIfAudioContextIsAllowedToStart + browser, + [isAllowedToStart], + checkIfAudioContextIsAllowedToStart ); await SpecialPowers.spawn(browser, [isAllowedToStart], resumeAudioContext); @@ -162,7 +164,11 @@ async function testAutoplayUnknownPermission({ name, method }) { info(`- create AudioContext which should not start -`); loadFrameScript(browser, createAudioContext); - await SpecialPowers.spawn(browser, [false], checkIfAudioContextIsAllowedToStart); + await SpecialPowers.spawn( + browser, + [false], + checkIfAudioContextIsAllowedToStart + ); info(`- simulate user activate the page -`); await SpecialPowers.spawn(browser, [], () => { @@ -174,11 +180,11 @@ async function testAutoplayUnknownPermission({ name, method }) { info(`- check AudioContext status -`); await SpecialPowers.spawn( - browser, [true], checkIfAudioContextIsAllowedToStart - ); - await SpecialPowers.spawn( - browser, [true], resumeAudioContext + browser, + [true], + checkIfAudioContextIsAllowedToStart ); + await SpecialPowers.spawn(browser, [true], resumeAudioContext); info(`- remove tab -`); PermissionTestUtils.remove(browser.currentURI, "autoplay-media"); diff --git a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js index ac5f8f5176a6..222b2e000fe2 100644 --- a/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js +++ b/toolkit/content/tests/browser/browser_autoplay_policy_web_audio_with_gum.js @@ -148,7 +148,9 @@ async function testWebAudioWithGUM(testParameters) { info("- check whether audio context starts running -"); try { await SpecialPowers.spawn( - tab.linkedBrowser, [], checkingAudioContextRunningState + tab.linkedBrowser, + [], + checkingAudioContextRunningState ); } catch (error) { ok(false, error.toString()); diff --git a/toolkit/content/tests/browser/browser_autoscroll_disabled.js b/toolkit/content/tests/browser/browser_autoscroll_disabled.js index 4b2f34adc502..d2f6efbd13c3 100644 --- a/toolkit/content/tests/browser/browser_autoscroll_disabled.js +++ b/toolkit/content/tests/browser/browser_autoscroll_disabled.js @@ -46,7 +46,9 @@ add_task(async function() { await new Promise(resolve => window.requestAnimationFrame(resolve)); let msg = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async function() { + gBrowser.selectedBrowser, + [], + async function() { // Skip the first animation frame callback as it's the same callback that // the browser uses to kick off the scrolling. return new Promise(resolve => { diff --git a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js index e581cd0e297b..b4746bc43141 100644 --- a/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js +++ b/toolkit/content/tests/browser/browser_bug295977_autoscroll_overflow.js @@ -260,12 +260,16 @@ body > div > div {width: 1000px;height: 1000px;}\ let scrollHori = test.expected & expectScrollHori; await SpecialPowers.spawn( - gBrowser.selectedBrowser, [{ - scrollVert, - scrollHori, - elemid: test.elem, - checkWindow: test.testwindow, - }], async function(args) { + gBrowser.selectedBrowser, + [ + { + scrollVert, + scrollHori, + elemid: test.elem, + checkWindow: test.testwindow, + }, + ], + async function(args) { let msg = ""; if (args.checkWindow) { if ( diff --git a/toolkit/content/tests/browser/browser_datetime_datepicker.js b/toolkit/content/tests/browser/browser_datetime_datepicker.js index 099097efb8eb..86bd6e435248 100644 --- a/toolkit/content/tests/browser/browser_datetime_datepicker.js +++ b/toolkit/content/tests/browser/browser_datetime_datepicker.js @@ -344,7 +344,9 @@ add_task(async function test_datepicker_clicked() { }); let value = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], async () => { + gBrowser.selectedBrowser, + [], + async () => { return content.document.querySelector("input").value; } ); diff --git a/toolkit/content/tests/browser/browser_delay_autoplay_media_pausedAfterPlay.js b/toolkit/content/tests/browser/browser_delay_autoplay_media_pausedAfterPlay.js index db830fa95912..8bc0e6c215d4 100644 --- a/toolkit/content/tests/browser/browser_delay_autoplay_media_pausedAfterPlay.js +++ b/toolkit/content/tests/browser/browser_delay_autoplay_media_pausedAfterPlay.js @@ -39,7 +39,11 @@ add_task(async function block_autoplay_media() { info("- tab1 should not be blocked, and media should not started -"); await waitForTabBlockEvent(tab1, false); - await SpecialPowers.spawn(tab1.linkedBrowser, [true], check_audio_pause_state); + await SpecialPowers.spawn( + tab1.linkedBrowser, + [true], + check_audio_pause_state + ); info("- select tab2 as foreground tab -"); await BrowserTestUtils.switchTab(window.gBrowser, tab2); @@ -47,7 +51,11 @@ add_task(async function block_autoplay_media() { info("- tab2 should not be blocked and media should be playing -"); await waitForTabBlockEvent(tab2, false); await waitForTabPlayingEvent(tab2, true); - await SpecialPowers.spawn(tab2.linkedBrowser, [false], check_audio_pause_state); + await SpecialPowers.spawn( + tab2.linkedBrowser, + [false], + check_audio_pause_state + ); info("- remove tabs -"); BrowserTestUtils.removeTab(tab1); diff --git a/toolkit/content/tests/browser/browser_delay_autoplay_multipleMedia.js b/toolkit/content/tests/browser/browser_delay_autoplay_multipleMedia.js index 3203fc854ac7..f55024bee2de 100644 --- a/toolkit/content/tests/browser/browser_delay_autoplay_multipleMedia.js +++ b/toolkit/content/tests/browser/browser_delay_autoplay_multipleMedia.js @@ -60,7 +60,9 @@ add_task(async function block_multiple_media() { info("- non-autoplay can't start playback when the tab is blocked -"); await SpecialPowers.spawn( - browser, [], play_nonautoplay_audio_should_be_blocked + browser, + [], + play_nonautoplay_audio_should_be_blocked ); info("- select tab as foreground tab -"); diff --git a/toolkit/content/tests/browser/browser_delay_autoplay_playAfterTabVisible.js b/toolkit/content/tests/browser/browser_delay_autoplay_playAfterTabVisible.js index 94e165fc2e81..e1f3f8f81481 100644 --- a/toolkit/content/tests/browser/browser_delay_autoplay_playAfterTabVisible.js +++ b/toolkit/content/tests/browser/browser_delay_autoplay_playAfterTabVisible.js @@ -57,7 +57,11 @@ add_task(async function media_should_be_able_to_play_in_visible_tab() { info("- audio should be playing -"); await waitForTabBlockEvent(tab, false); - await SpecialPowers.spawn(tab.linkedBrowser, [false], check_audio_pause_state); + await SpecialPowers.spawn( + tab.linkedBrowser, + [false], + check_audio_pause_state + ); info("- remove tab -"); BrowserTestUtils.removeTab(tab); diff --git a/toolkit/content/tests/browser/browser_delay_autoplay_playMediaInMuteTab.js b/toolkit/content/tests/browser/browser_delay_autoplay_playMediaInMuteTab.js index 468569630e2b..c33302169745 100644 --- a/toolkit/content/tests/browser/browser_delay_autoplay_playMediaInMuteTab.js +++ b/toolkit/content/tests/browser/browser_delay_autoplay_playMediaInMuteTab.js @@ -61,7 +61,9 @@ add_task(async function unblock_icon_should_disapear_after_resume_tab() { info("- audio shouldn't be muted -"); await SpecialPowers.spawn( - tab.linkedBrowser, [false], check_audio_volume_and_mute + tab.linkedBrowser, + [false], + check_audio_volume_and_mute ); info("- tab shouldn't display unblocking icon -"); @@ -82,7 +84,9 @@ add_task(async function unblock_icon_should_disapear_after_resume_tab() { info("- audio shoule be muted, but not be blocked -"); await SpecialPowers.spawn( - tab.linkedBrowser, [true], check_audio_volume_and_mute + tab.linkedBrowser, + [true], + check_audio_volume_and_mute ); info("- tab should not display unblocking icon -"); diff --git a/toolkit/content/tests/browser/browser_label_textlink.js b/toolkit/content/tests/browser/browser_label_textlink.js index dcb8e323d522..e6b967cbe9b6 100644 --- a/toolkit/content/tests/browser/browser_label_textlink.js +++ b/toolkit/content/tests/browser/browser_label_textlink.js @@ -3,7 +3,9 @@ add_task(async function() { { gBrowser, url: "about:preferences" }, async function(browser) { let newTabURL = "http://www.example.com/"; - await SpecialPowers.spawn(browser, [newTabURL], async function(newTabURL) { + await SpecialPowers.spawn(browser, [newTabURL], async function( + newTabURL + ) { let doc = content.document; let label = doc.createXULElement("label", { is: "text-link" }); label.href = newTabURL; diff --git a/toolkit/content/tests/browser/browser_mediaPlayback_suspended.js b/toolkit/content/tests/browser/browser_mediaPlayback_suspended.js index 4f1d665a41ce..036860ff2c88 100644 --- a/toolkit/content/tests/browser/browser_mediaPlayback_suspended.js +++ b/toolkit/content/tests/browser/browser_mediaPlayback_suspended.js @@ -56,25 +56,27 @@ async function suspended_pause(url, browser) { info("- the suspended state of audio should be non-suspened -"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio_suspended ); info("- pause playing audio -"); browser.pauseMedia(false /* non-disposable */); + await SpecialPowers.spawn(browser, [true], check_audio_pause_state); await SpecialPowers.spawn( - browser, [true], check_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE], check_audio_suspended + browser, + [SuspendedType.SUSPENDED_PAUSE], + check_audio_suspended ); info("- resume paused audio -"); browser.resumeMedia(); + await SpecialPowers.spawn(browser, [false], check_audio_pause_state); await SpecialPowers.spawn( - browser, [false], check_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio_suspended ); } @@ -87,25 +89,27 @@ async function suspended_pause_disposable(url, browser) { info("- the suspended state of audio should be non-suspened -"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio_suspended ); info("- pause playing audio -"); browser.pauseMedia(true /* disposable */); + await SpecialPowers.spawn(browser, [true], check_audio_pause_state); await SpecialPowers.spawn( - browser, [true], check_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], check_audio_suspended + browser, + [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], + check_audio_suspended ); info("- resume paused audio -"); browser.resumeMedia(); + await SpecialPowers.spawn(browser, [false], check_audio_pause_state); await SpecialPowers.spawn( - browser, [false], check_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio_suspended ); } @@ -118,14 +122,18 @@ async function suspended_stop_disposable(url, browser) { info("- the suspended state of audio should be non-suspened -"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio_suspended ); info("- stop playing audio -"); browser.stopMedia(); await wait_for_event(browser, "DOMAudioPlaybackStopped"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_audio_suspended ); } diff --git a/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js b/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js index bf88bc203826..939a742976f4 100644 --- a/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js +++ b/toolkit/content/tests/browser/browser_mediaPlayback_suspended_multipleAudio.js @@ -162,34 +162,44 @@ async function suspended_pause(url, browser) { info("- the default suspended state of all audio should be non-suspened-"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); info("- pause all audio in the page -"); browser.pauseMedia(false /* non-disposable */); + await SpecialPowers.spawn(browser, [true], check_autoplay_audio_pause_state); await SpecialPowers.spawn( - browser, [true], check_autoplay_audio_pause_state + browser, + [SuspendedType.SUSPENDED_PAUSE], + check_autoplay_audio_suspended ); await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE], check_autoplay_audio_suspended - ); - await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_nonautoplay_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_nonautoplay_audio_suspended ); info("- no audio can be playback during suspended-paused -"); await SpecialPowers.spawn( - browser, [], play_nonautoplay_audio_should_be_paused + browser, + [], + play_nonautoplay_audio_should_be_paused ); await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE], check_nonautoplay_audio_suspended + browser, + [SuspendedType.SUSPENDED_PAUSE], + check_nonautoplay_audio_suspended ); info("- both audio should be resumed at the same time -"); browser.resumeMedia(); await SpecialPowers.spawn(browser, [], all_audio_onresume); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); info("- both audio should be paused at the same time -"); @@ -206,33 +216,39 @@ async function suspended_pause_disposable(url, browser) { info("- the default suspended state of all audio should be non-suspened -"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); info("- only pause playing audio in the page -"); browser.pauseMedia(true /* non-disposable */); + await SpecialPowers.spawn(browser, [true], check_autoplay_audio_pause_state); await SpecialPowers.spawn( - browser, [true], check_autoplay_audio_pause_state + browser, + [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], + check_autoplay_audio_suspended ); await SpecialPowers.spawn( - browser, [SuspendedType.SUSPENDED_PAUSE_DISPOSABLE], check_autoplay_audio_suspended - ); - await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_nonautoplay_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_nonautoplay_audio_suspended ); info("- new playing audio should be playback correctly -"); await SpecialPowers.spawn( - browser, [], play_nonautoplay_audio_should_play_until_ended + browser, + [], + play_nonautoplay_audio_should_play_until_ended ); info("- should only resume one audio -"); browser.resumeMedia(); + await SpecialPowers.spawn(browser, [false], check_autoplay_audio_pause_state); await SpecialPowers.spawn( - browser, [false], check_autoplay_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); } @@ -245,29 +261,35 @@ async function suspended_stop_disposable(url, browser) { info("- the default suspended state of all audio should be non-suspened -"); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); info("- only stop playing audio in the page -"); browser.stopMedia(); await wait_for_event(browser, "DOMAudioPlaybackStopped"); + await SpecialPowers.spawn(browser, [true], check_autoplay_audio_pause_state); await SpecialPowers.spawn( - browser, [true], check_autoplay_audio_pause_state - ); - await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); info("- new playing audio should be playback correctly -"); await SpecialPowers.spawn( - browser, [], play_nonautoplay_audio_should_play_until_ended + browser, + [], + play_nonautoplay_audio_should_play_until_ended ); info("- no any audio can be resumed by page -"); browser.resumeMedia(); await SpecialPowers.spawn(browser, [], no_audio_resumed); await SpecialPowers.spawn( - browser, [SuspendedType.NONE_SUSPENDED], check_all_audio_suspended + browser, + [SuspendedType.NONE_SUSPENDED], + check_all_audio_suspended ); } diff --git a/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js b/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js index 0b23647ea5d9..4725f4cb9f08 100644 --- a/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js +++ b/toolkit/content/tests/browser/browser_resume_bkg_video_on_tab_hover.js @@ -83,7 +83,9 @@ function check_should_not_send_unselected_tab_hover_msg(browser) { function get_video_decoding_suspend_promise(browser, reload) { let suspend = true; return SpecialPowers.spawn( - browser, [{ suspend, reload }], check_video_decoding_state + browser, + [{ suspend, reload }], + check_video_decoding_state ); } @@ -91,7 +93,9 @@ function get_video_decoding_resume_promise(browser) { let suspend = false; let reload = false; return SpecialPowers.spawn( - browser, [{ suspend, reload }], check_video_decoding_state + browser, + [{ suspend, reload }], + check_video_decoding_state ); } diff --git a/toolkit/content/tests/browser/browser_sound_indicator_silent_video.js b/toolkit/content/tests/browser/browser_sound_indicator_silent_video.js index e39b1b75e0af..2679482fc552 100644 --- a/toolkit/content/tests/browser/browser_sound_indicator_silent_video.js +++ b/toolkit/content/tests/browser/browser_sound_indicator_silent_video.js @@ -43,7 +43,9 @@ add_task(async function should_not_show_sound_indicator_for_silent_video() { BrowserTestUtils.loadURI(tab.linkedBrowser, SILENT_PAGE); await BrowserTestUtils.browserLoaded(tab.linkedBrowser); await SpecialPowers.spawn( - tab.linkedBrowser, [true], check_audio_playing_state + tab.linkedBrowser, + [true], + check_audio_playing_state ); info("- tab should not have sound indicator after playing silent video -"); @@ -70,7 +72,9 @@ add_task( BrowserTestUtils.loadURI(tab.linkedBrowser, ALMOST_SILENT_PAGE); await BrowserTestUtils.browserLoaded(tab.linkedBrowser); await SpecialPowers.spawn( - tab.linkedBrowser, [true], check_audio_playing_state + tab.linkedBrowser, + [true], + check_audio_playing_state ); info( diff --git a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js index 87d614ba5ab5..3dba63d19872 100644 --- a/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js +++ b/toolkit/crashreporter/test/browser/browser_aboutCrashesResubmit.js @@ -187,8 +187,8 @@ function test() { ); BrowserTestUtils.openNewForegroundTab(gBrowser, "about:crashes").then(tab => { - SpecialPowers.spawn(tab.linkedBrowser, [crashes], check_crash_list).then(() => - check_submit_pending(tab, crashes) + SpecialPowers.spawn(tab.linkedBrowser, [crashes], check_crash_list).then( + () => check_submit_pending(tab, crashes) ); }); } diff --git a/toolkit/modules/tests/browser/head.js b/toolkit/modules/tests/browser/head.js index a69239d3c111..7a4a316cd0e9 100644 --- a/toolkit/modules/tests/browser/head.js +++ b/toolkit/modules/tests/browser/head.js @@ -92,7 +92,9 @@ function promiseTestHighlighterOutput( extraTest = () => {} ) { return SpecialPowers.spawn( - browser, [{ word, expectedResult, extraTest: extraTest.toSource() }], async function({ word, expectedResult, extraTest }) { + browser, + [{ word, expectedResult, extraTest: extraTest.toSource() }], + async function({ word, expectedResult, extraTest }) { return new Promise((resolve, reject) => { let stubbed = {}; let callCounts = { diff --git a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js index dbf48313aa81..228b95265de2 100644 --- a/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js +++ b/toolkit/mozapps/extensions/test/browser/browser_webapi_install.js @@ -45,7 +45,9 @@ add_task(async function setup() { // that event is triggered. async function testInstall(browser, args, steps, description) { let success = await SpecialPowers.spawn( - browser, [{ args, steps }], async function(opts) { + browser, + [{ args, steps }], + async function(opts) { let { args, steps } = opts; let install = await content.navigator.mozAddonManager.createInstall(args); if (!install) { @@ -380,31 +382,33 @@ add_task( add_task(async function test_permissions() { function testBadUrl(url, pattern, successMessage) { return BrowserTestUtils.withNewTab(TESTPAGE, async function(browser) { - let result = await SpecialPowers.spawn(browser, [{ url, pattern }], function( - opts - ) { - return new Promise(resolve => { - content.navigator.mozAddonManager - .createInstall({ url: opts.url }) - .then( - () => { - resolve({ - success: false, - message: "createInstall should not have succeeded", - }); - }, - err => { - if (err.message.match(new RegExp(opts.pattern))) { - resolve({ success: true }); + let result = await SpecialPowers.spawn( + browser, + [{ url, pattern }], + function(opts) { + return new Promise(resolve => { + content.navigator.mozAddonManager + .createInstall({ url: opts.url }) + .then( + () => { + resolve({ + success: false, + message: "createInstall should not have succeeded", + }); + }, + err => { + if (err.message.match(new RegExp(opts.pattern))) { + resolve({ success: true }); + } + resolve({ + success: false, + message: `Wrong error message: ${err.message}`, + }); } - resolve({ - success: false, - message: `Wrong error message: ${err.message}`, - }); - } - ); - }); - }); + ); + }); + } + ); is(result.success, true, result.message || successMessage); }); } diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js index 063fa2ff35b2..c8896da34351 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger.js @@ -52,7 +52,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js index ec079fe17f1f..e2fea46170b6 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_amosigned_trigger_iframe.js @@ -52,7 +52,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.frames[0].document.getElementById("return").textContent, status: content.frames[0].document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js b/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js index 17caf1d4a408..c87b2a851769 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_bug638292.js @@ -20,7 +20,9 @@ add_task(async function() { let newtab = await loadedPromise; let result = await SpecialPowers.spawn( - newtab.linkedBrowser, [], async function() { + newtab.linkedBrowser, + [], + async function() { return content.document.getElementById("enabled").textContent == "true"; } ); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js b/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js index 08e59bcd4170..51713a7646d6 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_containers.js @@ -83,7 +83,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js index 6351ba9a9d77..f41cfca66acd 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_corrupt.js @@ -33,7 +33,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js index c58db24380b4..268ec0cc2820 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled.js @@ -6,7 +6,9 @@ function test() { gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TESTROOT); SpecialPowers.spawn( - gBrowser.selectedBrowser, [TESTROOT + "enabled.html"], function(url) { + gBrowser.selectedBrowser, + [TESTROOT + "enabled.html"], + function(url) { return new Promise(resolve => { function page_loaded() { content.removeEventListener("PageLoaded", page_loaded); @@ -14,11 +16,19 @@ function test() { } function load_listener() { - docShell.chromeEventHandler.removeEventListener("load", load_listener, true); + docShell.chromeEventHandler.removeEventListener( + "load", + load_listener, + true + ); content.addEventListener("PageLoaded", page_loaded); } - docShell.chromeEventHandler.addEventListener("load", load_listener, true); + docShell.chromeEventHandler.addEventListener( + "load", + load_listener, + true + ); content.location.href = url; }); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js index 0545510b7484..615dfd064b3f 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled2.js @@ -8,7 +8,9 @@ function test() { gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TESTROOT); SpecialPowers.spawn( - gBrowser.selectedBrowser, [TESTROOT + "enabled.html"], function(url) { + gBrowser.selectedBrowser, + [TESTROOT + "enabled.html"], + function(url) { return new Promise(resolve => { function page_loaded() { content.removeEventListener("PageLoaded", page_loaded); @@ -16,11 +18,19 @@ function test() { } function load_listener() { - docShell.chromeEventHandler.removeEventListener("load", load_listener, true); + docShell.chromeEventHandler.removeEventListener( + "load", + load_listener, + true + ); content.addEventListener("PageLoaded", page_loaded); } - docShell.chromeEventHandler.addEventListener("load", load_listener, true); + docShell.chromeEventHandler.addEventListener( + "load", + load_listener, + true + ); content.location.href = url; }); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js index aac7b787c287..18e8b8202447 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_enabled3.js @@ -16,7 +16,9 @@ function test() { gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser, TESTROOT); SpecialPowers.spawn( - gBrowser.selectedBrowser, [TESTROOT + "installtrigger.html?" + triggers], url => { + gBrowser.selectedBrowser, + [TESTROOT + "installtrigger.html?" + triggers], + url => { return new Promise(resolve => { function page_loaded() { content.removeEventListener("PageLoaded", page_loaded); @@ -24,11 +26,19 @@ function test() { } function load_listener() { - docShell.chromeEventHandler.removeEventListener("load", load_listener, true); + docShell.chromeEventHandler.removeEventListener( + "load", + load_listener, + true + ); content.addEventListener("InstallTriggered", page_loaded); } - docShell.chromeEventHandler.addEventListener("load", load_listener, true); + docShell.chromeEventHandler.addEventListener( + "load", + load_listener, + true + ); content.location.href = url; }); diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js b/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js index a6150118fb58..bc9f1435d633 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_newwindow.js @@ -47,7 +47,9 @@ async function finish_test(count) { PermissionTestUtils.remove(exampleURI, "install"); const results = await SpecialPowers.spawn( - win.gBrowser.selectedBrowser, [], () => { + win.gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js b/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js index 297573747b87..6e7de398f40d 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_privatebrowsing.js @@ -85,7 +85,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gPrivateWin.gBrowser.selectedBrowser, [], () => { + gPrivateWin.gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js b/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js index 30a838d847f9..4944b592006d 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_relative.js @@ -46,7 +46,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js index 8a49824724db..98ebb8662597 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger.js @@ -47,7 +47,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js index f2fe39a91d32..4ad58ae7dda4 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_unsigned_trigger_iframe.js @@ -52,7 +52,9 @@ const finish_test = async function(count) { PermissionTestUtils.remove("http://example.com", "install"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.frames[0].document.getElementById("return").textContent, status: content.frames[0].document.getElementById("status").textContent, diff --git a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js b/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js index 7cdc3d5f0600..0e3df65ae4bd 100644 --- a/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js +++ b/toolkit/mozapps/extensions/test/xpinstall/browser_whitelist.js @@ -48,7 +48,9 @@ const finish_test = async function(count) { is(count, 1, "1 Add-on should have been successfully installed"); const results = await SpecialPowers.spawn( - gBrowser.selectedBrowser, [], () => { + gBrowser.selectedBrowser, + [], + () => { return { return: content.document.getElementById("return").textContent, status: content.document.getElementById("status").textContent, diff --git a/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js b/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js index ae6d75fc7fb5..68b32b268d72 100644 --- a/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js +++ b/toolkit/mozapps/update/tests/browser/browser_aboutPrefs_settings.js @@ -9,7 +9,9 @@ ChromeUtils.import("resource://gre/modules/osfile.jsm", this); // UI. Requires a tab with about:preferences open to be passed in. async function changeAndVerifyPref(tab, newConfigValue) { await SpecialPowers.spawn( - tab.linkedBrowser, [{ newConfigValue }], async function({ newConfigValue }) { + tab.linkedBrowser, + [{ newConfigValue }], + async function({ newConfigValue }) { let radioId = newConfigValue ? "autoDesktop" : "manualDesktop"; let radioElement = content.document.getElementById(radioId); radioElement.click(); @@ -45,7 +47,9 @@ async function changeAndVerifyPref(tab, newConfigValue) { } await SpecialPowers.spawn( - tab.linkedBrowser, [{ newConfigValue }], async function({ newConfigValue }) { + tab.linkedBrowser, + [{ newConfigValue }], + async function({ newConfigValue }) { let updateRadioGroup = content.document.getElementById( "updateRadioGroup" ); diff --git a/toolkit/mozapps/update/tests/browser/head.js b/toolkit/mozapps/update/tests/browser/head.js index 81448d111558..cfc47d0427ed 100644 --- a/toolkit/mozapps/update/tests/browser/head.js +++ b/toolkit/mozapps/update/tests/browser/head.js @@ -869,7 +869,9 @@ function runAboutPrefsUpdateTest(params, steps) { const { panelId, checkActiveUpdate, continueFile, downloadInfo } = step; return (async function() { await SpecialPowers.spawn( - tab.linkedBrowser, [{ panelId }], async ({ panelId }) => { + tab.linkedBrowser, + [{ panelId }], + async ({ panelId }) => { let updateDeck = content.document.getElementById("updateDeck"); // Also continue if the selected panel ID is 'apply' since there are no // other panels after 'apply'. @@ -951,7 +953,9 @@ function runAboutPrefsUpdateTest(params, steps) { } await SpecialPowers.spawn( - tab.linkedBrowser, [{ panelId, gDetailsURL }], async ({ panelId, gDetailsURL }) => { + tab.linkedBrowser, + [{ panelId, gDetailsURL }], + async ({ panelId, gDetailsURL }) => { let linkPanels = [ "downloadFailed", "manualUpdate", diff --git a/tools/profiler/tests/browser/browser_test_feature_ipcmessages.js b/tools/profiler/tests/browser/browser_test_feature_ipcmessages.js index 1b963ecf62ed..95bc0efed423 100644 --- a/tools/profiler/tests/browser/browser_test_feature_ipcmessages.js +++ b/tools/profiler/tests/browser/browser_test_feature_ipcmessages.js @@ -39,7 +39,9 @@ add_task(async function test_profile_feature_ipcmessges() { await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( - contentBrowser, [], () => Services.appinfo.processID + contentBrowser, + [], + () => Services.appinfo.processID ); await waitForLoad(); @@ -73,7 +75,9 @@ add_task(async function test_profile_feature_ipcmessges() { await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( - contentBrowser, [], () => Services.appinfo.processID + contentBrowser, + [], + () => Services.appinfo.processID ); await waitForLoad(); diff --git a/tools/profiler/tests/browser/browser_test_feature_jsallocations.js b/tools/profiler/tests/browser/browser_test_feature_jsallocations.js index 24822cfffaca..ae925e1fcdca 100644 --- a/tools/profiler/tests/browser/browser_test_feature_jsallocations.js +++ b/tools/profiler/tests/browser/browser_test_feature_jsallocations.js @@ -23,7 +23,9 @@ add_task(async function test_profile_feature_jsallocations() { const url = BASE_URL + "do_work_500ms.html"; await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( - contentBrowser, [], () => Services.appinfo.processID + contentBrowser, + [], + () => Services.appinfo.processID ); // Wait 500ms so that the tab finishes executing. diff --git a/tools/profiler/tests/browser/browser_test_feature_nostacksampling.js b/tools/profiler/tests/browser/browser_test_feature_nostacksampling.js index 95df2bcda28f..0fdae614eed3 100644 --- a/tools/profiler/tests/browser/browser_test_feature_nostacksampling.js +++ b/tools/profiler/tests/browser/browser_test_feature_nostacksampling.js @@ -19,7 +19,9 @@ add_task(async function test_profile_feature_nostacksampling() { const url = BASE_URL + "do_work_500ms.html"; await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( - contentBrowser, [], () => Services.appinfo.processID + contentBrowser, + [], + () => Services.appinfo.processID ); // Wait 500ms so that the tab finishes executing. diff --git a/tools/profiler/tests/browser/browser_test_feature_preferencereads.js b/tools/profiler/tests/browser/browser_test_feature_preferencereads.js index ae2d3a4560f2..22b628095b8b 100644 --- a/tools/profiler/tests/browser/browser_test_feature_preferencereads.js +++ b/tools/profiler/tests/browser/browser_test_feature_preferencereads.js @@ -48,7 +48,9 @@ add_task(async function test_profile_feature_preferencereads() { const url = BASE_URL + "fixed_height.html"; await BrowserTestUtils.withNewTab(url, async contentBrowser => { const contentPid = await SpecialPowers.spawn( - contentBrowser, [], () => Services.appinfo.processID + contentBrowser, + [], + () => Services.appinfo.processID ); await waitForPaintAfterLoad(); @@ -72,10 +74,14 @@ add_task(async function test_profile_feature_preferencereads() { // Now reload the tab with a clean run. await SpecialPowers.spawn(contentBrowser, [], () => { return new Promise(resolve => { - docShell.chromeEventHandler.addEventListener("pageshow", () => resolve(), { - capturing: true, - once: true, - }); + docShell.chromeEventHandler.addEventListener( + "pageshow", + () => resolve(), + { + capturing: true, + once: true, + } + ); content.location.reload(); }); }); diff --git a/widget/tests/browser/browser_test_clipboardcache.js b/widget/tests/browser/browser_test_clipboardcache.js index a1506fc164a6..f567f7b14a38 100644 --- a/widget/tests/browser/browser_test_clipboardcache.js +++ b/widget/tests/browser/browser_test_clipboardcache.js @@ -78,9 +78,13 @@ async function testCopyPaste(isPrivate) { let browser = tab.linkedBrowser; // Sanitize environment - await SpecialPowers.spawn(browser, [SHORT_STRING_NO_CACHE], async shortStr => { - await content.navigator.clipboard.writeText(shortStr); - }); + await SpecialPowers.spawn( + browser, + [SHORT_STRING_NO_CACHE], + async shortStr => { + await content.navigator.clipboard.writeText(shortStr); + } + ); let initialFdCount = getClipboardCacheFDCount(); @@ -123,9 +127,13 @@ async function testCopyPaste(isPrivate) { } // Cleanup. - await SpecialPowers.spawn(browser, [SHORT_STRING_NO_CACHE], async shortStr => { - await content.navigator.clipboard.writeText(shortStr); - }); + await SpecialPowers.spawn( + browser, + [SHORT_STRING_NO_CACHE], + async shortStr => { + await content.navigator.clipboard.writeText(shortStr); + } + ); is(getClipboardCacheFDCount(), initialFdCount, "Drop clipboard cache if any"); BrowserTestUtils.removeTab(tab);