diff --git a/toolkit/components/search/SearchService.jsm b/toolkit/components/search/SearchService.jsm index 7c740d6dbd55..aa19bad92b62 100644 --- a/toolkit/components/search/SearchService.jsm +++ b/toolkit/components/search/SearchService.jsm @@ -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; diff --git a/toolkit/components/search/SearchSettings.jsm b/toolkit/components/search/SearchSettings.jsm index 97ec66f8e5bf..3fb5baf07fee 100644 --- a/toolkit/components/search/SearchSettings.jsm +++ b/toolkit/components/search/SearchSettings.jsm @@ -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."); diff --git a/toolkit/components/search/tests/xpcshell/test_reload_engines.js b/toolkit/components/search/tests/xpcshell/test_reload_engines.js index a92281b750cf..06b3c957bb57 100644 --- a/toolkit/components/search/tests/xpcshell/test_reload_engines.js +++ b/toolkit/components/search/tests/xpcshell/test_reload_engines.js @@ -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" - ); -}); diff --git a/toolkit/components/search/tests/xpcshell/test_settings_persist.js b/toolkit/components/search/tests/xpcshell/test_settings_persist.js deleted file mode 100644 index 6cdb92d3ffd3..000000000000 --- a/toolkit/components/search/tests/xpcshell/test_settings_persist.js +++ /dev/null @@ -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" - ); -}); diff --git a/toolkit/components/search/tests/xpcshell/xpcshell.ini b/toolkit/components/search/tests/xpcshell/xpcshell.ini index 70b22daac95b..c1661da003dd 100644 --- a/toolkit/components/search/tests/xpcshell/xpcshell.ini +++ b/toolkit/components/search/tests/xpcshell/xpcshell.ini @@ -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