diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-adbda400be353e676059e335c3c0aaf99e719475.tar.xz firefox-adbda400be353e676059e335c3c0aaf99e719475.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js')
-rw-r--r-- | browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js | 132 |
1 files changed, 117 insertions, 15 deletions
diff --git a/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js b/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js index 3248c5cefa..5437d63d16 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js +++ b/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search_mozParam.js @@ -15,6 +15,9 @@ const { NimbusFeatures } = ChromeUtils.importESModule( const { sinon } = ChromeUtils.importESModule( "resource://testing-common/Sinon.sys.mjs" ); +const { SearchUtils } = ChromeUtils.importESModule( + "resource://gre/modules/SearchUtils.sys.mjs" +); AddonTestUtils.init(this); AddonTestUtils.overrideCertDB(); @@ -51,23 +54,118 @@ const params = [ { name: "prefval", condition: "pref", pref: "code" }, ]; +const CONFIG = [ + { + webExtension: { + id: "test@search.mozilla.org", + }, + appliesTo: [ + { + included: { everywhere: true }, + default: "yes", + }, + ], + }, +]; +const CONFIG_V2 = [ + { + recordType: "engine", + identifier: "test", + base: { + name: "MozParamsTest", + urls: { + search: { + base: "https://example.com/", + params: [ + { + name: "test-0", + searchAccessPoint: { + contextmenu: "0", + }, + }, + { + name: "test-1", + searchAccessPoint: { + searchbar: "1", + }, + }, + { + name: "test-2", + searchAccessPoint: { + homepage: "2", + }, + }, + { + name: "test-3", + searchAccessPoint: { + addressbar: "3", + }, + }, + { + name: "test-4", + searchAccessPoint: { + newtab: "4", + }, + }, + { + name: "simple", + value: "5", + }, + { + name: "term", + value: "{searchTerms}", + }, + { + name: "lang", + value: "{language}", + }, + { + name: "locale", + value: "{moz:locale}", + }, + { + name: "prefval", + experimentConfig: "code", + }, + { + name: "experimenter-1", + experimentConfig: "nimbus-key-1", + }, + { + name: "experimenter-2", + experimentConfig: "nimbus-key-2", + }, + ], + searchTermParamName: "q", + }, + }, + }, + variants: [ + { + environment: { allRegionsAndLocales: true }, + }, + ], + }, + { + recordType: "defaultEngines", + globalDefault: "test", + specificDefaults: [], + }, + { + recordType: "engineOrders", + orders: [], + }, +]; + add_task(async function setup() { let readyStub = sinon.stub(NimbusFeatures.search, "ready").resolves(); let updateStub = sinon.stub(NimbusFeatures.search, "onUpdate"); await promiseStartupManager(); - await SearchTestUtils.useTestEngines("data", null, [ - { - webExtension: { - id: "test@search.mozilla.org", - }, - appliesTo: [ - { - included: { everywhere: true }, - default: "yes", - }, - ], - }, - ]); + await SearchTestUtils.useTestEngines( + "data", + null, + SearchUtils.newSearchConfigEnabled ? CONFIG_V2 : CONFIG + ); await Services.search.init(); registerCleanupFunction(async () => { await promiseShutdownManager(); @@ -107,7 +205,9 @@ add_task(async function test_extension_setting_moz_params() { ).uri.spec; equal( expectedURL, - `https://example.com/?q=test&${p.name}=${p.value}&${paramStr}`, + SearchUtils.newSearchConfigEnabled + ? `https://example.com/?${p.name}=${p.value}&${paramStr}&q=test` + : `https://example.com/?q=test&${p.name}=${p.value}&${paramStr}`, "search url is expected" ); } @@ -180,7 +280,9 @@ add_task(async function test_nimbus_params() { ).uri.spec; equal( expectedURL, - `https://example.com/?q=test&${p.name}=${p.value}&${paramStr}`, + SearchUtils.newSearchConfigEnabled + ? `https://example.com/?${p.name}=${p.value}&${paramStr}&q=test` + : `https://example.com/?q=test&${p.name}=${p.value}&${paramStr}`, "search url is expected" ); } |