Bug 1907588 - In tests, only startup the Addon Manager when necessary, now that the search service doesn't require it all the time. r=search-reviewers,home-newtab-reviewers,jteow

We no longer need to start the add-on manager before the search service starts, so init it only when it is needed for installing add-ons.

Differential Revision: https://phabricator.services.mozilla.com/D216406
This commit is contained in:
Mark Banner 2024-07-17 11:20:20 +00:00
Родитель cbf2fd8b7b
Коммит 771e962b68
92 изменённых файлов: 105 добавлений и 324 удалений

Просмотреть файл

@ -26,13 +26,6 @@ const { DiscoveryStreamFeed } = ChromeUtils.importESModule(
);
SearchTestUtils.init(this);
AddonTestUtils.init(this);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"42",
"42"
);
const { AboutNewTab } = ChromeUtils.importESModule(
"resource:///modules/AboutNewTab.sys.mjs"
@ -61,7 +54,7 @@ add_setup(async function () {
do_get_profile();
// The SearchService is also needed in order to construct the initial state,
// which means that the AddonManager needs to be available.
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.initXPCShellAddonManager();
// The example.com domain will be used to host the dynamic layout JSON and
// the top stories JSON.

Просмотреть файл

@ -11,7 +11,6 @@ import {
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
BrowserTestUtils: "resource://testing-common/BrowserTestUtils.sys.mjs",
BrowserUIUtils: "resource:///modules/BrowserUIUtils.sys.mjs",
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
@ -1241,16 +1240,6 @@ export var UrlbarTestUtils = {
Cc["@mozilla.org/satchel/form-history-startup;1"]
.getService(Ci.nsIObserver)
.observe(null, "profile-after-change", null);
// This is necessary because UrlbarMuxerUnifiedComplete.sort calls
// Services.search.parseSubmissionURL, so we need engines.
try {
await lazy.AddonTestUtils.promiseStartupManager();
} catch (error) {
if (!error.message.includes("already started")) {
throw error;
}
}
},
/**

Просмотреть файл

@ -8,9 +8,18 @@
ChromeUtils.defineESModuleGetters(this, {
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
ExtensionTestCommon: "resource://testing-common/ExtensionTestCommon.sys.mjs",
});
AddonTestUtils.init(this, false);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"42",
"42"
);
// TODO: Firefox no longer uses `rating` and `number_of_ratings` but they are
// still present in Merino and RS suggestions, so they are included here for
// greater accuracy. We should remove them from Merino, RS, and tests.
@ -85,6 +94,8 @@ const REMOTE_SETTINGS_RESULTS = [
];
add_setup(async function init() {
await AddonTestUtils.promiseStartupManager();
// Disable search suggestions so we don't hit the network.
Services.prefs.setBoolPref("browser.search.suggest.enabled", false);

Просмотреть файл

@ -9,6 +9,18 @@
"use strict";
ChromeUtils.defineESModuleGetters(this, {
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
});
AddonTestUtils.init(this, false);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"42",
"42"
);
const { DEFAULT_SUGGESTION_SCORE } = UrlbarProviderQuickSuggest;
const REMOTE_SETTINGS_RECORDS = [
@ -131,6 +143,8 @@ const MERINO_UNKNOWN_SUGGESTION = {
};
add_setup(async function init() {
await AddonTestUtils.promiseStartupManager();
// Disable search suggestions so we don't hit the network.
Services.prefs.setBoolPref("browser.search.suggest.enabled", false);

Просмотреть файл

@ -12,7 +12,6 @@ var { UrlbarMuxer, UrlbarProvider, UrlbarQueryContext, UrlbarUtils } =
ChromeUtils.importESModule("resource:///modules/UrlbarUtils.sys.mjs");
ChromeUtils.defineESModuleGetters(this, {
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
HttpServer: "resource://testing-common/httpd.sys.mjs",
PlacesTestUtils: "resource://testing-common/PlacesTestUtils.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
@ -58,14 +57,10 @@ ChromeUtils.defineLazyGetter(this, "PlacesFrecencyRecalculator", () => {
).wrappedJSObject;
});
// Most tests need a profile to be setup, so do that here.
do_get_profile();
SearchTestUtils.init(this);
AddonTestUtils.init(this, false);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"42",
"42"
);
const SUGGESTIONS_ENGINE_NAME = "Suggestions";
const TAIL_SUGGESTIONS_ENGINE_NAME = "Tail Suggestions";

Просмотреть файл

@ -7,7 +7,6 @@ var { XPCOMUtils } = ChromeUtils.importESModule(
);
ChromeUtils.defineESModuleGetters(this, {
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
HttpServer: "resource://testing-common/httpd.sys.mjs",
NetUtil: "resource://gre/modules/NetUtil.sys.mjs",
SearchTestUtils: "resource://testing-common/SearchTestUtils.sys.mjs",
@ -59,17 +58,7 @@ const CONFIG_V2 = [
async function setupSearchService() {
SearchTestUtils.init(this);
AddonTestUtils.init(this);
AddonTestUtils.overrideCertDB();
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"1",
"42"
);
await SearchTestUtils.useTestEngines(".", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
}

Просмотреть файл

@ -4,7 +4,6 @@ import { NON_SPLIT_ENGINE_IDS } from "resource://gre/modules/SearchService.sys.m
const lazy = {};
ChromeUtils.defineESModuleGetters(lazy, {
AddonManager: "resource://gre/modules/AddonManager.sys.mjs",
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
ExtensionTestUtils:
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs",
@ -24,17 +23,25 @@ class _SearchTestUtils {
*/
#testScope = null;
/**
* True if we are in a mochitest scope, false for xpcshell-tests.
*
* @type {boolean?}
*/
#isMochitest = null;
/**
* Initialises the test utils, setting up the scope and working out if these
* are mochitest or xpcshell-test.
*
* @param {object} testScope
* The global scope for the test.
*/
init(testScope) {
this.#testScope = testScope;
this._isMochitest = !Services.env.exists("XPCSHELL_TEST_PROFILE_DIR");
if (this._isMochitest) {
this._isMochitest = true;
this.#isMochitest = !Services.env.exists("XPCSHELL_TEST_PROFILE_DIR");
if (this.#isMochitest) {
lazy.AddonTestUtils.initMochitest(testScope);
} else {
this._isMochitest = false;
// This handles xpcshell-tests.
this.#testScope.ExtensionTestUtils = lazy.ExtensionTestUtils;
this.initXPCShellAddonManager(testScope);
}
}
@ -229,29 +236,26 @@ class _SearchTestUtils {
}
/**
* Provides various setup for xpcshell-tests installing WebExtensions. Should
* be called from the global scope of the test.
*
* @param {object} scope
* The global scope of the test being run.
* @param {*} usePrivilegedSignatures
* How to sign created addons.
* Sets up the add-on manager so that it is ready for loading WebExtension
* in xpcshell-tests.
*/
initXPCShellAddonManager(scope, usePrivilegedSignatures = false) {
let scopes =
lazy.AddonManager.SCOPE_PROFILE | lazy.AddonManager.SCOPE_APPLICATION;
Services.prefs.setIntPref("extensions.enabledScopes", scopes);
// Only do this once.
try {
this.#testScope.ExtensionTestUtils.init(scope);
} catch (ex) {
// This can happen if init is called twice.
if (ex.result != Cr.NS_ERROR_FILE_ALREADY_EXISTS) {
throw ex;
}
async initXPCShellAddonManager() {
this.#testScope.ExtensionTestUtils = lazy.ExtensionTestUtils;
if (
lazy.ExtensionTestUtils.addonManagerStarted ||
lazy.AddonTestUtils.addonIntegrationService
) {
// We have already started the add-on manager, and the following functions
// may throw if they are called twice.
return;
}
lazy.AddonTestUtils.usePrivilegedSignatures = usePrivilegedSignatures;
lazy.ExtensionTestUtils.init(this.#testScope);
lazy.AddonTestUtils.overrideCertDB();
lazy.AddonTestUtils.init(this.#testScope, false);
await lazy.ExtensionTestUtils.startAddonManager();
}
/**
@ -292,6 +296,10 @@ class _SearchTestUtils {
} = {},
files = {}
) {
if (!this.#isMochitest) {
await this.initXPCShellAddonManager();
}
await Services.search.init();
let extensionInfo = {
@ -323,7 +331,7 @@ class _SearchTestUtils {
// Cleanup must be registered before loading the extension to avoid
// failures for mochitests.
if (!skipUnload && this._isMochitest) {
if (!skipUnload && this.#isMochitest) {
this.#testScope.registerCleanupFunction(cleanup);
}
@ -347,7 +355,7 @@ class _SearchTestUtils {
// For xpcshell-tests we must register the unload after adding the extension.
// See bug 1694409 for why this is.
if (!skipUnload && !this._isMochitest) {
if (!skipUnload && !this.#isMochitest) {
this.#testScope.registerCleanupFunction(cleanup);
}
@ -367,6 +375,9 @@ class _SearchTestUtils {
* The display name to use for the WebExtension.
* @param {string} [options.version]
* The version to use for the WebExtension.
* @param {boolean} [options.is_default]
* Whether or not to ask for the search engine in the WebExtension to be
* attempted to set as default.
* @param {string} [options.favicon_url]
* The favicon to use for the search engine in the WebExtension.
* @param {string} [options.keyword]
@ -403,6 +414,7 @@ class _SearchTestUtils {
chrome_settings_overrides: {
search_provider: {
name: options.name,
is_default: !!options.is_default,
search_url: options.search_url ?? "https://example.com/",
},
},

Просмотреть файл

@ -1,12 +1,12 @@
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et: */
const { XPCOMUtils } = ChromeUtils.importESModule(
"resource://gre/modules/XPCOMUtils.sys.mjs"
);
ChromeUtils.defineESModuleGetters(this, {
AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs",
ExtensionTestUtils:
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs",
FileUtils: "resource://gre/modules/FileUtils.sys.mjs",
HttpServer: "resource://testing-common/httpd.sys.mjs",
Region: "resource://gre/modules/Region.sys.mjs",
RemoteSettings: "resource://services-settings/remote-settings.sys.mjs",
RemoteSettingsClient:
@ -18,40 +18,27 @@ ChromeUtils.defineESModuleGetters(this, {
SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs",
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
clearTimeout: "resource://gre/modules/Timer.sys.mjs",
updateAppInfo: "resource://testing-common/AppInfo.sys.mjs",
setTimeout: "resource://gre/modules/Timer.sys.mjs",
sinon: "resource://testing-common/Sinon.sys.mjs",
});
var { HttpServer } = ChromeUtils.importESModule(
"resource://testing-common/httpd.sys.mjs"
);
var { AddonTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/AddonTestUtils.sys.mjs"
);
const { ExtensionTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs"
);
// We need Services.appinfo.name set up to allow the hashes to work with a
// consistent name.
// Note: the name and versions here match those in ExtensionXPCShellUtils.sys.mjs.
updateAppInfo({ name: "XPCShell", version: "48", platformVersion: "48" });
// We generally also need a profile set-up, for saving search settings etc.
do_get_profile();
SearchTestUtils.init(this);
const SETTINGS_FILENAME = "search.json.mozlz4";
// nsSearchService.js uses Services.appinfo.name to build a salt for a hash.
// eslint-disable-next-line mozilla/use-services
var XULRuntime = Cc["@mozilla.org/xre/runtime;1"].getService(Ci.nsIXULRuntime);
// Expand the amount of information available in error logs
Services.prefs.setBoolPref("browser.search.log", true);
Services.prefs.setBoolPref("browser.region.log", true);
AddonTestUtils.init(this, false);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"XPCShell",
"42",
"42"
);
// Allow telemetry probes which may otherwise be disabled for some applications (e.g. Thunderbird)
Services.prefs.setBoolPref(
"toolkit.telemetry.testing.overrideProductsCheck",

Просмотреть файл

@ -9,7 +9,6 @@
add_setup(async function () {
Region._setHomeRegion("an", false);
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("test-extensions");
});

Просмотреть файл

@ -2,7 +2,6 @@
http://creativecommons.org/publicdomain/zero/1.0/ */
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("simple-engines");
Services.fog.initializeFOG();
});

Просмотреть файл

@ -3,7 +3,6 @@
add_setup(async function () {
await SearchTestUtils.useTestEngines("method-extensions");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -16,7 +16,6 @@ add_setup(async () => {
Services.fog.initializeFOG();
useHttpServer();
await AddonTestUtils.promiseStartupManager();
await Services.search.init();

Просмотреть файл

@ -47,8 +47,6 @@ add_setup(async () => {
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
let promiseSaved = promiseSaveSettingsData();
await Services.search.init();
await promiseSaved;

Просмотреть файл

@ -45,8 +45,6 @@ add_setup(async function () {
"engine-reordered@search.mozilla.org",
]);
await AddonTestUtils.promiseStartupManager();
appDefault = await Services.search.getDefault();
appPrivateDefault = await Services.search.getDefaultPrivate();
});

Просмотреть файл

@ -30,7 +30,6 @@ add_setup(async () => {
);
useHttpServer("opensearch");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();

Просмотреть файл

@ -4,7 +4,6 @@
const NAME = "Test Alias Engine";
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
let settingsFileWritten = promiseAfterSettings();
await Services.search.init();
await settingsFileWritten;

Просмотреть файл

@ -57,7 +57,6 @@ const CONFIG_V2 = [
add_setup(async function () {
useHttpServer("opensearch");
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -4,7 +4,6 @@
const NAME = "Test Alias Engine";
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -2,7 +2,6 @@
add_setup(async function () {
useHttpServer();
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -7,7 +7,6 @@ const prefix = "https://example.com/?sourceId=Mozilla-search&search=";
add_setup(async function () {
await SearchTestUtils.useTestEngines("simple-engines");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -5,7 +5,6 @@
add_setup(async function () {
await SearchTestUtils.useTestEngines("simple-engines");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -35,7 +35,6 @@ add_task(async function test_pref_initial_value() {
);
}
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
const engine = Services.search.getEngineByName("engine-pref");

Просмотреть файл

@ -38,7 +38,6 @@ add_task(async function test_pref_initial_value() {
},
]);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
Assert.ok(

Просмотреть файл

@ -35,7 +35,6 @@ add_setup(async function () {
add_task(async function test_bad_nimbus_setting_on_init() {
getVariableStub.withArgs("extraParams").returns({ foo: "bar" });
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
Assert.ok(

Просмотреть файл

@ -12,8 +12,6 @@ add_setup(async function () {
// The test engines used in this test need to be recognized as 'default'
// engines, or their MozParams used to set the purpose will be ignored.
await SearchTestUtils.useTestEngines();
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -9,7 +9,6 @@
add_setup(async function () {
await SearchTestUtils.useTestEngines("simple-engines");
await AddonTestUtils.promiseStartupManager();
const result = await Services.search.init();
Assert.ok(

Просмотреть файл

@ -12,11 +12,6 @@ const kSearchEngineURL2 =
"https://example.com/?search={searchTerms}&IGNORE=TRUE";
const kSearchEngineURL3 = "https://example.com/?search={searchTerms}";
const kExtensionID = "searchignore@mozilla.com";
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_ignoreList() {
await setupRemoteSettings();

Просмотреть файл

@ -13,10 +13,6 @@ const kSearchEngineURL2 =
const kSearchEngineURL3 = "https://example.com/?search={searchTerms}";
const kExtensionID = "searchignore@mozilla.com";
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_ignoreList() {
Assert.ok(
!Services.search.isInitialized,

Просмотреть файл

@ -1,87 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
// Tests that a delayed add-on manager start up does not affect the start up
// of the search service.
"use strict";
const CONFIG_V2 = [
{
recordType: "engine",
identifier: "engine",
base: {
name: "Test search engine",
urls: {
search: {
base: "https://www.google.com/search",
params: [
{
name: "channel",
searchAccessPoint: {
addressbar: "fflb",
contextmenu: "rcs",
},
},
],
searchTermParamName: "q",
},
suggestions: {
base: "https://suggestqueries.google.com/complete/search?output=firefox&client=firefox",
searchTermParamName: "q",
},
},
},
variants: [
{
environment: { allRegionsAndLocales: true },
},
],
},
{
recordType: "defaultEngines",
globalDefault: "engine",
specificDefaults: [],
},
{
recordType: "engineOrders",
orders: [],
},
];
add_setup(() => {
do_get_profile();
Services.fog.initializeFOG();
});
add_task(async function test_initialization_delayed_addon_manager() {
let stub = await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
// Wait until the search service gets its configuration before starting
// to initialise the add-on manager. This simulates the add-on manager
// starting late which used to cause the search service to fail to load any
// engines.
stub.callsFake(() => {
Services.tm.dispatchToMainThread(() => {
AddonTestUtils.promiseStartupManager();
});
return CONFIG_V2;
});
await Services.search.init();
Assert.equal(
Services.search.defaultEngine.name,
"Test search engine",
"Test engine shouldn't be the default anymore"
);
await assertGleanDefaultEngine({
normal: {
engineId: "engine",
displayName: "Test search engine",
loadPath: ["[app]engine@search.mozilla.org"],
submissionUrl: "https://www.google.com/search?q=",
verified: "default",
},
});
});

Просмотреть файл

@ -10,7 +10,6 @@ const searchService = Services.search.wrappedJSObject;
add_setup(async () => {
consoleAllowList.push("#init: failure initializing search:");
await SearchTestUtils.useTestEngines("simple-engines");
await AddonTestUtils.promiseStartupManager();
Services.fog.initializeFOG();
});

Просмотреть файл

@ -116,7 +116,6 @@ add_setup(async function () {
SearchTestUtils.useMockIdleService();
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
});
// This tests what we expect is the normal startup route for a fresh profile -

Просмотреть файл

@ -28,7 +28,6 @@ add_setup(async function () {
add_task(async function test_listJSONlocale() {
Services.locale.requestedLocales = ["de"];
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
Assert.ok(Services.search.isInitialized, "search initialized");

Просмотреть файл

@ -21,7 +21,6 @@ add_task(async function test_searchDefaultEngineUS() {
);
Services.prefs.setCharPref(SearchUtils.BROWSER_SEARCH_PREF + "region", "US");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
Assert.ok(Services.search.isInitialized, "search initialized");

Просмотреть файл

@ -16,7 +16,6 @@ add_task(async function test_searchDefaultEngineUS() {
Services.prefs.setCharPref(SearchUtils.BROWSER_SEARCH_PREF + "region", "US");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
Assert.ok(Services.search.isInitialized, "search initialized");

Просмотреть файл

@ -6,8 +6,6 @@
"use strict";
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
Services.prefs.setBoolPref(
SearchUtils.BROWSER_SEARCH_PREF + "separatePrivateDefault.ui.enabled",
true

Просмотреть файл

@ -29,10 +29,6 @@ function verifyProbeSum(probe, sum) {
equal(snapshot.sum, sum, probe);
}
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_location_timeout_xhr() {
let resolveContinuePromise;
let continuePromise = new Promise(resolve => {

Просмотреть файл

@ -9,9 +9,6 @@
add_setup(async function () {
await SearchTestUtils.useTestEngines("test-extensions");
await AddonTestUtils.promiseStartupManager();
registerCleanupFunction(AddonTestUtils.promiseShutdownManager);
});
add_task(async function basic_multilocale_test() {

Просмотреть файл

@ -7,7 +7,6 @@ const kExtensionID = "simple@tests.mozilla.org";
add_setup(async function () {
useHttpServer("opensearch");
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("data1");
await Services.search.init();
});

Просмотреть файл

@ -18,7 +18,6 @@
add_setup(async function () {
useHttpServer();
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_nodb_pluschanges() {

Просмотреть файл

@ -7,7 +7,6 @@ let engine;
let appDefaultEngine;
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
useHttpServer();
Services.prefs.setBoolPref(

Просмотреть файл

@ -55,7 +55,6 @@ const tests = [
add_setup(async function () {
Services.fog.initializeFOG();
useHttpServer("opensearch");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -6,7 +6,6 @@
add_setup(async function () {
let server = useHttpServer();
server.registerContentType("sjs", "sjs");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -8,7 +8,6 @@
add_setup(async function () {
let server = useHttpServer("");
server.registerContentType("sjs", "sjs");
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_installedresourceicon() {

Просмотреть файл

@ -7,7 +7,7 @@
add_setup(async function () {
useHttpServer("opensearch");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
// This test purposely attempts to load an invalid engine.

Просмотреть файл

@ -7,8 +7,6 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);
const { promiseStartupManager, promiseShutdownManager } = AddonTestUtils;
const openSearchEngineFiles = [
"secure-and-securely-updated1.xml",
"secure-and-securely-updated2.xml",
@ -42,16 +40,11 @@ async function verifyTelemetry(probeNameFragment, engineCount, type) {
add_setup(async function () {
useHttpServer("opensearch");
await promiseStartupManager();
await Services.search.init();
for (let file of openSearchEngineFiles) {
await SearchTestUtils.installOpenSearchEngine({ url: gDataUrl + file });
}
registerCleanupFunction(async () => {
await promiseShutdownManager();
});
});
add_task(async function () {

Просмотреть файл

@ -11,7 +11,6 @@ let timerManager;
add_setup(async function () {
let server = useHttpServer("");
server.registerContentType("sjs", "sjs");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
timerManager = Cc["@mozilla.org/updates/timer-manager;1"].getService(

Просмотреть файл

@ -227,7 +227,7 @@ let remoteSettingsStub;
add_setup(async function () {
await SearchTestUtils.useTestEngines("simple-engines");
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.initXPCShellAddonManager();
await Services.search.init();
baseExtension = ExtensionTestUtils.loadExtension({

Просмотреть файл

@ -168,7 +168,6 @@ add_setup(async function () {
];
Services.locale.requestedLocales = ["en"];
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
const settings = await RemoteSettings(SearchUtils.SETTINGS_ALLOWLIST_KEY);

Просмотреть файл

@ -33,7 +33,7 @@ let extensionInfo;
add_setup(async function () {
await SearchTestUtils.useTestEngines("simple-engines");
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.initXPCShellAddonManager();
await Services.search.init();
extensionInfo = {

Просмотреть файл

@ -9,7 +9,6 @@
add_task(async function setup() {
useHttpServer();
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_parseSubmissionURL() {

Просмотреть файл

@ -41,7 +41,6 @@ add_setup(async function () {
policies.observe(null, "policies-startup", null);
Services.fog.initializeFOG();
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines();
SearchUtils.GENERAL_SEARCH_ENGINE_IDS = new Set([

Просмотреть файл

@ -270,7 +270,6 @@ add_setup(async function () {
SearchTestUtils.useMockIdleService();
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
});
// This is to verify that the loaded configuration matches what we expect for

Просмотреть файл

@ -72,7 +72,6 @@ add_setup(async () => {
Region._setHomeRegion("US", false);
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -80,7 +80,6 @@ const CONFIG_V2 = [
add_setup(async function () {
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
});
// This is to verify that the loaded configuration matches what we expect for

Просмотреть файл

@ -96,7 +96,6 @@ add_setup(async () => {
Services.locale.requestedLocales = ["gd"];
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -105,7 +105,6 @@ add_setup(async function () {
SearchSettings.SETTINGS_INVALIDATION_DELAY = 100;
SearchTestUtils.useMockIdleService();
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
stub = sinon.stub(
await Services.search.wrappedJSObject,

Просмотреть файл

@ -6,7 +6,6 @@
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
});
add_task(async function run_test() {

Просмотреть файл

@ -15,7 +15,6 @@
add_setup(async function () {
useHttpServer();
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_save_sorted_engines() {

Просмотреть файл

@ -45,8 +45,6 @@ add_setup(async function () {
let server = useHttpServer();
server.registerContentType("sjs", "sjs");
await AddonTestUtils.promiseStartupManager();
let getEngineData = {
baseURL: gDataUrl,
name: "GET suggestion engine",

Просмотреть файл

@ -60,8 +60,6 @@ function countCookieEntries() {
let engines;
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
Services.prefs.setBoolPref("browser.search.suggest.enabled", true);
Services.prefs.setBoolPref("browser.search.suggest.enabled.private", true);

Просмотреть файл

@ -57,7 +57,6 @@ add_setup(async function () {
null,
TEST_CONFIG_V2
);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -20,8 +20,6 @@ add_setup(async function () {
let server = useHttpServer();
server.registerContentType("sjs", "sjs");
await AddonTestUtils.promiseStartupManager();
const engineData = {
baseURL: gDataUrl,
name: "GET suggestion engine",

Просмотреть файл

@ -62,7 +62,6 @@ const TERM_ENCODED = "c%3B%2C%3F%3A%40%26%3D%2B%24-_.!~*'()%23+d%C3%A8f";
add_setup(async function () {
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
defaultEngine = Services.search.getEngineByName("Test Engine With Purposes");

Просмотреть файл

@ -9,7 +9,6 @@
add_setup(async function () {
await SearchTestUtils.useTestEngines("data", null);
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_resultDomain() {

Просмотреть файл

@ -5,7 +5,6 @@ const kDefaultEngineName = "engine1";
add_setup(async function () {
useHttpServer();
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("data1");
Assert.ok(!Services.search.isInitialized);
Services.prefs.setBoolPref(

Просмотреть файл

@ -33,7 +33,6 @@ const SUBMISSION_NO = [
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
});
async function addAndMakeDefault(name, search_url, search_url_get_params) {

Просмотреть файл

@ -17,7 +17,6 @@ var settingsTemplate;
*/
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -63,8 +63,6 @@ const enginesSettings = {
};
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
// Allow telemetry probes which may otherwise be disabled for some applications (e.g. Thunderbird)
Services.prefs.setBoolPref(
"toolkit.telemetry.testing.overrideProductsCheck",

Просмотреть файл

@ -75,8 +75,6 @@ const enginesSettings = {
};
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
// Allow telemetry probes which may otherwise be disabled for some applications (e.g. Thunderbird)
Services.prefs.setBoolPref(
"toolkit.telemetry.testing.overrideProductsCheck",

Просмотреть файл

@ -44,8 +44,6 @@ const enginesSettings = {
};
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
// Allow telemetry probes which may otherwise be disabled for some applications (e.g. Thunderbird)
Services.prefs.setBoolPref(
"toolkit.telemetry.testing.overrideProductsCheck",

Просмотреть файл

@ -17,8 +17,6 @@ var settingsTemplate;
* Test reading from search.json.mozlz4
*/
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
await setupRemoteSettings();
settingsTemplate = await readJSONFile(

Просмотреть файл

@ -28,7 +28,6 @@ async function loadSettingsFile(settingsFile) {
*/
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -59,7 +59,6 @@ add_setup(async function () {
policies.observe(null, "policies-startup", null);
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
await EnterprisePolicyTesting.setupPolicyEngineWithJson(enterprisePolicy);
// Setting the enterprise policy starts the search service initialising,
// so we wait for that to complete before starting the test.

Просмотреть файл

@ -34,7 +34,6 @@ add_setup(async function () {
policies.observe(null, "policies-startup", null);
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
await EnterprisePolicyTesting.setupPolicyEngineWithJson(enterprisePolicy);
// Setting the enterprise policy starts the search service initialising,
// so we wait for that to complete before starting the test, we can

Просмотреть файл

@ -12,7 +12,6 @@
add_setup(async function () {
useHttpServer();
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_nosettings() {

Просмотреть файл

@ -61,7 +61,6 @@ async function checkLoadSettingProperties(settingsFile, engineName) {
*/
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
await AddonTestUtils.promiseStartupManager();
});
add_task(async function test_obsolete_distribution_engine() {

Просмотреть файл

@ -40,7 +40,6 @@ const SEARCH_CONFIG_V2_UPDATED = [
async function startup() {
let settingsFileWritten = promiseAfterSettings();
let ss = new SearchService();
await AddonTestUtils.promiseRestartManager();
await ss.init(false);
await settingsFileWritten;
return ss;
@ -61,8 +60,6 @@ async function visibleEngines(ss) {
add_setup(async function () {
await SearchTestUtils.useTestEngines("test-extensions");
registerCleanupFunction(AddonTestUtils.promiseShutdownManager);
await AddonTestUtils.promiseStartupManager();
// This is only needed as otherwise events will not be properly notified
// due to https://searchfox.org/mozilla-central/rev/5f0a7ca8968ac5cef8846e1d970ef178b8b76dcc/toolkit/components/search/SearchSettings.sys.mjs#41-42
let settingsFileWritten = promiseAfterSettings();

Просмотреть файл

@ -9,8 +9,6 @@
"use strict";
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines(
"data",
null,

Просмотреть файл

@ -20,8 +20,6 @@ const EXPECTED_ORDER = [
];
add_setup(async function () {
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines();
Services.locale.availableLocales = [

Просмотреть файл

@ -367,7 +367,6 @@ add_setup(async () => {
);
await SearchTestUtils.useTestEngines("data", null, BASE_CONFIG_V2);
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -9,7 +9,6 @@
add_setup(async function () {
Services.fog.initializeFOG();
await AddonTestUtils.promiseStartupManager();
await Services.search.init();
});

Просмотреть файл

@ -48,6 +48,5 @@ add_task(async function test_validate_engines() {
});
sinon.stub(settings, "get").returns(config);
await AddonTestUtils.promiseStartupManager();
await ss.init();
});

Просмотреть файл

@ -3,8 +3,6 @@
"use strict";
const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
let gBaseUrl;
async function getEngineNames() {
@ -18,7 +16,6 @@ add_setup(async function () {
gBaseUrl = `http://localhost:${server.identity.primaryPort}/`;
await SearchTestUtils.useTestEngines("test-extensions");
await promiseStartupManager();
Services.locale.availableLocales = [
...Services.locale.availableLocales,
@ -26,7 +23,6 @@ add_setup(async function () {
];
registerCleanupFunction(async () => {
await promiseShutdownManager();
Services.prefs.clearUserPref("browser.search.region");
});
});

Просмотреть файл

@ -3,8 +3,6 @@
"use strict";
const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
add_setup(async function () {
Services.locale.availableLocales = [
...Services.locale.availableLocales,
@ -15,11 +13,8 @@ add_setup(async function () {
Services.locale.requestedLocales = ["en"];
await SearchTestUtils.useTestEngines("data1");
await promiseStartupManager();
await Services.search.init();
await promiseAfterSettings();
registerCleanupFunction(promiseShutdownManager);
});
add_task(async function test_language_switch_changes_name() {

Просмотреть файл

@ -9,7 +9,6 @@
add_setup(async function () {
useHttpServer("opensearch");
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("data1");
let data = await readJSONFile(do_get_file("data/search-migration.json"));

Просмотреть файл

@ -14,19 +14,13 @@ ChromeUtils.defineESModuleGetters(lazy, {
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs",
});
const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
let extension;
add_setup(async function () {
let server = useHttpServer();
server.registerContentType("sjs", "sjs");
await SearchTestUtils.useTestEngines("test-extensions");
await promiseStartupManager();
registerCleanupFunction(async () => {
await promiseShutdownManager();
});
await SearchTestUtils.initXPCShellAddonManager();
});
add_task(async function test_startup_with_new_addon() {

Просмотреть файл

@ -5,8 +5,6 @@
const lazy = {};
const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
ChromeUtils.defineESModuleGetters(lazy, {
ExtensionTestUtils:
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs",
@ -16,11 +14,7 @@ add_setup(async function () {
let server = useHttpServer();
server.registerContentType("sjs", "sjs");
await SearchTestUtils.useTestEngines("test-extensions");
await promiseStartupManager();
registerCleanupFunction(async () => {
await promiseShutdownManager();
});
await SearchTestUtils.initXPCShellAddonManager();
});
add_task(async function test_install_duplicate_engine_startup() {

Просмотреть файл

@ -7,8 +7,17 @@ const ENGINE_ID = "enginetest@example.com";
let xpi;
let profile = do_get_profile().clone();
AddonTestUtils.init(this, false);
AddonTestUtils.createAppInfo(
"xpcshell@tests.mozilla.org",
"xpcshell",
"42",
"42"
);
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
xpi = AddonTestUtils.createTempWebExtensionFile({
manifest: {
version: "1.0",
@ -27,9 +36,8 @@ add_setup(async function () {
});
add_task(async function test_removeAddonOnStartup() {
// First startup the add-on manager and ensure the engine is installed.
await AddonTestUtils.promiseStartupManager();
let promise = promiseAfterSettings();
await SearchTestUtils.initXPCShellAddonManager();
await Services.search.init();
let engine = Services.search.getEngineByName("Test Engine");

Просмотреть файл

@ -3,15 +3,10 @@
"use strict";
const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
add_setup(async function () {
await SearchTestUtils.useTestEngines("data1");
await promiseStartupManager();
await Services.search.init();
await promiseAfterSettings();
registerCleanupFunction(promiseShutdownManager);
});
add_task(async function test_basic_upgrade() {

Просмотреть файл

@ -7,15 +7,12 @@ const { TelemetryTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryTestUtils.sys.mjs"
);
const { promiseShutdownManager, promiseStartupManager } = AddonTestUtils;
let extension;
let extensionPostData;
let oldRemoveEngineFunc;
add_setup(async function () {
await SearchTestUtils.useTestEngines("simple-engines");
await promiseStartupManager();
Services.telemetry.canRecordExtended = true;
@ -45,7 +42,7 @@ add_setup(async function () {
Services.search.wrappedJSObject.removeEngine = () => {};
registerCleanupFunction(async () => {
await promiseShutdownManager();
await extensionPostData.unload();
});
});

Просмотреть файл

@ -103,8 +103,6 @@ tags = "remotesettings searchmain"
["test_ignorelist_update.js"]
["test_initialization.js"]
["test_initialization_status_telemetry.js"]
["test_initialization_with_region.js"]

Просмотреть файл

@ -12,7 +12,12 @@ const { TelemetryEnvironmentTesting } = ChromeUtils.importESModule(
"resource://testing-common/TelemetryEnvironmentTesting.sys.mjs"
);
const { ExtensionTestUtils } = ChromeUtils.importESModule(
"resource://testing-common/ExtensionXPCShellUtils.sys.mjs"
);
SearchTestUtils.init(this);
ExtensionTestUtils.init(this);
function promiseNextTick() {
return new Promise(resolve => executeSoon(resolve));