Bug 1911981 - Replace use of SearchTestUtils.useTestEngines with setRemoteSettingsConfig in non-search test code. r=mbeier,backup-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D219894
This commit is contained in:
Mark Banner 2024-08-27 16:01:45 +00:00
parent 4bb11c45f9
commit 431635ac9a
10 changed files with 39 additions and 226 deletions

View File

@ -1,101 +0,0 @@
{
"data": [
{
"base": {
"name": "engine1",
"urls": {
"search": {
"base": "https://1.example.com/search",
"searchTermParamName": "q"
}
},
"classification": "general"
},
"variants": [{ "environment": { "allRegionsAndLocales": true } }],
"identifier": "engine1",
"recordType": "engine"
},
{
"base": {
"name": "engine2",
"urls": {
"search": {
"base": "https://2.example.com/search",
"searchTermParamName": "q"
}
},
"classification": "general"
},
"variants": [{ "environment": { "allRegionsAndLocales": true } }],
"identifier": "engine2",
"recordType": "engine"
},
{
"base": {
"name": "exp2",
"urls": {
"search": {
"base": "https://2.example.com/searchexp",
"searchTermParamName": "q"
}
},
"classification": "general"
},
"variants": [
{
"environment": { "allRegionsAndLocales": true, "experiment": "exp2" }
}
],
"identifier": "exp2",
"recordType": "engine"
},
{
"base": {
"name": "exp3",
"urls": {
"search": {
"base": "https://3.example.com/searchexp",
"searchTermParamName": "q"
}
},
"classification": "general"
},
"variants": [
{
"environment": { "allRegionsAndLocales": true, "experiment": "exp3" }
}
],
"identifier": "exp3",
"recordType": "engine"
},
{
"recordType": "defaultEngines",
"globalDefault": "engine1",
"globalDefaultPrivate": "engine1",
"specificDefaults": [
{
"environment": { "experiment": "exp1" },
"default": "engine2"
},
{
"environment": { "experiment": "exp2" },
"defaultPrivate": "exp2"
},
{
"environment": { "experiment": "exp3" },
"default": "exp3"
}
]
},
{
"recordType": "engineOrders",
"orders": [
{
"environment": { "allRegionsAndLocales": true },
"order": ["exp3", "engine1", "engine2", "exp2"]
}
]
}
],
"timestamp": 1704229342821
}

View File

@ -26,7 +26,10 @@ do_get_profile();
const FAKE_SEARCH_EXTENSION_NAME = "Some WebExtension Search Engine";
add_setup(async function () {
await SearchTestUtils.useTestEngines("search-data");
await SearchTestUtils.setRemoteSettingsConfig([
{ identifier: "engine1" },
{ identifier: "engine2" },
]);
Services.prefs.setCharPref(SearchUtils.BROWSER_SEARCH_PREF + "region", "US");
Services.locale.availableLocales = ["en-US"];
Services.locale.requestedLocales = ["en-US"];

View File

@ -63,8 +63,5 @@ support-files = [
["test_PreferencesBackupResource.js"]
["test_PreferencesBackupResource_searchEngines.js"]
support-files = [
"search-data/search-config-v2.json",
]
["test_SessionStoreBackupResource.js"]

View File

@ -23,10 +23,9 @@ const { sinon } = ChromeUtils.importESModule(
"resource://testing-common/Sinon.sys.mjs"
);
const CONFIG_V2 = [
const CONFIG = [
{
recordType: "engine",
identifier: "test",
identifier: "MozParamsTest",
base: {
name: "MozParamsTest",
urls: {
@ -92,17 +91,9 @@ const CONFIG_V2 = [
},
},
},
variants: [
{
environment: {
allRegionsAndLocales: true,
},
},
],
},
{
recordType: "engine",
identifier: "test2",
identifier: "MozParamsTest2",
base: {
name: "MozParamsTest2",
urls: {
@ -118,22 +109,6 @@ const CONFIG_V2 = [
},
},
},
variants: [
{
environment: {
allRegionsAndLocales: true,
},
},
],
},
{
recordType: "defaultEngines",
globalDefault: "test",
specificDefaults: [],
},
{
recordType: "engineOrders",
orders: [],
},
];
@ -157,7 +132,7 @@ add_task(async function setup() {
AddonTestUtils.usePrivilegedSignatures = false;
AddonTestUtils.overrideCertDB();
await AddonTestUtils.promiseStartupManager();
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await SearchTestUtils.setRemoteSettingsConfig(CONFIG);
await Services.search.init();
registerCleanupFunction(async () => {
await AddonTestUtils.promiseShutdownManager();
@ -239,7 +214,7 @@ add_task(async function test_extension_overriding_app_provided_default() {
sinon.stub(settings, "get").returns([
{
thirdPartyId: "test@thirdparty.example.com",
overridesAppIdv2: "test2",
overridesAppIdv2: "MozParamsTest2",
urls: [
{
search_url: "https://example.com/?q={searchTerms}&foo=myparams",

View File

@ -50,10 +50,9 @@ const params = [
{ name: "prefval", condition: "pref", pref: "code" },
];
const CONFIG_V2 = [
const CONFIG = [
{
recordType: "engine",
identifier: "test",
identifier: "MozParamsTest",
base: {
name: "MozParamsTest",
urls: {
@ -119,20 +118,6 @@ const CONFIG_V2 = [
},
},
},
variants: [
{
environment: { allRegionsAndLocales: true },
},
],
},
{
recordType: "defaultEngines",
globalDefault: "test",
specificDefaults: [],
},
{
recordType: "engineOrders",
orders: [],
},
];
@ -140,7 +125,7 @@ add_task(async function setup() {
let readyStub = sinon.stub(NimbusFeatures.search, "ready").resolves();
let updateStub = sinon.stub(NimbusFeatures.search, "onUpdate");
await promiseStartupManager();
await SearchTestUtils.useTestEngines("data", null, CONFIG_V2);
await SearchTestUtils.setRemoteSettingsConfig(CONFIG);
await Services.search.init();
registerCleanupFunction(async () => {
await promiseShutdownManager();

View File

@ -25,40 +25,12 @@ const kPostSearchEngineID = "test_urifixup_search_engine_post";
const kPostSearchEngineURL = "https://www.example.org/";
const kPostSearchEngineData = "q={searchTerms}";
const CONFIG_V2 = [
{
recordType: "engine",
identifier: "test_urifixup_search_engine_app_provided",
base: {
name: "test_urifixup_search_engine_app_provided",
urls: {
search: {
base: "https://www.example.org/",
searchTermParamName: "search",
},
},
},
variants: [
{
environment: { allRegionsAndLocales: true },
},
],
},
{
recordType: "defaultEngines",
globalDefault: "test_urifixup_search_engine_app_provided",
specificDefaults: [],
},
{
recordType: "engineOrders",
orders: [],
},
];
const CONFIG = [{ identifier: "test_urifixup_search_engine_app_provided" }];
async function setupSearchService() {
SearchTestUtils.init(this);
await SearchTestUtils.useTestEngines(".", null, CONFIG_V2);
await SearchTestUtils.setRemoteSettingsConfig(CONFIG);
await Services.search.init();
}

View File

@ -1,40 +0,0 @@
{
"data": [
{
"recordType": "engine",
"identifier": "telemetrySearchIdentifier",
"base": {
"name": "telemetrySearchIdentifier",
"urls": {
"search": {
"base": "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB",
"params": [
{
"name": "sourceId",
"value": "Mozilla-search"
}
],
"searchTermParamName": "search"
},
"suggestions": {
"base": "https://ar.wikipedia.org/w/api.php?action=opensearch",
"searchTermParamName": "search"
}
}
},
"variants": [
{
"environment": { "allRegionsAndLocales": true }
}
]
},
{
"recordType": "defaultEngines",
"specificDefaults": []
},
{
"recordType": "engineOrders",
"orders": []
}
]
}

View File

@ -182,7 +182,9 @@ add_task(async function setup() {
await TelemetryEnvironmentTesting.spoofProfileReset();
await TelemetryEnvironment.delayedInit();
await SearchTestUtils.useTestEngines("data", "search-extensions");
// The environment needs the search service initialised, so use a dummy
// configuration.
await SearchTestUtils.setRemoteSettingsConfig([{ identifier: "unused" }]);
});
add_task(async function test_checkEnvironment() {

View File

@ -30,6 +30,27 @@ var gHttpRoot = null;
// The URL of the data directory, on the webserver.
var gDataRoot = null;
const SEARCH_CONFIG = [
{
identifier: "telemetrySearchIdentifier",
base: {
name: "telemetrySearchIdentifier",
urls: {
search: {
base: "https://ar.wikipedia.org/wiki/%D8%AE%D8%A7%D8%B5:%D8%A8%D8%AD%D8%AB",
params: [
{
name: "sourceId",
value: "Mozilla-search",
},
],
searchTermParamName: "search",
},
},
},
},
];
add_task(async function setup() {
TelemetryEnvironmentTesting.registerFakeSysInfo();
TelemetryEnvironmentTesting.spoofGfxAdapter();
@ -82,7 +103,7 @@ add_task(async function setup() {
await TelemetryEnvironmentTesting.spoofProfileReset();
await TelemetryEnvironment.delayedInit();
await SearchTestUtils.useTestEngines("data", "search-extensions");
await SearchTestUtils.setRemoteSettingsConfig(SEARCH_CONFIG);
// Now continue with startup.
let initPromise = TelemetryEnvironment.onInitialized();

View File

@ -4,7 +4,6 @@ firefox-appdir = "browser"
# The *.xpi files are only needed for test_TelemetryEnvironment.js, but
# xpcshell fails to install tests if we move them under the test entry.
support-files = [
"data/search-extensions/search-config-v2.json",
"engine.xml",
"system.xpi",
"restartless.xpi",