зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1753696 - move common setup/init tasks in head.js files to use add_setup, r=Standard8
Without this, changing to add_setup in individual test files causes the tasks to be reordered, which causes tests to fail. I also had to adjust an enterprise policy test that was expecting setup tests to run inbetween tasks. Differential Revision: https://phabricator.services.mozilla.com/D142457
This commit is contained in:
Родитель
b76ad616d1
Коммит
7298feb0ee
|
@ -648,7 +648,7 @@ async function interactiveUpdateTest(autoUpdate, checkFn) {
|
|||
// Individual tests can store a cleanup function in the testCleanup global
|
||||
// to ensure it gets called before the final check is performed.
|
||||
let testCleanup;
|
||||
add_task(async function() {
|
||||
add_setup(async function head_setup() {
|
||||
let addons = await AddonManager.getAllAddons();
|
||||
let existingAddons = new Set(addons.map(a => a.id));
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ async function addLogin(login) {
|
|||
|
||||
let EXPECTED_BREACH = null;
|
||||
let EXPECTED_ERROR_MESSAGE = null;
|
||||
add_task(async function setup_head() {
|
||||
add_setup(async function setup_head() {
|
||||
const db = await RemoteSettings(LoginBreaches.REMOTE_SETTINGS_COLLECTION).db;
|
||||
if (EXPECTED_BREACH) {
|
||||
await db.create(EXPECTED_BREACH, {
|
||||
|
|
|
@ -81,7 +81,7 @@ function run_test() {
|
|||
run_next_test();
|
||||
}
|
||||
|
||||
add_task(async function test_common_initialize() {
|
||||
add_setup(async function test_common_initialize() {
|
||||
gDownloadDir = await setDownloadDir();
|
||||
Services.prefs.setCharPref("browser.download.loglevel", "Debug");
|
||||
});
|
||||
|
|
|
@ -23,15 +23,12 @@ add_task(async function test_menu_shown() {
|
|||
await BrowserTestUtils.closeWindow(newWin);
|
||||
});
|
||||
|
||||
add_setup(async function() {
|
||||
add_task(async function test_menu_shown() {
|
||||
await setupPolicyEngineWithJson({
|
||||
policies: {
|
||||
SearchBar: "unified",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
add_task(async function test_menu_shown() {
|
||||
let newWin = await BrowserTestUtils.openNewBrowserWindow();
|
||||
let placement = CustomizableUI.getPlacementOfWidget("search-container");
|
||||
is(placement, null, "Search bar has no placement");
|
||||
|
|
|
@ -172,7 +172,7 @@ async function check_homepage({
|
|||
await BrowserTestUtils.removeTab(tab);
|
||||
}
|
||||
|
||||
add_task(async function policies_headjs_startWithCleanSlate() {
|
||||
add_setup(async function policies_headjs_startWithCleanSlate() {
|
||||
if (Services.policies.status != Ci.nsIEnterprisePolicies.INACTIVE) {
|
||||
await setupPolicyEngineWithJson("");
|
||||
}
|
||||
|
|
|
@ -47,12 +47,10 @@ const SEARCH_STRINGS = {
|
|||
UPDATE: "firefox update",
|
||||
};
|
||||
|
||||
add_task(async function init() {
|
||||
registerCleanupFunction(() => {
|
||||
// We need to reset the provider's appUpdater.status between tests so that
|
||||
// each test doesn't interfere with the next.
|
||||
UrlbarProviderInterventions.resetAppUpdater();
|
||||
});
|
||||
registerCleanupFunction(() => {
|
||||
// We need to reset the provider's appUpdater.status between tests so that
|
||||
// each test doesn't interfere with the next.
|
||||
UrlbarProviderInterventions.resetAppUpdater();
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
@ -26,7 +26,7 @@ XPCOMUtils.defineLazyGetter(this, "UrlbarTestUtils", () => {
|
|||
return module;
|
||||
});
|
||||
|
||||
add_task(async function headInit() {
|
||||
add_setup(async function headInit() {
|
||||
await PlacesUtils.history.clear();
|
||||
await PlacesUtils.bookmarks.eraseEverything();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ const SCRIPT_PATH = getTestFilePath(SCRIPT_BASENAME);
|
|||
let schemaSource;
|
||||
let scriptSource;
|
||||
|
||||
add_task(async function loadSource() {
|
||||
add_setup(async function loadSource() {
|
||||
schemaSource = await (await fetch("file://" + SCHEMA_PATH)).text();
|
||||
scriptSource = await (await fetch("file://" + SCRIPT_PATH)).text();
|
||||
});
|
||||
|
|
|
@ -52,7 +52,7 @@ AddonTestUtils.createAppInfo(
|
|||
const SUGGESTIONS_ENGINE_NAME = "Suggestions";
|
||||
const TAIL_SUGGESTIONS_ENGINE_NAME = "Tail Suggestions";
|
||||
|
||||
add_task(async function initXPCShellDependencies() {
|
||||
add_setup(async function initXPCShellDependencies() {
|
||||
await UrlbarTestUtils.initXPCShellDependencies();
|
||||
});
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ function objectMatches(object, fields) {
|
|||
return ObjectUtils.deepEqual(actual, fields);
|
||||
}
|
||||
|
||||
add_task(async function head_initialize() {
|
||||
add_setup(async function head_initialize() {
|
||||
Services.prefs.setBoolPref("extensions.experiments.enabled", true);
|
||||
Services.prefs.setBoolPref(
|
||||
"extensions.formautofill.heuristics.enabled",
|
||||
|
@ -338,7 +338,7 @@ add_task(async function head_initialize() {
|
|||
});
|
||||
|
||||
let OSKeyStoreTestUtils;
|
||||
add_task(async function os_key_store_setup() {
|
||||
add_setup(async function os_key_store_setup() {
|
||||
({ OSKeyStoreTestUtils } = ChromeUtils.import(
|
||||
"resource://testing-common/OSKeyStoreTestUtils.jsm"
|
||||
));
|
||||
|
|
|
@ -214,7 +214,7 @@ async function getImageSizeFromClipboard(browser) {
|
|||
});
|
||||
}
|
||||
|
||||
add_task(async function common_initialize() {
|
||||
add_setup(async function common_initialize() {
|
||||
// Ensure Screenshots is initially enabled for all tests
|
||||
const addon = await AddonManager.getAddonByID("screenshots@mozilla.org");
|
||||
const isEnabled = addon.enabled;
|
||||
|
|
|
@ -64,4 +64,4 @@ function shouldCapture() {
|
|||
return true;
|
||||
}
|
||||
|
||||
add_task(setup);
|
||||
add_setup(setup);
|
||||
|
|
|
@ -56,7 +56,7 @@ ChromeUtils.defineModuleGetter(
|
|||
"resource://gre/modules/AddonManager.jsm"
|
||||
);
|
||||
|
||||
add_task(async function head_setup() {
|
||||
add_setup(async function head_setup() {
|
||||
// Initialize logging. This will sometimes be reset by a pref reset,
|
||||
// so it's also called as part of SyncTestingInfrastructure().
|
||||
syncTestLogging();
|
||||
|
|
|
@ -956,7 +956,7 @@ var gMostRecentFirstBytePos;
|
|||
|
||||
// Initialization functions common to all tests
|
||||
|
||||
add_task(function test_common_initialize() {
|
||||
add_setup(function test_common_initialize() {
|
||||
// Start the HTTP server.
|
||||
gHttpServer = new HttpServer();
|
||||
gHttpServer.registerDirectory("/", do_get_file("../data"));
|
||||
|
|
|
@ -57,7 +57,7 @@ const testEnv = {
|
|||
expectRemote: false,
|
||||
};
|
||||
|
||||
add_task(function check_remote() {
|
||||
add_setup(function check_remote() {
|
||||
Assert.equal(
|
||||
WebExtensionPolicy.useRemoteWebExtensions,
|
||||
testEnv.expectRemote,
|
||||
|
|
|
@ -10,7 +10,7 @@ XPCOMUtils.defineLazyModuleGetters(this, {
|
|||
ExtensionTestCommon: "resource://testing-common/ExtensionTestCommon.jsm",
|
||||
});
|
||||
|
||||
add_task(function checkExtensionsWebIDLEnabled() {
|
||||
add_setup(function checkExtensionsWebIDLEnabled() {
|
||||
equal(
|
||||
AppConstants.MOZ_WEBEXT_WEBIDL_ENABLED,
|
||||
true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/* eslint-env mozilla/frame-script */
|
||||
|
||||
// Enable HTTPS-Only Mode
|
||||
add_task(async function() {
|
||||
add_setup(async function() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["dom.security.https_only_mode", true]],
|
||||
});
|
||||
|
|
|
@ -19,7 +19,7 @@ const { PromptTestUtils } = ChromeUtils.import(
|
|||
"resource://testing-common/PromptTestUtils.jsm"
|
||||
);
|
||||
|
||||
add_task(async function common_initialize() {
|
||||
add_setup(async function common_initialize() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["signon.rememberSignons", true],
|
||||
|
|
|
@ -80,7 +80,7 @@ const RecipeHelpers = {
|
|||
|
||||
// Initialization functions common to all tests
|
||||
|
||||
add_task(async function test_common_initialize() {
|
||||
add_setup(async function test_common_initialize() {
|
||||
// Before initializing the service for the first time, we should copy the key
|
||||
// file required to decrypt the logins contained in the SQLite databases used
|
||||
// by migration tests. This file is not required for the other tests.
|
||||
|
@ -100,7 +100,7 @@ add_task(async function test_common_initialize() {
|
|||
}
|
||||
});
|
||||
|
||||
add_task(async function test_common_prefs() {
|
||||
add_setup(async function test_common_prefs() {
|
||||
Services.prefs.setStringPref(NEW_PASSWORD_HEURISTIC_ENABLED_PREF, "0.75");
|
||||
});
|
||||
|
||||
|
|
|
@ -27,6 +27,6 @@ AddonTestUtils.createAppInfo(
|
|||
"42"
|
||||
);
|
||||
|
||||
add_task(async function setup() {
|
||||
add_setup(async function() {
|
||||
await AddonTestUtils.promiseStartupManager();
|
||||
});
|
||||
|
|
|
@ -65,7 +65,7 @@ requestLongerTimeout(10);
|
|||
/**
|
||||
* Common tasks to perform for all tests before each one has started.
|
||||
*/
|
||||
add_task(async function setupTestCommon() {
|
||||
add_setup(async function setupTestCommon() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
[PREF_APP_UPDATE_BADGEWAITTIME, 1800],
|
||||
|
|
|
@ -299,7 +299,7 @@ async function setDownloadDir() {
|
|||
return tmpDir;
|
||||
}
|
||||
|
||||
add_task(async function test_common_initialize() {
|
||||
add_setup(async function test_common_initialize() {
|
||||
gDownloadDir = await setDownloadDir();
|
||||
Services.prefs.setCharPref("browser.download.loglevel", "Debug");
|
||||
registerCleanupFunction(function() {
|
||||
|
|
Загрузка…
Ссылка в новой задаче