Bug 1619926 - Remove old search config list.json files from tests as they aren't necessary anymore. r=daleharvey

Depends on D88020

Differential Revision: https://phabricator.services.mozilla.com/D88021
This commit is contained in:
Mark Banner 2020-08-31 16:34:24 +00:00
Родитель 58fc9d2cdc
Коммит ea5b87fb78
15 изменённых файлов: 18 добавлений и 227 удалений

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

@ -1,8 +0,0 @@
{
"default": {
"searchDefault": "test",
"visibleDefaultEngines": [
"test", "test2"
]
}
}

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

@ -27,12 +27,10 @@ skip-if = tsan # Times out, bug 1612707
support-files =
data/test/manifest.json
data/test2/manifest.json
data/list.json
[test_ext_settings_overrides_search.js]
[test_ext_settings_overrides_search_mozParam.js]
support-files =
data/test/manifest.json
data/list.json
[test_ext_settings_overrides_shutdown.js]
[test_ext_settings_validate.js]
[test_ext_topSites.js]

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

@ -1,12 +0,0 @@
{
"default": {
"visibleDefaultEngines": [
"multilocale-an"
]
},
"FR": {
"visibleDefaultEngines": [
"multilocale-af"
]
}
}

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

@ -1,31 +0,0 @@
{
"default": {
"searchDefault": "Test search engine",
"searchPrivateDefault": "engine-pref",
"searchOrder": ["engine-resourceicon", "engine-chromeicon"],
"visibleDefaultEngines": [
"engine", "engine-pref", "engine-rel-searchform-purpose", "engine-chromeicon", "engine-resourceicon", "engine-reordered"
]
},
"regionOverrides": {
"RU": {
"engine-resourceicon": "engine-chromeicon"
}
},
"locales": {
"de": {
"default": {
"visibleDefaultEngines": [
"engine"
]
}
},
"fr": {
"default": {
"visibleDefaultEngines": [
"engine", "engine-pref", "engine-resourceicon"
]
}
}
}
}

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

@ -1,8 +0,0 @@
{
"default": {
"searchDefault": "engine1",
"visibleDefaultEngines": [
"engine1", "engine2"
]
}
}

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

@ -197,77 +197,7 @@ function isUSTimezone() {
return UTCOffset >= 150 && UTCOffset <= 600;
}
const kDefaultenginenamePref = "browser.search.defaultenginename";
const kTestEngineName = "Test search engine";
const TOPIC_LOCALES_CHANGE = "intl:app-locales-changed";
/**
* Loads the current default engine list.json via parsing the json manually.
*
* @param {boolean} isUS
* If this is false, the requested locale will be checked, otherwise the
* US region will be used if it exists.
* @param {boolean} privateMode
* If this is true, then the engine for private mode is returned.
* @returns {string}
* Returns the name of the private engine.
*/
function getDefaultEngineName(isUS = false, privateMode = false) {
// The list of visibleDefaultEngines needs to match or the cache will be ignored.
let chan = NetUtil.newChannel({
uri: "resource://search-extensions/list.json",
loadUsingSystemPrincipal: true,
});
const settingName = privateMode ? "searchPrivateDefault" : "searchDefault";
let searchSettings = parseJsonFromStream(chan.open());
let defaultEngineName = searchSettings.default[settingName];
if (!isUS) {
isUS = Services.locale.requestedLocale == "en-US" && isUSTimezone();
}
if (isUS && "US" in searchSettings && settingName in searchSettings.US) {
defaultEngineName = searchSettings.US[settingName];
}
return defaultEngineName;
}
function getDefaultEngineList(isUS) {
// The list of visibleDefaultEngines needs to match or the cache will be ignored.
let chan = NetUtil.newChannel({
uri: "resource://search-extensions/list.json",
loadUsingSystemPrincipal: true,
});
let json = parseJsonFromStream(chan.open());
let visibleDefaultEngines = json.default.visibleDefaultEngines;
if (isUS === undefined) {
isUS = Services.locale.requestedLocale == "en-US" && isUSTimezone();
}
if (isUS) {
let searchSettings = json.locales["en-US"];
if (
"US" in searchSettings &&
"visibleDefaultEngines" in searchSettings.US
) {
visibleDefaultEngines = searchSettings.US.visibleDefaultEngines;
}
// From nsSearchService.js
let searchRegion = "US";
if ("regionOverrides" in json && searchRegion in json.regionOverrides) {
for (let engine in json.regionOverrides[searchRegion]) {
let index = visibleDefaultEngines.indexOf(engine);
if (index > -1) {
visibleDefaultEngines[index] =
json.regionOverrides[searchRegion][engine];
}
}
}
}
return visibleDefaultEngines;
}
/**
* Waits for the cache file to be saved.

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

@ -1,12 +0,0 @@
{
"default": {
"visibleDefaultEngines": [
"basic", "simple"
]
},
"hidden": {
"visibleDefaultEngines": [
"hidden"
]
}
}

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

@ -1,25 +0,0 @@
{
"default": {
"searchDefault": "Plain",
"visibleDefaultEngines": [
"plainengine", "special-engine"
]
},
"af": {
"visibleDefaultEngines": [
"plainengine", "special-engine", "multilocale-an", "multilocale-af"
]
},
"an": {
"searchDefault": "Multilocale AN",
"visibleDefaultEngines": [
"plainengine", "special-engine", "multilocale-an"
]
},
"tr": {
"searchDefault": "Special",
"visibleDefaultEngines": [
"plainengine", "special-engine"
]
}
}

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

@ -25,9 +25,6 @@ add_task(async function setup() {
cacheTemplate = readJSONFile(cacheTemplateFile);
cacheTemplate.buildID = getAppInfo().platformBuildID;
// The list of visibleDefaultEngines needs to match or the cache will be ignored.
cacheTemplate.visibleDefaultEngines = getDefaultEngineList(false);
await promiseSaveCacheData(cacheTemplate);
});

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

@ -33,14 +33,14 @@ add_task(async function test_listJSONlocale() {
Assert.equal(
Services.search.defaultEngine.name,
getDefaultEngineName(false, false),
"Test search engine",
"Should have the correct default engine"
);
Assert.equal(
Services.search.defaultPrivateEngine.name,
// 'de' only displays google, so we'll be using the same engine as the
// normal default.
getDefaultEngineName(false, false),
"Test search engine",
"Should have the correct private default engine"
);
});

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

@ -23,12 +23,12 @@ add_task(async function test_searchDefaultEngineUS() {
Assert.equal(
Services.search.defaultEngine.name,
getDefaultEngineName(true),
"Test search engine",
"Should have the expected engine as default."
);
Assert.equal(
Services.search.originalDefaultEngine.name,
getDefaultEngineName(true),
"Test search engine",
"Should have the expected engine as the original"
);
@ -57,12 +57,12 @@ add_task(async function test_searchDefaultEngineUS() {
Assert.equal(
Services.search.defaultPrivateEngine.name,
getDefaultEngineName(true, true),
"engine-pref",
"Should have the private default engine when separate private browsing is on."
);
Assert.equal(
Services.search.originalPrivateDefaultEngine.name,
getDefaultEngineName(true, true),
"engine-pref",
"Should have the original private engine set correctly when separate private browsing is on."
);

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

@ -1,7 +1,7 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
const kSelectedEnginePref = "browser.search.selectedEngine";
const kDefaultEngineName = "engine1";
add_task(async function setup() {
await AddonTestUtils.promiseStartupManager();
@ -14,34 +14,11 @@ add_task(async function test_defaultEngine() {
await Services.search.init();
await installTestEngine();
Assert.equal(Services.search.defaultEngine.name, getDefaultEngineName());
});
// Giving prefs a user value shouldn't change the selected engine.
add_task(async function test_selectedEngine() {
let defaultEngineName = getDefaultEngineName();
// Test the selectedEngine pref.
Services.prefs.setCharPref(kSelectedEnginePref, kTestEngineName);
Services.search.wrappedJSObject.reset();
await Services.search.init(true);
Assert.equal(Services.search.defaultEngine.name, defaultEngineName);
Services.prefs.clearUserPref(kSelectedEnginePref);
// Test the defaultenginename pref.
Services.prefs.setCharPref(kDefaultenginenamePref, kTestEngineName);
Services.search.wrappedJSObject.reset();
await Services.search.init(true);
Assert.equal(Services.search.defaultEngine.name, defaultEngineName);
Services.prefs.clearUserPref(kDefaultenginenamePref);
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
});
// Setting the search engine should be persisted across restarts.
add_task(async function test_persistAcrossRestarts() {
await installTestEngine();
// Set the engine through the API.
await Services.search.setDefault(
Services.search.getEngineByName(kTestEngineName)
@ -60,7 +37,7 @@ add_task(async function test_persistAcrossRestarts() {
// Cleanup (set the engine back to default).
Services.search.resetToOriginalDefaultEngine();
Assert.equal(Services.search.defaultEngine.name, getDefaultEngineName());
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
});
// An engine set without a valid hash should be ignored.
@ -80,7 +57,7 @@ add_task(async function test_ignoreInvalidHash() {
// Re-init the search service, and check that the json file is ignored.
Services.search.wrappedJSObject.reset();
await Services.search.init(true);
Assert.equal(Services.search.defaultEngine.name, getDefaultEngineName());
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
});
// Resetting the engine to the default should remove the saved value.
@ -98,7 +75,7 @@ add_task(async function test_settingToDefault() {
// Then set the engine back to the default through the API.
await Services.search.setDefault(
Services.search.getEngineByName(getDefaultEngineName())
Services.search.getEngineByName(kDefaultEngineName)
);
await promiseAfterCache();
@ -108,8 +85,7 @@ add_task(async function test_settingToDefault() {
});
add_task(async function test_resetToOriginalDefaultEngine() {
let defaultName = getDefaultEngineName();
Assert.equal(Services.search.defaultEngine.name, defaultName);
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
await Services.search.setDefault(
Services.search.getEngineByName(kTestEngineName)
@ -118,17 +94,16 @@ add_task(async function test_resetToOriginalDefaultEngine() {
await promiseAfterCache();
Services.search.resetToOriginalDefaultEngine();
Assert.equal(Services.search.defaultEngine.name, defaultName);
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
await promiseAfterCache();
});
add_task(async function test_fallback_kept_after_restart() {
// Set current engine to a default engine that isn't the original default.
let builtInEngines = await Services.search.getDefaultEngines();
let defaultName = getDefaultEngineName();
let nonDefaultBuiltInEngine;
for (let engine of builtInEngines) {
if (engine.name != defaultName) {
if (engine.name != kDefaultEngineName) {
nonDefaultBuiltInEngine = engine;
break;
}
@ -148,17 +123,17 @@ add_task(async function test_fallback_kept_after_restart() {
// Using the defaultEngine getter should force a fallback to the
// original default engine.
Assert.equal(Services.search.defaultEngine.name, defaultName);
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
// Restoring the default engines should unhide our built-in test
// engine, but not change the value of defaultEngine.
Services.search.restoreDefaultEngines();
Assert.ok(!nonDefaultBuiltInEngine.hidden);
Assert.equal(Services.search.defaultEngine.name, defaultName);
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
await promiseAfterCache();
// After a restart, the defaultEngine value should still be unchanged.
Services.search.wrappedJSObject.reset();
await Services.search.init(true);
Assert.equal(Services.search.defaultEngine.name, defaultName);
Assert.equal(Services.search.defaultEngine.name, kDefaultEngineName);
});

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

@ -33,22 +33,18 @@ support-files =
data/engine-same-name/_locales/gd/messages.json
data/engines-no-order-hint.json
data/engines.json
data/list.json
data/search.json
data/search-legacy.json
data/searchSuggestions.sjs
data/geolookup-extensions/list.json
data/geolookup-extensions/multilocale/favicon.ico
data/geolookup-extensions/multilocale/manifest.json
data/geolookup-extensions/multilocale/_locales/af/messages.json
data/geolookup-extensions/multilocale/_locales/an/messages.json
simple-engines/engines.json
simple-engines/list.json
simple-engines/basic/manifest.json
simple-engines/hidden/manifest.json
simple-engines/simple/manifest.json
test-extensions/engines.json
test-extensions/list.json
test-extensions/plainengine/favicon.ico
test-extensions/plainengine/manifest.json
test-extensions/special-engine/favicon.ico
@ -104,13 +100,12 @@ support-files = data/search_ignorelist.json
support-files =
data1/engine1/manifest.json
data1/engine2/manifest.json
data1/list.json
data1/engines.json
[test_list_json_locale.js]
[test_list_json_no_private_default.js]
support-files =
data1/engine1/manifest.json
data1/engine2/manifest.json
data1/list.json
data1/engines.json
[test_list_json_searchdefault.js]
[test_list_json_searchorder.js]

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

@ -1,7 +0,0 @@
{
"default": {
"visibleDefaultEngines": [
"telemetrySearchIdentifier"
]
}
}

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

@ -5,7 +5,6 @@ firefox-appdir = browser
# xpcshell fails to install tests if we move them under the test entry.
support-files =
data/search-extensions/engines.json
data/search-extensions/list.json
data/search-extensions/telemetrySearchIdentifier/manifest.json
dictionary.xpi
engine.xml