Bug 1596860 - Remove default region setting for various search engines in the modern config as it is different to the legacy config. r=daleharvey

Also adds tests for checking the search engine lists when falling back to a default region.

Differential Revision: https://phabricator.services.mozilla.com/D59084

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mark Banner 2020-01-09 16:18:23 +00:00
Родитель 0d7a7f637d
Коммит c56fa2fbd0
4 изменённых файлов: 30 добавлений и 17 удалений

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

@ -174,8 +174,6 @@
"startsWith": ["bn", "en"]
}
}
}, {
"included": { "regions": ["default"] }
}]
},
{
@ -224,8 +222,6 @@
]
},
"appliesTo": [{
"included": { "regions": ["default"] }
}, {
"included": {
"locales": {
"matches": [
@ -505,8 +501,6 @@
]
},
"appliesTo": [{
"included": { "regions": ["default"] }
}, {
"included": { "locales": { "matches": ["en-US"] } },
"excluded": { "regions": ["by", "ca", "ch", "gb", "kz", "nl", "ru", "tr"] }
}, {

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

@ -126,7 +126,7 @@ depending on the user's locale.
---------
You can specify ``"default"`` as a region in the configuration if
the engine is to be included when no region is specified.
the engine is to be included when we do not know the user's region.
Application Scoping
===================

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

@ -126,6 +126,13 @@ class SearchConfigTest {
Services.search.isInitialized,
"Should have correctly initialized the search service"
);
registerCleanupFunction(() => {
this.assertOk(
!TEST_DEBUG,
"Should not have test debug turned on in production"
);
});
}
/**
@ -157,11 +164,6 @@ class SearchConfigTest {
}
}
}
this.assertOk(
!TEST_DEBUG,
"Should not have test debug turned on in production"
);
}
async _getEngines(useEngineSelector, region, locale) {
@ -169,7 +171,7 @@ class SearchConfigTest {
let engines = [];
let configs = await engineSelector.fetchEngineConfiguration(
locale,
region,
region || "default",
AppConstants.MOZ_APP_VERSION_DISPLAY.endsWith("esr")
? "esr"
: AppConstants.MOZ_UPDATE_CHANNEL
@ -192,7 +194,14 @@ class SearchConfigTest {
* The two-letter locale code.
*/
async _reinit(region, locale) {
Services.prefs.setStringPref("browser.search.region", region.toUpperCase());
if (region) {
Services.prefs.setStringPref(
"browser.search.region",
region.toUpperCase()
);
} else {
Services.prefs.clearUserPref("browser.search.region");
}
const reinitCompletePromise = SearchTestUtils.promiseSearchNotification(
"reinit-complete"
);
@ -211,12 +220,19 @@ class SearchConfigTest {
* @returns {Set} the list of regions for the tests to run with.
*/
get _regions() {
// TODO: The legacy configuration worked with null as an unknown region,
// for the search engine selector, we expect "default" but apply the
// fallback in _getEngines. Once we remove the legacy configuration, we can
// simplify this.
if (TEST_DEBUG) {
return new Set(["by", "cn", "kz", "us", "ru", "tr"]);
return new Set(["by", "cn", "kz", "us", "ru", "tr", null]);
}
const chunk =
Services.prefs.getIntPref("browser.search.config.test.section", -1) - 1;
const regions = Services.intl.getAvailableLocaleDisplayNames("region");
const regions = [
...Services.intl.getAvailableLocaleDisplayNames("region"),
null,
];
const chunkSize = Math.ceil(regions.length / 4);
const startPoint = chunk * chunkSize;
return regions.slice(startPoint, startPoint + chunkSize);

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

@ -3,7 +3,10 @@
"use strict";
let availableRegions = Services.intl.getAvailableLocaleDisplayNames("region");
const availableRegions = [
...Services.intl.getAvailableLocaleDisplayNames("region"),
null,
];
const DOMAIN_LOCALES = {
"ebay-ca": ["en-CA"],