Skip to content

Commit

Permalink
Bug 1596918: Part 3a - Scripted rewrite of most ContentTask.spawn cal…
Browse files Browse the repository at this point in the history
…ls to SpecialPowers.spawn calls. r=mccr8,remote-protocol-reviewers,ato

This is generally pretty straightforward, and rewrites nearly all calls. It
skips the ones that it can detect using frame script globals like
`sendAsyncMessage`, though.

Differential Revision: https://phabricator.services.mozilla.com/D53740
  • Loading branch information
kmaglione committed Dec 6, 2019
1 parent b7e85a9 commit 799653e
Show file tree
Hide file tree
Showing 985 changed files with 2,917 additions and 3,886 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_task(async function checkWrongSystemTimeWarning() {
info("Loading and waiting for the cert error");
await certErrorLoaded;

return ContentTask.spawn(browser, null, async function() {
return SpecialPowers.spawn(browser, [], async function() {
let doc = content.document;
let div = doc.getElementById("errorShortDescText");
let systemDateDiv = doc.getElementById("wrongSystemTime_systemDate1");
Expand Down
24 changes: 10 additions & 14 deletions browser/base/content/test/about/browser_aboutCertError_exception.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ add_task(async function checkExceptionDialogButton() {
let browser = tab.linkedBrowser;
let loaded = BrowserTestUtils.browserLoaded(browser, false, BAD_CERT);
info("Clicking the exceptionDialogButton in advanced panel");
await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
let doc = content.document;
let exceptionButton = doc.getElementById("exceptionDialogButton");
exceptionButton.click();
Expand All @@ -25,7 +25,7 @@ add_task(async function checkExceptionDialogButton() {
info("Loading the url after adding exception");
await loaded;

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
let doc = content.document;
ok(
!doc.documentURI.startsWith("about:certerror"),
Expand All @@ -52,10 +52,8 @@ add_task(async function checkPermanentExceptionPref() {
let browser = tab.linkedBrowser;
let loaded = BrowserTestUtils.browserLoaded(browser, false, BAD_CERT);
info("Clicking the exceptionDialogButton in advanced panel");
let securityInfoAsString = await ContentTask.spawn(
browser,
null,
async function() {
let securityInfoAsString = await SpecialPowers.spawn(
browser, [], async function() {
let doc = content.document;
let exceptionButton = doc.getElementById("exceptionDialogButton");
exceptionButton.click();
Expand All @@ -72,7 +70,7 @@ add_task(async function checkPermanentExceptionPref() {
info("Loading the url after adding exception");
await loaded;

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
let doc = content.document;
ok(
!doc.documentURI.startsWith("about:certerror"),
Expand Down Expand Up @@ -116,7 +114,7 @@ add_task(async function checkBadStsCert() {
let tab = await openErrorPage(BAD_STS_CERT, useFrame);
let browser = tab.linkedBrowser;

await ContentTask.spawn(browser, { frame: useFrame }, async function({
await SpecialPowers.spawn(browser, [{ frame: useFrame }], async function({
frame,
}) {
let doc = frame
Expand All @@ -129,10 +127,8 @@ add_task(async function checkBadStsCert() {
);
});

let message = await ContentTask.spawn(
browser,
{ frame: useFrame },
async function({ frame }) {
let message = await SpecialPowers.spawn(
browser, [{ frame: useFrame }], async function({ frame }) {
let doc = frame
? content.document.querySelector("iframe").contentDocument
: content.document;
Expand Down Expand Up @@ -172,7 +168,7 @@ add_task(async function checkhideAddExceptionButtonViaPref() {
let tab = await openErrorPage(BAD_CERT, useFrame);
let browser = tab.linkedBrowser;

await ContentTask.spawn(browser, { frame: useFrame }, async function({
await SpecialPowers.spawn(browser, [{ frame: useFrame }], async function({
frame,
}) {
let doc = frame
Expand All @@ -199,7 +195,7 @@ add_task(async function checkhideAddExceptionButtonInFrames() {
let tab = await openErrorPage(BAD_CERT, true);
let browser = tab.linkedBrowser;

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
let doc = content.document.querySelector("iframe").contentDocument;
let exceptionButton = doc.getElementById("exceptionDialogButton");
ok(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ add_task(async function checkMitmPriming() {
// The page will reload after the initial canary request, so we'll just
// wait until we're seeing the dedicated MitM page.
await TestUtils.waitForCondition(function() {
return ContentTask.spawn(browser, {}, () => {
return SpecialPowers.spawn(browser, [], () => {
return (
content.document.body.getAttribute("code") ==
"MOZILLA_PKIX_ERROR_MITM_DETECTED"
Expand All @@ -54,7 +54,7 @@ add_task(async function checkMitmPriming() {
"Stored the correct issuer"
);

await ContentTask.spawn(browser, {}, () => {
await SpecialPowers.spawn(browser, [], () => {
let mitmName1 = content.document.querySelector(
"#errorShortDescText .mitm-name"
);
Expand Down Expand Up @@ -113,7 +113,7 @@ add_task(async function checkMitmAutoEnableEnterpriseRoots() {
// The page will reload after the initial canary request, so we'll just
// wait until we're seeing the dedicated MitM page.
await TestUtils.waitForCondition(function() {
return ContentTask.spawn(browser, {}, () => {
return SpecialPowers.spawn(browser, [], () => {
return (
content.document.body.getAttribute("code") ==
"MOZILLA_PKIX_ERROR_MITM_DETECTED"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,8 @@ add_task(async function checkUntrustedCertError() {
let tab = await openErrorPage(UNKNOWN_ISSUER);
let browser = tab.linkedBrowser;
info("Clicking the exceptionDialogButton in advanced panel");
let badCertTechnicalInfoText = await ContentTask.spawn(
browser,
null,
checkAdvancedAndGetTechnicalInfoText
let badCertTechnicalInfoText = await SpecialPowers.spawn(
browser, [], checkAdvancedAndGetTechnicalInfoText
);
checkCorrectMessages(badCertTechnicalInfoText, browser);
BrowserTestUtils.removeTab(gBrowser.selectedTab);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ add_task(async function() {
Services.search.setDefault(engine),
]);
let promise = BrowserTestUtils.browserLoaded(browser);
await ContentTask.spawn(browser, { needle }, async function(args) {
await SpecialPowers.spawn(browser, [{ needle }], async function(args) {
let doc = content.document;
let el = doc.querySelector(["#searchText", "#newtab-search-text"]);
el.value = args.needle;
Expand All @@ -51,7 +51,7 @@ add_task(async function() {
await promise;

// When the search results load, check them for correctness.
await ContentTask.spawn(browser, { needle }, async function(args) {
await SpecialPowers.spawn(browser, [{ needle }], async function(args) {
let loadedText = content.document.body.textContent;
ok(loadedText, "search page loaded");
is(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ add_task(async function() {
);
});

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
// Start composition and type "x"
let input = content.document.querySelector([
"#searchText",
Expand All @@ -46,7 +46,7 @@ add_task(async function() {
});

info("Setting up the mutation observer before synthesizing composition");
let mutationPromise = ContentTask.spawn(browser, null, async function() {
let mutationPromise = SpecialPowers.spawn(browser, [], async function() {
let searchController = content.wrappedJSObject.gContentSearchController;

// Wait for the search suggestions to become visible.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ add_task(async function() {
Services.search.setDefault(engine),
]);

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
// Type an X in the search input.
let input = content.document.querySelector([
"#searchText",
Expand All @@ -30,7 +30,7 @@ add_task(async function() {

await BrowserTestUtils.synthesizeKey("x", {}, browser);

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
// Wait for the search suggestions to become visible.
let table = content.document.getElementById("searchSuggestionTable");
let input = content.document.querySelector([
Expand All @@ -57,7 +57,7 @@ add_task(async function() {
await BrowserTestUtils.synthesizeKey("a", { accelKey: true }, browser);
await BrowserTestUtils.synthesizeKey("VK_DELETE", {}, browser);

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
let table = content.document.getElementById("searchSuggestionTable");
await ContentTaskUtils.waitForCondition(
() => table.hidden,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,8 @@ add_task(async function() {
Services.search.setDefault(engine),
]);

await ContentTask.spawn(
browser,
{ expectedName: engine.name },
async function(args) {
await SpecialPowers.spawn(
browser, [{ expectedName: engine.name }], async function(args) {
let engineName =
content.wrappedJSObject.gContentSearchController.defaultEngine.name;
is(
Expand Down Expand Up @@ -65,7 +63,7 @@ add_task(async function() {
);

// Perform a search to increase the SEARCH_COUNT histogram.
await ContentTask.spawn(browser, { searchStr }, async function(args) {
await SpecialPowers.spawn(browser, [{ searchStr }], async function(args) {
let doc = content.document;
info("Perform a search.");
let el = doc.querySelector(["#searchText", "#newtab-search-text"]);
Expand Down
8 changes: 4 additions & 4 deletions browser/base/content/test/about/browser_aboutNetError.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ add_task(async function resetToDefaultConfig() {
TLS12_PAGE
);

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
const doc = content.document;
ok(
doc.documentURI.startsWith("about:neterror"),
Expand Down Expand Up @@ -124,7 +124,7 @@ add_task(async function checkLearnMoreLink() {

const baseURL = Services.urlFormatter.formatURLPref("app.support.baseURL");

await ContentTask.spawn(browser, baseURL, function(_baseURL) {
await SpecialPowers.spawn(browser, [baseURL], function(_baseURL) {
const doc = content.document;
ok(
doc.documentURI.startsWith("about:neterror"),
Expand Down Expand Up @@ -176,7 +176,7 @@ add_task(async function checkEnable10() {
TLS10_PAGE
);

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
const doc = content.document;
ok(
doc.documentURI.startsWith("about:neterror"),
Expand Down Expand Up @@ -227,7 +227,7 @@ add_task(async function dontOffer10WhenAlreadyEnabled() {
info("Loading and waiting for the net error");
await pageLoaded;

await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
const doc = content.document;
ok(
doc.documentURI.startsWith("about:neterror"),
Expand Down
18 changes: 6 additions & 12 deletions browser/base/content/test/about/browser_aboutSupport.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@ add_task(async function() {
await BrowserTestUtils.withNewTab(
{ gBrowser, url: "about:support" },
async function(browser) {
let keyLocationServiceGoogleStatus = await ContentTask.spawn(
browser,
null,
async function() {
let keyLocationServiceGoogleStatus = await SpecialPowers.spawn(
browser, [], async function() {
let textBox = content.document.getElementById(
"key-location-service-google-box"
);
Expand All @@ -26,10 +24,8 @@ add_task(async function() {
"Google location service API key status shown"
);

let keySafebrowsingGoogleStatus = await ContentTask.spawn(
browser,
null,
async function() {
let keySafebrowsingGoogleStatus = await SpecialPowers.spawn(
browser, [], async function() {
let textBox = content.document.getElementById(
"key-safebrowsing-google-box"
);
Expand All @@ -45,10 +41,8 @@ add_task(async function() {
"Google Safebrowsing API key status shown"
);

let keyMozillaStatus = await ContentTask.spawn(
browser,
null,
async function() {
let keyMozillaStatus = await SpecialPowers.spawn(
browser, [], async function() {
let textBox = content.document.getElementById("key-mozilla-box");
await ContentTaskUtils.waitForCondition(
() => content.document.l10n.getAttributes(textBox).id,
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/about/browser_bug435325.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ add_task(async function checkSwitchPageToOnlineMode() {
);

// Click on the 'Try again' button.
await ContentTask.spawn(browser, null, async function() {
await SpecialPowers.spawn(browser, [], async function() {
ok(
content.document.documentURI.startsWith("about:neterror?e=netOffline"),
"Should be showing error page"
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/about/browser_bug633691.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_task(async function test() {
await BrowserTestUtils.withNewTab({ gBrowser, url: URL }, async function(
browser
) {
let context = await ContentTask.spawn(browser, null, function() {
let context = await SpecialPowers.spawn(browser, [], function() {
let iframe = content.document.querySelector("iframe");
iframe.src = "https://expired.example.com/";
return BrowsingContext.getFromWindow(iframe.contentWindow);
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/about/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function promiseTabLoadEvent(tab, url) {
* Wait for the search engine to change.
*/
function promiseContentSearchChange(browser, newEngineName) {
return ContentTask.spawn(browser, { newEngineName }, async function(args) {
return SpecialPowers.spawn(browser, [{ newEngineName }], async function(args) {
return new Promise(resolve => {
content.addEventListener("ContentSearchService", function listener(
aEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ add_task(async function test_notificationReplace() {
url: notificationURL,
},
async function dummyTabTask(aBrowser) {
await ContentTask.spawn(aBrowser, {}, async function() {
await SpecialPowers.spawn(aBrowser, [], async function() {
let win = content.window.wrappedJSObject;
let notification = win.showNotification1();
let promiseCloseEvent = ContentTaskUtils.waitForEvent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ add_task(async function test_notificationPreventDefaultAndSwitchTabs() {

// First, show a notification that will be have the tab-switching prevented.
function promiseNotificationEvent(evt) {
return ContentTask.spawn(aBrowser, evt, async function(contentEvt) {
return SpecialPowers.spawn(aBrowser, [evt], async function(contentEvt) {
return new Promise(resolve => {
let contentNotification = content.wrappedJSObject._notification;
contentNotification.addEventListener(
Expand Down
4 changes: 2 additions & 2 deletions browser/base/content/test/alerts/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function promiseWindowClosed(window) {
*/
function openNotification(aBrowser, fn, timeout) {
info(`openNotification: ${fn}`);
return ContentTask.spawn(aBrowser, [fn, timeout], async function([
return SpecialPowers.spawn(aBrowser, [[fn, timeout]], async function([
contentFn,
contentTimeout,
]) {
Expand All @@ -60,7 +60,7 @@ function openNotification(aBrowser, fn, timeout) {
}

function closeNotification(aBrowser) {
return ContentTask.spawn(aBrowser, null, function() {
return SpecialPowers.spawn(aBrowser, [], function() {
content.wrappedJSObject._notification.close();
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ add_task(async function checkCaptivePortalCertErrorUI() {
CANONICAL_URL
);

await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
ok(
doc.body.classList.contains("captiveportal"),
Expand Down Expand Up @@ -84,7 +84,7 @@ add_task(async function checkCaptivePortalCertErrorUI() {
// Passing an empty function to BrowserTestUtils.switchTab lets us wait for an arbitrary
// tab switch.
portalTabPromise = BrowserTestUtils.switchTab(gBrowser, () => {});
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
info("Clicking the Open Login Page button.");
content.document.getElementById("openPortalLoginPageButton").click();
});
Expand All @@ -102,7 +102,7 @@ add_task(async function checkCaptivePortalCertErrorUI() {
"Waiting for error tab to be reloaded after the captive portal was freed."
);
await errorTabReloaded;
await ContentTask.spawn(browser, null, () => {
await SpecialPowers.spawn(browser, [], () => {
let doc = content.document;
ok(
!doc.body.classList.contains("captiveportal"),
Expand Down
Loading

0 comments on commit 799653e

Please sign in to comment.