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 | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.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')
7 files changed, 285 insertions, 53 deletions
diff --git a/browser/components/extensions/test/xpcshell/test_ext_browsingData_settings.js b/browser/components/extensions/test/xpcshell/test_ext_browsingData_settings.js index 9d2241895c..843adfd0f1 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_browsingData_settings.js +++ b/browser/components/extensions/test/xpcshell/test_ext_browsingData_settings.js @@ -18,7 +18,7 @@ const SETTINGS_LIST = [ add_task(async function testSettingsProperties() { function background() { - browser.test.onMessage.addListener(msg => { + browser.test.onMessage.addListener(() => { browser.browsingData.settings().then(settings => { browser.test.sendMessage("settings", settings); }); @@ -108,7 +108,7 @@ add_task(async function testSettingsSince() { }; function background() { - browser.test.onMessage.addListener(msg => { + browser.test.onMessage.addListener(() => { browser.browsingData.settings().then(settings => { browser.test.sendMessage("settings", settings); }); diff --git a/browser/components/extensions/test/xpcshell/test_ext_chrome_settings_overrides_update.js b/browser/components/extensions/test/xpcshell/test_ext_chrome_settings_overrides_update.js index aac00a8023..b7b9deac0b 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_chrome_settings_overrides_update.js +++ b/browser/components/extensions/test/xpcshell/test_ext_chrome_settings_overrides_update.js @@ -113,7 +113,7 @@ add_task(async function test_overrides_update_removal() { // that is the default, we do not prompt for default. let deferredPrompt = topicObservable( "webextension-defaultsearch-prompt", - (subject, message) => { + subject => { if (subject.wrappedJSObject.id == extension.id) { ok(false, "default override should not prompt"); } @@ -243,7 +243,7 @@ add_task(async function test_overrides_update_adding() { let deferredUpgradePrompt = topicObservable( "webextension-defaultsearch-prompt", - (subject, message) => { + subject => { if (subject.wrappedJSObject.id == extension.id) { ok(false, "should not prompt on update"); } @@ -351,7 +351,7 @@ async function withHandlingDefaultSearchPrompt({ extensionId, respond }, cb) { ); const prompted = TestUtils.topicObserved( "webextension-defaultsearch-prompt", - (subject, message) => { + subject => { if (subject.wrappedJSObject.id == extensionId) { return subject.wrappedJSObject.respond(respond); } @@ -364,7 +364,7 @@ async function withHandlingDefaultSearchPrompt({ extensionId, respond }, cb) { async function assertUpdateDoNotPrompt(extension, updateExtensionInfo) { let deferredUpgradePrompt = topicObservable( "webextension-defaultsearch-prompt", - (subject, message) => { + subject => { if (subject.wrappedJSObject.id == extension.id) { ok(false, "should not prompt on update"); } diff --git a/browser/components/extensions/test/xpcshell/test_ext_history.js b/browser/components/extensions/test/xpcshell/test_ext_history.js index c0f6c39be7..0ad6893484 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_history.js +++ b/browser/components/extensions/test/xpcshell/test_ext_history.js @@ -251,7 +251,7 @@ add_task(async function test_search() { function background(BGSCRIPT_REFERENCE_DATE) { const futureTime = Date.now() + 24 * 60 * 60 * 1000; - browser.test.onMessage.addListener(msg => { + browser.test.onMessage.addListener(() => { browser.history .search({ text: "" }) .then(results => { @@ -295,7 +295,7 @@ add_task(async function test_search() { }); }) .then( - results => { + () => { browser.test.fail( "history.search rejects with startTime that is after the endTime" ); diff --git a/browser/components/extensions/test/xpcshell/test_ext_homepage_overrides_private.js b/browser/components/extensions/test/xpcshell/test_ext_homepage_overrides_private.js index 2d2bccc1e2..0fecc8c3e5 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_homepage_overrides_private.js +++ b/browser/components/extensions/test/xpcshell/test_ext_homepage_overrides_private.js @@ -32,7 +32,7 @@ AddonTestUtils.overrideCertDB(); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42"); function promisePrefChange(pref) { - return new Promise((resolve, reject) => { + return new Promise(resolve => { Services.prefs.addObserver(pref, function observer() { Services.prefs.removeObserver(pref, observer); resolve(arguments); diff --git a/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_defaults.js b/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_defaults.js index dd24be3aff..05ba807fae 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_defaults.js +++ b/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_defaults.js @@ -23,6 +23,124 @@ const { sinon } = ChromeUtils.importESModule( "resource://testing-common/Sinon.sys.mjs" ); +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: "engine", + identifier: "test2", + base: { + name: "MozParamsTest2", + urls: { + search: { + base: "https://example.com/2/", + params: [ + { + name: "simple2", + value: "5", + }, + ], + searchTermParamName: "q", + }, + }, + }, + variants: [ + { + environment: { + allRegionsAndLocales: true, + }, + }, + ], + }, + { + recordType: "defaultEngines", + globalDefault: "test", + specificDefaults: [], + }, + { + recordType: "engineOrders", + orders: [], + }, +]; + const URLTYPE_SUGGEST_JSON = "application/x-suggestions+json"; AddonTestUtils.init(this); @@ -43,29 +161,35 @@ add_task(async function setup() { AddonTestUtils.usePrivilegedSignatures = false; AddonTestUtils.overrideCertDB(); await AddonTestUtils.promiseStartupManager(); - await SearchTestUtils.useTestEngines("data", null, [ - { - webExtension: { - id: "test@search.mozilla.org", - }, - appliesTo: [ - { - included: { everywhere: true }, - default: "yes", - }, - ], - }, - { - webExtension: { - id: "test2@search.mozilla.org", - }, - appliesTo: [ - { - included: { everywhere: true }, - }, - ], - }, - ]); + await SearchTestUtils.useTestEngines( + "data", + null, + SearchUtils.newSearchConfigEnabled + ? CONFIG_V2 + : [ + { + webExtension: { + id: "test@search.mozilla.org", + }, + appliesTo: [ + { + included: { everywhere: true }, + default: "yes", + }, + ], + }, + { + webExtension: { + id: "test2@search.mozilla.org", + }, + appliesTo: [ + { + included: { everywhere: true }, + }, + ], + }, + ] + ); await Services.search.init(); registerCleanupFunction(async () => { await AddonTestUtils.promiseShutdownManager(); @@ -124,7 +248,9 @@ add_task(async function test_extension_changing_to_app_provided_default() { assertEngineParameters({ name: "MozParamsTest2", - searchURL: "https://example.com/2/?q={searchTerms}&simple2=5", + searchURL: SearchUtils.newSearchConfigEnabled + ? "https://example.com/2/?simple2=5&q={searchTerms}" + : "https://example.com/2/?q={searchTerms}&simple2=5", messageSnippet: "left unchanged", }); @@ -213,7 +339,9 @@ add_task(async function test_extension_overriding_app_provided_default() { ); assertEngineParameters({ name: "MozParamsTest2", - searchURL: "https://example.com/2/?q={searchTerms}&simple2=5", + searchURL: SearchUtils.newSearchConfigEnabled + ? "https://example.com/2/?simple2=5&q={searchTerms}" + : "https://example.com/2/?q={searchTerms}&simple2=5", messageSnippet: "reverted", }); @@ -256,7 +384,9 @@ add_task(async function test_extension_overriding_app_provided_default() { assertEngineParameters({ name: "MozParamsTest2", - searchURL: "https://example.com/2/?q={searchTerms}&simple2=5", + searchURL: SearchUtils.newSearchConfigEnabled + ? "https://example.com/2/?simple2=5&q={searchTerms}" + : "https://example.com/2/?q={searchTerms}&simple2=5", messageSnippet: "reverted", }); sinon.restore(); diff --git a/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search.js b/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search.js index 10fed4d36b..e4e8fab79d 100644 --- a/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search.js +++ b/browser/components/extensions/test/xpcshell/test_ext_settings_overrides_search.js @@ -60,19 +60,19 @@ add_task(async function test_extension_adding_engine() { let { baseURI } = ext1.extension; equal( - engine.getIconURL(), + await engine.getIconURL(), baseURI.resolve("foo.ico"), "16x16 icon path matches" ); equal( - engine.getIconURL(16), + await engine.getIconURL(16), baseURI.resolve("foo.ico"), "16x16 icon path matches" ); // TODO: Bug 1871036 - Differently sized icons are currently incorrectly // handled for add-ons. // equal( - // engine.getIconURL(32), + // await engine.getIconURL(32), // baseURI.resolve("foo32.ico"), // "32x32 icon path matches" // ); 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" ); } |