зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 90a4b1d0082a (bug 1675624) for multiple failures e.g. browser_PermissionUI.js. CLOSED TREE
This commit is contained in:
Родитель
7cce5b00f5
Коммит
4035e379d0
|
@ -813,8 +813,6 @@ SearchService.prototype = {
|
|||
);
|
||||
}
|
||||
}
|
||||
let settings = await this._settings.get();
|
||||
this._loadEnginesMetadataFromSettings(settings.engines);
|
||||
|
||||
// Now set the sort out the default engines and notify as appropriate.
|
||||
this._currentEngine = null;
|
||||
|
|
|
@ -69,12 +69,6 @@ class SearchSettings {
|
|||
*/
|
||||
_searchService = null;
|
||||
|
||||
/*
|
||||
* A copy of the settings so we can persist metadata for engines that
|
||||
* are not currently active.
|
||||
*/
|
||||
_currentSettings = null;
|
||||
|
||||
addObservers() {
|
||||
Services.obs.addObserver(this, SearchUtils.TOPIC_ENGINE_MODIFIED);
|
||||
Services.obs.addObserver(this, SearchUtils.TOPIC_SEARCH_SERVICE);
|
||||
|
@ -130,7 +124,6 @@ class SearchSettings {
|
|||
Services.prefs.clearUserPref(prefName);
|
||||
}
|
||||
|
||||
this._currentSettings = json;
|
||||
return json;
|
||||
}
|
||||
|
||||
|
@ -203,21 +196,6 @@ class SearchSettings {
|
|||
settings.engines = [...this._searchService._engines.values()];
|
||||
settings.metaData = this._metaData;
|
||||
|
||||
// Persist metadata for AppProvided engines even if they aren't currently
|
||||
// active, this means if they become active again their settings
|
||||
// will be restored.
|
||||
if (this._currentSettings?.engines) {
|
||||
for (let engine of this._currentSettings.engines) {
|
||||
let included = settings.engines.some(e => e._name == engine._name);
|
||||
if (engine._isAppProvided && !included) {
|
||||
settings.engines.push(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update the local copy.
|
||||
this._currentSettings = settings;
|
||||
|
||||
try {
|
||||
if (!settings.engines.length) {
|
||||
throw new Error("cannot write without any engine.");
|
||||
|
|
|
@ -143,10 +143,6 @@ function listenFor(name, key) {
|
|||
};
|
||||
}
|
||||
|
||||
async function visibleEngines() {
|
||||
return (await Services.search.getVisibleEngines()).map(e => e.identifier);
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
Services.prefs.setBoolPref("browser.search.separatePrivateDefault", true);
|
||||
Services.prefs.setBoolPref(
|
||||
|
@ -302,39 +298,3 @@ add_task(async function test_config_updated_engine_changes() {
|
|||
"Should not have set the useSavedOrder preference"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_user_settings_persist() {
|
||||
let reload = SearchTestUtils.promiseSearchNotification("engines-reloaded");
|
||||
Region._setHomeRegion("");
|
||||
await reload;
|
||||
|
||||
Assert.ok(
|
||||
(await visibleEngines()).includes("engine-rel-searchform-purpose"),
|
||||
"Rel Searchform engine should be included by default"
|
||||
);
|
||||
|
||||
let settingsFileWritten = promiseAfterSettings();
|
||||
let engine = await Services.search.getEngineByName(
|
||||
"engine-rel-searchform-purpose"
|
||||
);
|
||||
await Services.search.removeEngine(engine);
|
||||
await settingsFileWritten;
|
||||
|
||||
Assert.ok(
|
||||
!(await visibleEngines()).includes("engine-rel-searchform-purpose"),
|
||||
"Rel Searchform engine has been removed"
|
||||
);
|
||||
|
||||
reload = SearchTestUtils.promiseSearchNotification("engines-reloaded");
|
||||
Region._setHomeRegion("FR");
|
||||
await reload;
|
||||
|
||||
reload = SearchTestUtils.promiseSearchNotification("engines-reloaded");
|
||||
Region._setHomeRegion("");
|
||||
await reload;
|
||||
|
||||
Assert.ok(
|
||||
!(await visibleEngines()).includes("engine-rel-searchform-purpose"),
|
||||
"Rel Searchform removal should be remembered"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
SearchTestUtils.initXPCShellAddonManager(this, "system");
|
||||
|
||||
const CONFIG_DEFAULT = [
|
||||
{
|
||||
webExtension: { id: "plainengine@search.mozilla.org" },
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
{
|
||||
webExtension: { id: "special-engine@search.mozilla.org" },
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
];
|
||||
|
||||
const CONFIG_UPDATED = [
|
||||
{
|
||||
webExtension: { id: "plainengine@search.mozilla.org" },
|
||||
appliesTo: [{ included: { everywhere: true } }],
|
||||
},
|
||||
];
|
||||
|
||||
async function startup() {
|
||||
let settingsFileWritten = promiseAfterSettings();
|
||||
let ss = new SearchService();
|
||||
await AddonTestUtils.promiseRestartManager();
|
||||
await ss.init(false);
|
||||
await settingsFileWritten;
|
||||
return ss;
|
||||
}
|
||||
|
||||
async function updateConfig(config) {
|
||||
const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY);
|
||||
settings.get.restore();
|
||||
sinon.stub(settings, "get").returns(config);
|
||||
}
|
||||
|
||||
async function visibleEngines(ss) {
|
||||
return (await ss.getVisibleEngines()).map(e => e._name);
|
||||
}
|
||||
|
||||
add_task(async function setup() {
|
||||
await SearchTestUtils.useTestEngines("test-extensions", null, CONFIG_DEFAULT);
|
||||
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/source/toolkit/components/search/SearchUtils.jsm#186
|
||||
await Services.search.init(false);
|
||||
Services.search.wrappedJSObject._removeObservers();
|
||||
});
|
||||
|
||||
add_task(async function() {
|
||||
let ss = await startup();
|
||||
Assert.ok(
|
||||
(await visibleEngines(ss)).includes("Special"),
|
||||
"Should have both engines on first startup"
|
||||
);
|
||||
|
||||
let settingsFileWritten = promiseAfterSettings();
|
||||
let engine = await ss.getEngineByName("Special");
|
||||
await ss.removeEngine(engine);
|
||||
await settingsFileWritten;
|
||||
|
||||
Assert.ok(
|
||||
!(await visibleEngines(ss)).includes("Special"),
|
||||
"Special has been remove, only Plain should remain"
|
||||
);
|
||||
|
||||
ss._removeObservers();
|
||||
updateConfig(CONFIG_UPDATED);
|
||||
ss = await startup();
|
||||
|
||||
Assert.ok(
|
||||
!(await visibleEngines(ss)).includes("Special"),
|
||||
"Updated to new configuration that doesnt have Special"
|
||||
);
|
||||
|
||||
ss._removeObservers();
|
||||
updateConfig(CONFIG_DEFAULT);
|
||||
ss = await startup();
|
||||
|
||||
Assert.ok(
|
||||
!(await visibleEngines(ss)).includes("Special"),
|
||||
"Configuration now includes Special but we should remember its removal"
|
||||
);
|
||||
});
|
|
@ -138,7 +138,6 @@ support-files =
|
|||
[test_settings_ignorelist.js]
|
||||
support-files = data/search_ignorelist.json
|
||||
[test_settings_none.js]
|
||||
[test_settings_persist.js]
|
||||
[test_settings.js]
|
||||
support-files =
|
||||
data1/engine1/manifest.json
|
||||
|
|
Загрузка…
Ссылка в новой задаче