diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:14:29 +0000 |
commit | fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch) | |
tree | 4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /toolkit/components/search/tests/xpcshell/test_settings_persist.js | |
parent | Releasing progress-linux version 124.0.1-1~progress7.99u1. (diff) | |
download | firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/search/tests/xpcshell/test_settings_persist.js')
-rw-r--r-- | toolkit/components/search/tests/xpcshell/test_settings_persist.js | 62 |
1 files changed, 43 insertions, 19 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_settings_persist.js b/toolkit/components/search/tests/xpcshell/test_settings_persist.js index bed6771554..5c2cbd85c4 100644 --- a/toolkit/components/search/tests/xpcshell/test_settings_persist.js +++ b/toolkit/components/search/tests/xpcshell/test_settings_persist.js @@ -1,9 +1,13 @@ /* Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ */ +/** + * Tests the removal of an engine is persisted in search settings. + */ + "use strict"; -const CONFIG_DEFAULT = [ +const CONFIG_UPDATED = [ { webExtension: { id: "plainengine@search.mozilla.org", @@ -18,26 +22,38 @@ const CONFIG_DEFAULT = [ }, appliesTo: [{ included: { everywhere: true } }], }, +]; + +const SEARCH_CONFIG_V2_UPDATED = [ { - webExtension: { - id: "special-engine@search.mozilla.org", - name: "Special", - search_url: "https://www.google.com/search", - params: [ - { - name: "q", - value: "{searchTerms}", + recordType: "engine", + identifier: "plainengine", + base: { + name: "Plain", + urls: { + search: { + base: "https://duckduckgo.com/", + searchTermParamName: "q", }, - ], + }, }, - appliesTo: [{ included: { everywhere: true } }], + variants: [ + { + environment: { allRegionsAndLocales: true }, + }, + ], + }, + { + recordType: "defaultEngines", + globalDefault: "plainengine", + specificDefaults: [], + }, + { + recordType: "engineOrders", + orders: [], }, ]; -const CONFIG_UPDATED = CONFIG_DEFAULT.filter(r => - r.webExtension.id.startsWith("plainengine") -); - async function startup() { let settingsFileWritten = promiseAfterSettings(); let ss = new SearchService(); @@ -50,7 +66,10 @@ async function startup() { async function updateConfig(config) { const settings = await RemoteSettings(SearchUtils.SETTINGS_KEY); settings.get.restore(); - sinon.stub(settings, "get").returns(config); + + config == "test-extensions" + ? await SearchTestUtils.useTestEngines("test-extensions") + : sinon.stub(settings, "get").returns(config); } async function visibleEngines(ss) { @@ -58,7 +77,7 @@ async function visibleEngines(ss) { } add_setup(async function () { - await SearchTestUtils.useTestEngines("test-extensions", null, CONFIG_DEFAULT); + await SearchTestUtils.useTestEngines("test-extensions"); registerCleanupFunction(AddonTestUtils.promiseShutdownManager); await AddonTestUtils.promiseStartupManager(); // This is only needed as otherwise events will not be properly notified @@ -87,7 +106,11 @@ add_task(async function () { ); ss._removeObservers(); - updateConfig(CONFIG_UPDATED); + await updateConfig( + SearchUtils.newSearchConfigEnabled + ? SEARCH_CONFIG_V2_UPDATED + : CONFIG_UPDATED + ); ss = await startup(); Assert.ok( @@ -96,7 +119,8 @@ add_task(async function () { ); ss._removeObservers(); - updateConfig(CONFIG_DEFAULT); + await updateConfig("test-extensions"); + ss = await startup(); Assert.ok( |