Skip to content

Commit

Permalink
Bug 1753696 - Automatic rewrite: replace add_task(setup with add_setu…
Browse files Browse the repository at this point in the history
…p in browser mochitest, r=Standard8,webcompat-reviewers,twisniewski

Differential Revision: https://phabricator.services.mozilla.com/D141437
  • Loading branch information
gijsk committed Mar 30, 2022
1 parent 4d3b614 commit 8e67201
Show file tree
Hide file tree
Showing 471 changed files with 472 additions and 465 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const bookmarksInfo = [
},
];

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
// Ensure we can wait for about:newtab to load.
set: [["browser.newtab.preload", false]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const PAGE =
// to show up before we decide that it's not coming.
const NOTIFICATION_TIMEOUT_SECS = 2000;

add_task(async function setup() {
add_setup(async function() {
await addNotificationPermission(PAGE);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function checkCaptivePortalTabReference(evt, currState) {
gBrowser.removeTab(errorTab);
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["captivedetect.canonicalURL", CANONICAL_URL],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

"use strict";

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["captivedetect.canonicalURL", CANONICAL_URL],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const testPath = getRootDirectory(gTestPath).replace(
const CANONICAL_URI = Services.io.newURI(testPath);
const PERMISSION_NAME = "https-only-load-insecure";

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
// That changes the canoncicalURL from "http://{server}/captive-detect/success.txt"
// to http://example.com
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function unlockHandler(request, response) {
response.setHeader("Location", CANONICAL_SUCCESS_URL);
}

add_task(async function setup() {
add_setup(async function() {
// Set up a mock server for handling captive portal redirect.
server = new HttpServer();
server.registerPathHandler("/success", redirectHandler);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async function openInNewTabAndReturnContent(selector) {
return blobDataFromContent;
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [["privacy.partition.bloburl_per_agent_cluster", false]],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ async function openAndCheckContextMenu(contextMenu, target) {
}

// Ensure that we can run touch events properly for windows [10]
add_task(async function setup() {
add_setup(async function() {
let isWindows = AppConstants.isPlatformAndVersionAtLeast("win", "10.0");
await SpecialPowers.pushPrefEnv({
set: [["apz.test.fails_with_native_injection", isWindows]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function createLinks(linkInfos) {
});
}

add_task(async function setup() {
add_setup(async function() {
const URL = ROOT + "discovery.html";
let iconPromise = waitIcon("http://mochi.test:8888/favicon.ico");
let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, URL);
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/forms/browser_selectpopup.js
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ async function doSelectTests(contentType, content) {
BrowserTestUtils.removeTab(tab);
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.forms.select.customstyling", true]],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ async function testSelectColors(selectID, itemCount, options) {
// System colors may be different in content pages and chrome pages.
let kDefaultSelectStyles = {};

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.forms.select.customstyling", true]],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SELECT +=
' <option selected="true">{"end": "true"}</option>' +
"</select></body></html>";

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.forms.selectSearch", true]],
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async function testWindowElementFocus(isPopup) {
BrowserTestUtils.removeTab(tab);
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["dom.disable_open_during_load", false], // Allow window.focus calls without user interaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function testWindowOpen(iframeID) {
BrowserTestUtils.removeTab(tab);
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["dom.disable_open_during_load", false], // Allow window.open calls without user interaction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ var checkInfobarButton = async function(aNotification) {
await promiseNextTick();
};

add_task(async function setup() {
add_setup(async function() {
const isFirstRun = Preferences.get(PREF_FIRST_RUN, true);
const bypassNotification = Preferences.get(PREF_BYPASS_NOTIFICATION, true);
const currentPolicyVersion = Preferences.get(PREF_CURRENT_POLICY_VERSION, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function openAboutPrefPromise(win) {
];
return Promise.all(promises);
}
add_task(async function setup() {
add_setup(async function() {
let win = await BrowserTestUtils.openNewBrowserWindow();
// Open a new tab to keep the window open.
await BrowserTestUtils.openNewForegroundTab(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function waitForNewWindow() {
});
}

add_task(async function setup() {
add_setup(async function() {
let tmpDir = PathUtils.join(
PathUtils.tempDir,
"testsavedir" + Math.floor(Math.random() * 2 ** 32)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function withNewBlankTab(taskFn) {

const BOOKMARKS_COUNT = 100;

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["browser.toolbars.keyboard_navigation", true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function testPermListHasEntries(expectEntries) {
ok(!listEntryCount, "List of permissions is empty");
}

add_task(async function setup() {
add_setup(async function() {
registerCleanupFunction(() => {
Services.perms.removeAll();
Services.prefs.clearUserPref(AUTOPLAY_PREF);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ async function checkGeolocation(browser, frameId, expect) {
}
}

add_task(async function setup() {
add_setup(async function() {
await new Promise(r => {
SpecialPowers.pushPrefEnv(
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async function check(contentTask, options = {}) {
}
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["media.navigator.permission.fake", true],
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/popups/browser_popup_blocker.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function clearAllPermissionsByPrefix(aPrefix) {
}
}

add_task(async function setup() {
add_setup(async function() {
// Enable the popup blocker.
await SpecialPowers.pushPrefEnv({
set: [["dom.disable_open_during_load", true]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const { CustomizableUITestUtils } = ChromeUtils.import(
"resource://testing-common/CustomizableUITestUtils.jsm"
);

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
// Set the auto hide timing to 100ms for blocking the test less.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const CONTAINER_PAGE =

const TPC_PREF = "network.cookie.cookieBehavior";

add_task(async function setup() {
add_setup(async function() {
await UrlClassifierTestUtils.addTestTrackers();

registerCleanupFunction(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TRACKING_PAGE =
const CM_PROTECTION_PREF = "privacy.trackingprotection.cryptomining.enabled";
let cmHistogram;

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const TRACKING_PAGE =
const FP_PROTECTION_PREF = "privacy.trackingprotection.fingerprinting.enabled";
let fpHistogram;

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
// Hide protections cards so as not to trigger more async messaging
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function waitAndAssertPreferencesShown(_spotlight) {
BrowserTestUtils.removeTab(gBrowser.selectedTab);
}

add_task(async function setup() {
add_setup(async function() {
await UrlClassifierTestUtils.addTestTrackers();
let oldCanRecord = Services.telemetry.canRecordExtended;
Services.telemetry.canRecordExtended = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ let { Preferences } = ChromeUtils.import(
"resource://gre/modules/Preferences.jsm"
);

add_task(async function setup() {
add_setup(async function() {
await UrlClassifierTestUtils.addTestTrackers();

registerCleanupFunction(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const TEST_CASES = [
},
];

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
// By default, proxies don't apply to 127.0.0.1. We need them to for this test, though:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const TRACKING_PAGE =
const ST_PROTECTION_PREF = "privacy.trackingprotection.socialtracking.enabled";
const ST_BLOCK_COOKIES_PREF = "privacy.socialtracking.block_cookies.enabled";

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
[ST_BLOCK_COOKIES_PREF, true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
const TRACKING_PAGE =
"http://example.net/browser/browser/base/content/test/protectionsUI/trackingPage.html";

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["privacy.trackingprotection.enabled", true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function getShieldCounts() {
return getShieldHistogram().snapshot().values;
}

add_task(async function setup() {
add_setup(async function() {
await UrlClassifierTestUtils.addTestTrackers();
Services.prefs.setBoolPref(DTSCBN_PREF, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const TRACKING_PAGE =

const TP_PREF = "privacy.trackingprotection.enabled";

add_task(async function setup() {
add_setup(async function() {
await UrlClassifierTestUtils.addTestTrackers();

registerCleanupFunction(() => {
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/sidebar/browser_sidebar_adopt.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function failIfSidebarFocusedFires() {
ok(false, "This event shouldn't have fired");
}

add_task(function setup() {
add_setup(function() {
CustomizableUI.addWidgetToArea("sidebar-button", "nav-bar");
registerCleanupFunction(() =>
CustomizableUI.removeWidgetFromArea("sidebar-button")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const HTTPS_TEST_ROOT_2 = getRootDirectory(gTestPath).replace(
"https://test2.example.com"
);

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({ set: [[PREF_ACTIVE, true]] });
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ const fxaDevices = [
{ id: 4, name: "Homer" }, // Incompatible target.
];

add_task(async function setup() {
add_setup(async function() {
await promiseSyncReady();
await Services.search.init();
// gSync.init() is called in a requestIdleCallback. Force its initialization.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ function updateTabContextMenu(tab = gBrowser.selectedTab) {
menu.hidePopup();
}

add_task(async function setup() {
add_setup(async function() {
await promiseSyncReady();
await Services.search.init();
// gSync.init() is called in a requestIdleCallback. Force its initialization.
Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/sync/browser_sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { CustomizableUITestUtils } = ChromeUtils.import(

let gCUITestUtils = new CustomizableUITestUtils(window);

add_task(async function setup() {
add_setup(async function() {
// gSync.init() is called in a requestIdleCallback. Force its initialization.
gSync.init();
// This preference gets set the very first time that the FxA menu gets opened,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function getTestDirectory() {
return tmpDir.path;
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
// Allow using our MockFilePicker in the content process.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ async function checkDialog(
});
}

add_task(async function setup() {
add_setup(async function() {
await SpecialPowers.pushPrefEnv({
set: [
["prompts.contentPromptSubDialog", true],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const PAGE =
"data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page.";

add_task(async function setup() {
add_setup(async function() {
await setupLocalCrashReportServer();
});

Expand Down
2 changes: 1 addition & 1 deletion browser/base/content/test/tabcrashed/browser_shown.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const COMMENTS = "Here's my test comment!";
// Avoid timeouts, as in bug 1325530
requestLongerTimeout(2);

add_task(async function setup() {
add_setup(async function() {
await setupLocalCrashReportServer();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const PAGE =
"data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page.";

add_task(async function setup() {
add_setup(async function() {
prepareNoDump();
});

Expand Down
Loading

0 comments on commit 8e67201

Please sign in to comment.