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 | |
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')
63 files changed, 619 insertions, 245 deletions
diff --git a/browser/components/extensions/test/AppUiTestDelegate.sys.mjs b/browser/components/extensions/test/AppUiTestDelegate.sys.mjs index f68392800d..6bfb36bfd9 100644 --- a/browser/components/extensions/test/AppUiTestDelegate.sys.mjs +++ b/browser/components/extensions/test/AppUiTestDelegate.sys.mjs @@ -112,7 +112,7 @@ async function promisePopupShown(popup) { if (popup.state == "open") { resolve(); } else { - let onPopupShown = event => { + let onPopupShown = () => { popup.removeEventListener("popupshown", onPopupShown); resolve(); }; @@ -129,7 +129,7 @@ function awaitBrowserLoaded(browser) { return Promise.resolve(); } return new Promise(resolve => { - const listener = ev => { + const listener = () => { if (browser.currentURI.spec === "about:blank") { return; } diff --git a/browser/components/extensions/test/browser/browser.toml b/browser/components/extensions/test/browser/browser.toml index c185ebd4e7..417bad7e31 100644 --- a/browser/components/extensions/test/browser/browser.toml +++ b/browser/components/extensions/test/browser/browser.toml @@ -49,7 +49,7 @@ support-files = [ "../../../../../toolkit/components/reader/test/readerModeNonArticle.html", "../../../../../toolkit/components/reader/test/readerModeArticle.html", ] -skip-if = ["os == 'linux' && asan"] # Bug 1721945 - Software WebRender +skip-if = ["os == 'linux' && os_version == '18.04' && asan"] # Bug 1721945 - Software WebRender ["browser_AMBrowserExtensionsImport.js"] @@ -75,12 +75,12 @@ disabled = "bug 1438663 # same focus issue as Bug 1438663" ["browser_ext_browserAction_context.js"] https_first_disabled = true skip-if = [ - "os == 'linux' && debug", # Bug 1504096 - "os == 'linux' && socketprocess_networking", + "os == 'linux' && os_version == '18.04' && debug", # Bug 1504096 + "os == 'linux' && os_version == '18.04' && socketprocess_networking", ] ["browser_ext_browserAction_contextMenu.js"] -skip-if = ["os == 'linux'"] # bug 1369197 +skip-if = ["os == 'linux' && os_version == '18.04'"] # bug 1369197 ["browser_ext_browserAction_disabled.js"] @@ -132,8 +132,9 @@ skip-if = ["debug"] # Bug 1522164 ["browser_ext_commands_execute_page_action.js"] skip-if = [ - "verify && os == 'linux'", - "verify && os == 'mac'", + "os == 'linux' && os_version == '18.04' && verify", + "apple_catalina && verify", + "apple_silicon && verify", ] ["browser_ext_commands_execute_sidebar_action.js"] @@ -230,8 +231,9 @@ support-files = ["../../../../../devtools/client/inspector/extensions/test/head_ ["browser_ext_find.js"] https_first_disabled = true skip-if = [ - "verify && os == 'linux'", - "verify && os == 'mac'", + "os == 'linux' && os_version == '18.04' && verify", + "apple_catalina && verify", + "apple_silicon && verify", ] ["browser_ext_getViews.js"] @@ -303,8 +305,9 @@ https_first_disabled = true ["browser_ext_openPanel.js"] skip-if = [ - "verify && !debug && os == 'linux'", - "verify && !debug && os == 'mac'", + "os == 'linux' && os_version == '18.04' && !debug && verify", + "apple_catalina && !debug && verify", + "apple_silicon && !debug && verify", ] ["browser_ext_optionsPage_activity.js"] @@ -328,14 +331,17 @@ https_first_disabled = true ["browser_ext_pageAction_context.js"] https_first_disabled = true -skip-if = ["verify && !debug && os == 'linux'"] +skip-if = ["os == 'linux' && os_version == '18.04' && !debug && verify"] ["browser_ext_pageAction_contextMenu.js"] ["browser_ext_pageAction_popup.js"] ["browser_ext_pageAction_popup_resize.js"] -skip-if = ["verify && debug && os == 'mac'"] +skip-if = [ + "apple_catalina && debug && verify", + "apple_silicon && debug && verify", +] ["browser_ext_pageAction_show_matches.js"] https_first_disabled = true @@ -487,8 +493,9 @@ https_first_disabled = true ["browser_ext_tabs_discard_reversed.js"] https_first_disabled = true skip-if = [ - "os == 'mac'", # Bug 1722607 - "os == 'linux' && debug", #Bug 1722607 + "apple_silicon", # Bug 1722607 + "apple_catalina", # Bug 1722607 + "os == 'linux' && os_version == '18.04' && debug", #Bug 1722607 ] ["browser_ext_tabs_discarded.js"] @@ -641,7 +648,10 @@ https_first_disabled = true ["browser_ext_webRequest_error_after_stopped_or_closed.js"] ["browser_ext_webrtc.js"] -skip-if = ["os == 'mac'"] # Bug 1565738 +skip-if = [ + "apple_catalina", # Bug 1565738 + "apple_silicon", # Bug 1565738 +] ["browser_ext_windows.js"] https_first_disabled = true @@ -650,7 +660,10 @@ https_first_disabled = true https_first_disabled = true ["browser_ext_windows_create.js"] -skip-if = ["verify && os == 'mac'"] +skip-if = [ + "apple_catalina && verify", + "apple_silicon && verify", +] tags = "fullscreen" ["browser_ext_windows_create_cookieStoreId.js"] @@ -670,13 +683,15 @@ https_first_disabled = true ["browser_ext_windows_size.js"] skip-if = [ - "os == 'mac'", + "apple_catalina", + "apple_silicon", "os == 'linux' && os_version == '18.04' && debug", # Fails when windows are randomly opened in fullscreen mode, Bug 1638027 ] ["browser_ext_windows_update.js"] skip-if = [ - "verify && os == 'mac'", + "apple_catalina && verify", + "apple_silicon && verify", "os == 'mac' && os_version == '10.15' && debug", # Bug 1780998 "os == 'linux' && os_version == '18.04'", # Bug 1533982 for linux1804 ] diff --git a/browser/components/extensions/test/browser/browser_AMBrowserExtensionsImport.js b/browser/components/extensions/test/browser/browser_AMBrowserExtensionsImport.js index a680edb454..515875daac 100644 --- a/browser/components/extensions/test/browser/browser_AMBrowserExtensionsImport.js +++ b/browser/components/extensions/test/browser/browser_AMBrowserExtensionsImport.js @@ -43,7 +43,7 @@ const ADDON_SEARCH_RESULTS = {}; const mockAddonRepository = ({ addons = [] }) => { return { - async getMappedAddons(browserID, extensionIDs) { + async getMappedAddons() { return Promise.resolve({ addons, matchedIDs: [], @@ -136,7 +136,7 @@ add_task(async function test_appmenu_notification() { "expected a notification about the imported add-ons" ); - const endedPromises = result.importedAddonIDs.map(id => + const endedPromises = result.importedAddonIDs.map(() => AddonTestUtils.promiseInstallEvent("onInstallEnded") ); const menuPanelHidden = BrowserTestUtils.waitForEvent( diff --git a/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js b/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js index 2e1e178215..11a3058444 100644 --- a/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js +++ b/browser/components/extensions/test/browser/browser_ExtensionControlledPopup.js @@ -13,7 +13,7 @@ ChromeUtils.defineESModuleGetters(this, { "resource://gre/modules/ExtensionSettingsStore.sys.mjs", }); -function createMarkup(doc, popup) { +function createMarkup(doc) { let panel = ExtensionControlledPopup._getAndMaybeCreatePanel(doc); let popupnotification = doc.createXULElement("popupnotification"); let attributes = { @@ -98,7 +98,7 @@ add_task(async function testExtensionControlledPopup() { return popupShown; } - function closePopupWithAction(action, extensionId) { + function closePopupWithAction(action) { let done; if (action == "ignore") { panel.hidePopup(); diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_click_types.js b/browser/components/extensions/test/browser/browser_ext_browserAction_click_types.js index 6614bb62c2..e891901ed9 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_click_types.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_click_types.js @@ -145,7 +145,7 @@ async function test_clickData_reset({ manifest_version }) { browser.test.sendMessage("onClick", info); } - function onPageActionClicked(tab, info) { + function onPageActionClicked() { browser.test.sendMessage("open-popup"); } diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js index c1f8184c78..e5d315c5d2 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_context.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_context.js @@ -258,7 +258,7 @@ let tabSwitchTestData = { "2.png": imageBuffer, }, - getTests: function (tabs, windows) { + getTests: function (tabs) { let manifest = browser.runtime.getManifest(); let { manifest_version } = manifest; const action = manifest_version < 3 ? "browserAction" : "action"; @@ -491,7 +491,7 @@ add_task(async function testDefaultTitle() { "icon.png": imageBuffer, }, - getTests: function (tabs, windows) { + getTests: function (tabs) { let details = [ { title: "Foo Extension", diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js b/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js index 9544ed43a4..8e89457904 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_contextMenu.js @@ -452,7 +452,7 @@ async function browseraction_contextmenu_remove_extension_helper() { Services.prompt = prompt; }); - async function testContextMenu(menuId, customizing) { + async function testContextMenu(menuId) { info(`Open browserAction context menu in ${menuId}`); let confirmArgs = promptService.confirmArgs(); let menu = await openContextMenu(menuId, buttonId); diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_experiment.js b/browser/components/extensions/test/browser/browser_ext_browserAction_experiment.js index d33553146e..dbf0b7efbd 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_experiment.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_experiment.js @@ -49,7 +49,7 @@ let fooExperimentFiles = { /* globals ExtensionAPI */ "parent.js": () => { this.foo = class extends ExtensionAPI { - getAPI(context) { + getAPI() { return { experiments: { foo: { @@ -65,7 +65,7 @@ let fooExperimentFiles = { "child.js": () => { this.foo = class extends ExtensionAPI { - getAPI(context) { + getAPI() { return { experiments: { foo: { diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_pageAction_icon_permissions.js b/browser/components/extensions/test/browser/browser_ext_browserAction_pageAction_icon_permissions.js index 5a94a0dde1..71f615c91d 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_pageAction_icon_permissions.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_pageAction_icon_permissions.js @@ -21,7 +21,7 @@ add_task(async function testInvalidIconSizes() { let promises = []; for (let api of ["pageAction", "browserAction"]) { // helper function to run setIcon and check if it fails - let assertSetIconThrows = function (detail, error, message) { + let assertSetIconThrows = function (detail) { detail.tabId = tabId; browser.test.assertThrows( () => browser[api].setIcon(detail), @@ -203,7 +203,7 @@ add_task(async function testSecureManifestURLsDenied() { for (let api of apis) { info(`TEST ${api} icon url: ${url}`); - let matchURLForbidden = url => ({ + let matchURLForbidden = () => ({ message: new RegExp(`match the format "strictRelativeUrl"`), }); diff --git a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js index 4c47c1b13b..c640f63ab7 100644 --- a/browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js +++ b/browser/components/extensions/test/browser/browser_ext_browserAction_popup_preload.js @@ -136,7 +136,7 @@ add_task(async function testBrowserActionClickCanceled() { widget.node, "mouseup", false, - event => { + () => { isnot(browserAction.pendingPopup, null, "Pending popup was not cleared"); isnot( browserAction.pendingPopupTimeout, @@ -279,7 +279,7 @@ add_task(async function testBrowserActionDisabled() { widget.node, "mouseup", false, - event => { + () => { is(browserAction.pendingPopup, null, "Have no pending popup"); is( browserAction.pendingPopupTimeout, diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus.js b/browser/components/extensions/test/browser/browser_ext_contextMenus.js index c816c89f82..77e4bf0827 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus.js @@ -391,7 +391,7 @@ add_task(async function () { checkClickInfo(result); // Select some text - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function (arg) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { let doc = content.document; let range = doc.createRange(); let selection = content.getSelection(); @@ -459,7 +459,7 @@ add_task(async function () { checkClickInfo(result); // Select a lot of text - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function (arg) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { let doc = content.document; let range = doc.createRange(); let selection = content.getSelection(); @@ -501,7 +501,7 @@ add_task(async function () { // Select a lot of text, excercise the editable element code path in // the Browser:GetSelection handler. - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function (arg) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { let doc = content.document; let node = doc.getElementById("editabletext"); // content.js handleContentContextMenu fails intermittently without focus. diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus_bookmarks.js b/browser/components/extensions/test/browser/browser_ext_contextMenus_bookmarks.js index 1e95899513..24411731f7 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus_bookmarks.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_bookmarks.js @@ -20,7 +20,7 @@ function bookmarkContextMenuExtension() { { title: CONTEXT_ENTRY_LABEL, contexts: ["bookmark"], - onclick: (info, tab) => { + onclick: info => { browser.test.sendMessage(`clicked`, info.bookmarkId); }, }, diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js b/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js index 5a8f1db208..d643dda663 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_commands.js @@ -25,7 +25,7 @@ add_task(async function test_actions_context_menu() { contexts: ["all"], command: "_execute_sidebar_action", }); - browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { + browser.tabs.onUpdated.addListener(tabId => { browser.pageAction.show(tabId); }); browser.contextMenus.onClicked.addListener(() => { diff --git a/browser/components/extensions/test/browser/browser_ext_contextMenus_targetUrlPatterns.js b/browser/components/extensions/test/browser/browser_ext_contextMenus_targetUrlPatterns.js index b28487064f..0f353600d7 100644 --- a/browser/components/extensions/test/browser/browser_ext_contextMenus_targetUrlPatterns.js +++ b/browser/components/extensions/test/browser/browser_ext_contextMenus_targetUrlPatterns.js @@ -72,7 +72,7 @@ add_task(async function unsupportedSchemes() { }, ]; - async function testScript(testcases) { + async function testScript() { let testcase; browser.contextMenus.onShown.addListener(({ menuIds, linkUrl }) => { diff --git a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow.js b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow.js index 0cfcb33ab3..55acbadad4 100644 --- a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow.js +++ b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow.js @@ -464,7 +464,7 @@ add_task(async function test_devtools_inspectedWindow_eval_target_lifecycle() { ); function devtools_page() { - browser.test.onMessage.addListener(async (msg, ...args) => { + browser.test.onMessage.addListener(async msg => { if (msg !== "inspectedWindow-eval-requests") { browser.test.fail(`Unexpected test message received: ${msg}`); return; diff --git a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js index a5f910e698..f0aeb891fd 100644 --- a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js +++ b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_eval_bindings.js @@ -231,7 +231,7 @@ add_task(async function test_devtools_inspectedWindow_eval_bindings() { info("Waiting for the object properties to be displayed"); // If this is the case, we wait for the properties to be fetched and displayed. await new Promise(resolve => { - const observer = new MutationObserver(mutations => { + const observer = new MutationObserver(() => { resolve(); observer.disconnect(); }); diff --git a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_reload.js b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_reload.js index 9f7d452a2c..116d063f50 100644 --- a/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_reload.js +++ b/browser/components/extensions/test/browser/browser_ext_devtools_inspectedWindow_reload.js @@ -270,7 +270,7 @@ add_task( background, devtoolsPage, closeToolbox: false, - testCase: async function (extension, tab, toolbox) { + testCase: async function (extension, tab) { info("Get the initial user agent"); const initialUserAgent = await SpecialPowers.spawn( gBrowser.selectedBrowser, diff --git a/browser/components/extensions/test/browser/browser_ext_devtools_page.js b/browser/components/extensions/test/browser/browser_ext_devtools_page.js index 8f2700c657..492825965a 100644 --- a/browser/components/extensions/test/browser/browser_ext_devtools_page.js +++ b/browser/components/extensions/test/browser/browser_ext_devtools_page.js @@ -202,11 +202,11 @@ add_task(async function test_devtools_page_and_extension_tab_messaging() { } function devtools_page() { - browser.runtime.onConnect.addListener(port => { + browser.runtime.onConnect.addListener(() => { browser.test.sendMessage("devtools_page_onconnect"); }); - browser.runtime.onMessage.addListener((msg, sender) => { + browser.runtime.onMessage.addListener(() => { browser.test.sendMessage("devtools_page_onmessage"); }); diff --git a/browser/components/extensions/test/browser/browser_ext_menus_accesskey.js b/browser/components/extensions/test/browser/browser_ext_menus_accesskey.js index 88c89902ac..8424dc2813 100644 --- a/browser/components/extensions/test/browser/browser_ext_menus_accesskey.js +++ b/browser/components/extensions/test/browser/browser_ext_menus_accesskey.js @@ -185,7 +185,7 @@ add_task(async function accesskeys_selection() { await extension.startup(); // Select all - await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function (arg) { + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () { let doc = content.document; let range = doc.createRange(); let selection = content.getSelection(); diff --git a/browser/components/extensions/test/browser/browser_ext_menus_targetElement.js b/browser/components/extensions/test/browser/browser_ext_menus_targetElement.js index abfbf26a05..4fc9ebba82 100644 --- a/browser/components/extensions/test/browser/browser_ext_menus_targetElement.js +++ b/browser/components/extensions/test/browser/browser_ext_menus_targetElement.js @@ -29,7 +29,7 @@ async function loadExtensionAndTab() { } async function background() { - browser.menus.onShown.addListener(async (info, tab) => { + browser.menus.onShown.addListener(async info => { browser.test.sendMessage("onShownMenu", info.targetElementId); }); await browser.tabs.executeScript({ file: "contentScript.js" }); @@ -79,7 +79,7 @@ add_task(async function required_permission() { // Load another extension to verify that the permission from the first // extension does not enable the "targetElementId" parameter. function background() { - browser.contextMenus.onShown.addListener((info, tab) => { + browser.contextMenus.onShown.addListener(info => { browser.test.assertEq( undefined, info.targetElementId, diff --git a/browser/components/extensions/test/browser/browser_ext_mousewheel_zoom.js b/browser/components/extensions/test/browser/browser_ext_mousewheel_zoom.js index d558400a7e..9c5f447a76 100644 --- a/browser/components/extensions/test/browser/browser_ext_mousewheel_zoom.js +++ b/browser/components/extensions/test/browser/browser_ext_mousewheel_zoom.js @@ -40,7 +40,7 @@ async function test_mousewheel_zoom(test) { function contentScript() { // eslint-disable-next-line mozilla/balanced-listeners - document.addEventListener("mousedown", e => { + document.addEventListener("mousedown", () => { // Send the zoom level back as a "zoom" message. const zoom = SpecialPowers.getFullZoom(window).toFixed(2); browser.test.sendMessage("zoom", zoom); @@ -49,7 +49,7 @@ async function test_mousewheel_zoom(test) { function sidebarContentScript() { // eslint-disable-next-line mozilla/balanced-listeners - document.addEventListener("mousedown", e => { + document.addEventListener("mousedown", () => { // Send the zoom level back as a "zoom" message. const zoom = SpecialPowers.getFullZoom(window).toFixed(2); browser.test.sendMessage("zoom", zoom); diff --git a/browser/components/extensions/test/browser/browser_ext_openPanel.js b/browser/components/extensions/test/browser/browser_ext_openPanel.js index 105cdc834b..ed96bf2520 100644 --- a/browser/components/extensions/test/browser/browser_ext_openPanel.js +++ b/browser/components/extensions/test/browser/browser_ext_openPanel.js @@ -4,7 +4,7 @@ add_task(async function test_openPopup_requires_user_interaction() { async function backgroundScript() { - browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tabInfo) => { + browser.tabs.onUpdated.addListener(async (tabId, changeInfo) => { if (changeInfo.status != "complete") { return; } diff --git a/browser/components/extensions/test/browser/browser_ext_optionsPage_modals.js b/browser/components/extensions/test/browser/browser_ext_optionsPage_modals.js index 809a5605c0..0c3d150c91 100644 --- a/browser/components/extensions/test/browser/browser_ext_optionsPage_modals.js +++ b/browser/components/extensions/test/browser/browser_ext_optionsPage_modals.js @@ -2,6 +2,41 @@ /* vim: set sts=2 sw=2 et tw=80: */ "use strict"; +const { PromptTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/PromptTestUtils.sys.mjs" +); + +async function waitForExtensionModalPrompt(extension) { + const dialog = await PromptTestUtils.waitForPrompt(gBrowser.selectedBrowser, { + modalType: Ci.nsIPrompt.MODAL_TYPE_CONTENT, + }); + ok(dialog, "Got an active modal prompt dialog as expected"); + Assert.equal( + dialog?.args.promptPrincipal.addonId, + extension.id, + "Got a prompt associated to the expected extension id" + ); + + const promptTitle = dialog?.ui.infoTitle.textContent; + ok( + /The page at TestExtName says:/.test(promptTitle), + `Got the expect title on the modal prompt dialog: "${promptTitle}"` + ); + + return { + async closeModalPrompt() { + info("Close the tab modal prompt"); + await PromptTestUtils.handlePrompt(dialog); + }, + assertClosedModalPrompt() { + ok( + !dialog.args.promptActive, + "modal prompt dialog has been closed as expected" + ); + }, + }; +} + add_task(async function test_tab_options_modals() { function backgroundScript() { browser.runtime.openOptionsPage(); @@ -26,6 +61,7 @@ add_task(async function test_tab_options_modals() { options_ui: { page: "options.html", }, + name: "TestExtName", }, files: { "options.html": `<!DOCTYPE html> @@ -42,57 +78,15 @@ add_task(async function test_tab_options_modals() { await BrowserTestUtils.openNewForegroundTab(gBrowser, "about:addons"); + const testPromptPromise = waitForExtensionModalPrompt(extension); await extension.startup(); - const onceModalOpened = new Promise(resolve => { - const aboutAddonsBrowser = gBrowser.selectedBrowser; - - aboutAddonsBrowser.addEventListener( - "DOMWillOpenModalDialog", - function onModalDialog(event) { - // Wait for the next event tick to make sure the remaining part of the - // testcase runs after the dialog gets opened. - SimpleTest.executeSoon(resolve); - }, - { once: true, capture: true } - ); - }); - info("Wait the options_ui modal to be opened"); - await onceModalOpened; - - const optionsBrowser = getInlineOptionsBrowser(gBrowser.selectedBrowser); - - // The stack that contains the tabmodalprompt elements is the parent of - // the extensions options_ui browser element. - let stack = optionsBrowser.parentNode; - - let dialogs = stack.querySelectorAll("tabmodalprompt"); - Assert.equal( - dialogs.length, - 1, - "Expect a tab modal opened for the about addons tab" - ); - - // Verify that the expected stylesheets have been applied on the - // tabmodalprompt element (See Bug 1550529). - const tabmodalStyle = dialogs[0].ownerGlobal.getComputedStyle(dialogs[0]); - is( - tabmodalStyle["background-color"], - "rgba(26, 26, 26, 0.5)", - "Got the expected styles applied to the tabmodalprompt" - ); - - info("Close the tab modal prompt"); - dialogs[0].querySelector(".tabmodalprompt-button0").click(); + const testModalPrompt = await testPromptPromise; + testModalPrompt.closeModalPrompt(); await extension.awaitFinish("options-ui-modals"); - - Assert.equal( - stack.querySelectorAll("tabmodalprompt").length, - 0, - "Expect the tab modal to be closed" - ); + testModalPrompt.assertClosedModalPrompt(); BrowserTestUtils.removeTab(gBrowser.selectedTab); diff --git a/browser/components/extensions/test/browser/browser_ext_pageAction_click_types.js b/browser/components/extensions/test/browser/browser_ext_pageAction_click_types.js index 0168ea0ab2..0ca9be6bfa 100644 --- a/browser/components/extensions/test/browser/browser_ext_pageAction_click_types.js +++ b/browser/components/extensions/test/browser/browser_ext_pageAction_click_types.js @@ -146,7 +146,7 @@ async function test_clickData_reset(testAsNonPersistent = false) { files: { "background.js": async function background() { - function onBrowserActionClicked(tab, info) { + function onBrowserActionClicked() { // openPopup requires user interaction, such as a browser action click. browser.pageAction.openPopup(); } diff --git a/browser/components/extensions/test/browser/browser_ext_popup_focus.js b/browser/components/extensions/test/browser/browser_ext_popup_focus.js index 4cf46f2be5..16e4f05dbb 100644 --- a/browser/components/extensions/test/browser/browser_ext_popup_focus.js +++ b/browser/components/extensions/test/browser/browser_ext_popup_focus.js @@ -22,7 +22,7 @@ add_task(async function testPageActionFocus() { "popup.js": function () { window.addEventListener( "focus", - event => { + () => { browser.test.log("extension popup received focus event"); browser.test.assertEq( true, @@ -63,7 +63,7 @@ add_task(async function testBrowserActionFocus() { "popup.js": function () { window.addEventListener( "focus", - event => { + () => { browser.test.log("extension popup received focus event"); browser.test.assertEq( true, diff --git a/browser/components/extensions/test/browser/browser_ext_search_favicon.js b/browser/components/extensions/test/browser/browser_ext_search_favicon.js index 4e48dd55fa..474ab37e20 100644 --- a/browser/components/extensions/test/browser/browser_ext_search_favicon.js +++ b/browser/components/extensions/test/browser/browser_ext_search_favicon.js @@ -25,18 +25,18 @@ server.registerPathHandler("/ico.png", (request, response) => { response.write(atob(HTTP_ICON_DATA)); }); -function promiseEngineIconLoaded(engineName) { - return TestUtils.topicObserved( +async function promiseEngineIconLoaded(engineName) { + await TestUtils.topicObserved( "browser-search-engine-modified", (engine, verb) => { engine.QueryInterface(Ci.nsISearchEngine); - return ( - verb == "engine-changed" && - engine.name == engineName && - engine.getIconURL() - ); + return verb == "engine-changed" && engine.name == engineName; } ); + Assert.ok( + await Services.search.getEngineByName(engineName).getIconURL(), + "Should have a valid icon URL" + ); } add_task(async function test_search_favicon() { diff --git a/browser/components/extensions/test/browser/browser_ext_sessions_getRecentlyClosed_tabs.js b/browser/components/extensions/test/browser/browser_ext_sessions_getRecentlyClosed_tabs.js index 4a513f5131..71c30ccf5b 100644 --- a/browser/components/extensions/test/browser/browser_ext_sessions_getRecentlyClosed_tabs.js +++ b/browser/components/extensions/test/browser/browser_ext_sessions_getRecentlyClosed_tabs.js @@ -247,7 +247,7 @@ add_task( info("Open the non web controlled page in _blank target"); let onNewTabOpened = new Promise(resolve => win.gBrowser.addTabsProgressListener({ - onStateChange(browser, webProgress, request, stateFlags, status) { + onStateChange(browser, webProgress, request, stateFlags) { if (stateFlags & Ci.nsIWebProgressListener.STATE_START) { win.gBrowser.removeTabsProgressListener(this); resolve(win.gBrowser.getTabForBrowser(browser)); diff --git a/browser/components/extensions/test/browser/browser_ext_sessions_restore.js b/browser/components/extensions/test/browser/browser_ext_sessions_restore.js index 39057519ed..1006fab89a 100644 --- a/browser/components/extensions/test/browser/browser_ext_sessions_restore.js +++ b/browser/components/extensions/test/browser/browser_ext_sessions_restore.js @@ -27,7 +27,7 @@ add_task(async function test_sessions_restore() { }); } else if (msg == "restore-reject") { browser.sessions.restore("not-a-valid-session-id").then( - sessions => { + () => { browser.test.fail("restore rejected with an invalid sessionId"); }, error => { diff --git a/browser/components/extensions/test/browser/browser_ext_sessions_restoreTab.js b/browser/components/extensions/test/browser/browser_ext_sessions_restoreTab.js index 679e1fbd6c..c89e9d39dc 100644 --- a/browser/components/extensions/test/browser/browser_ext_sessions_restoreTab.js +++ b/browser/components/extensions/test/browser/browser_ext_sessions_restoreTab.js @@ -16,7 +16,7 @@ ChromeUtils.defineESModuleGetters(this, { add_task(async function test_restoringModifiedTab() { function background() { browser.tabs.create({ url: "http://example.com/" }); - browser.test.onMessage.addListener((msg, filter) => { + browser.test.onMessage.addListener(msg => { if (msg == "change-tab") { browser.tabs.executeScript({ code: 'location.href += "?changedTab";' }); } @@ -83,7 +83,7 @@ add_task(async function test_restoringModifiedTab() { add_task(async function test_restoringClosedTabWithTooLargeIndex() { function background() { - browser.test.onMessage.addListener(async (msg, filter) => { + browser.test.onMessage.addListener(async msg => { if (msg != "restoreTab") { return; } diff --git a/browser/components/extensions/test/browser/browser_ext_sessions_window_tab_value.js b/browser/components/extensions/test/browser/browser_ext_sessions_window_tab_value.js index b21b59fe8c..f6482ed709 100644 --- a/browser/components/extensions/test/browser/browser_ext_sessions_window_tab_value.js +++ b/browser/components/extensions/test/browser/browser_ext_sessions_window_tab_value.js @@ -134,7 +134,7 @@ add_task(async function test_sessions_tab_value_persistence() { // Wait until the newly created tab has completed loading or it will still have // about:blank url when it gets removed and will not appear in the removed tabs history. browser.webNavigation.onCompleted.addListener( - async function newTabListener(details) { + async function newTabListener() { browser.webNavigation.onCompleted.removeListener(newTabListener); let tabs = await browser.tabs.query({ currentWindow: true }); diff --git a/browser/components/extensions/test/browser/browser_ext_settings_overrides_default_search.js b/browser/components/extensions/test/browser/browser_ext_settings_overrides_default_search.js index 74eaa6e634..083f6be393 100644 --- a/browser/components/extensions/test/browser/browser_ext_settings_overrides_default_search.js +++ b/browser/components/extensions/test/browser/browser_ext_settings_overrides_default_search.js @@ -7,6 +7,7 @@ ChromeUtils.defineESModuleGetters(this, { AddonManager: "resource://gre/modules/AddonManager.sys.mjs", AddonTestUtils: "resource://testing-common/AddonTestUtils.sys.mjs", SearchTestUtils: "resource://testing-common/SearchTestUtils.sys.mjs", + SearchUtils: "resource://gre/modules/SearchUtils.sys.mjs", TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs", }); @@ -21,14 +22,19 @@ SearchTestUtils.init(this); const DEFAULT_ENGINE = { id: "basic", name: "basic", - loadPath: "[addon]basic@search.mozilla.org", - submissionUrl: - "https://mochi.test:8888/browser/browser/components/search/test/browser/?search=&foo=1", + loadPath: SearchUtils.newSearchConfigEnabled + ? "[app]basic@search.mozilla.org" + : "[addon]basic@search.mozilla.org", + submissionUrl: SearchUtils.newSearchConfigEnabled + ? "https://mochi.test:8888/browser/browser/components/search/test/browser/?foo=1&search=" + : "https://mochi.test:8888/browser/browser/components/search/test/browser/?search=&foo=1", }; const ALTERNATE_ENGINE = { id: "simple", name: "Simple Engine", - loadPath: "[addon]simple@search.mozilla.org", + loadPath: SearchUtils.newSearchConfigEnabled + ? "[app]simple@search.mozilla.org" + : "[addon]simple@search.mozilla.org", submissionUrl: "https://example.com/?sourceId=Mozilla-search&search=", }; const ALTERNATE2_ENGINE = { @@ -97,7 +103,11 @@ add_setup(async function () { await SearchTestUtils.useMochitestEngines(searchExtensions); SearchTestUtils.useMockIdleService(); - let response = await fetch(`resource://search-extensions/engines.json`); + let response = await fetch( + SearchUtils.newSearchConfigEnabled + ? `resource://search-extensions/search-config-v2.json` + : `resource://search-extensions/engines.json` + ); let json = await response.json(); await SearchTestUtils.updateRemoteSettingsConfig(json.data); diff --git a/browser/components/extensions/test/browser/browser_ext_sidebarAction.js b/browser/components/extensions/test/browser/browser_ext_sidebarAction.js index afc1e4f9b9..8498f73071 100644 --- a/browser/components/extensions/test/browser/browser_ext_sidebarAction.js +++ b/browser/components/extensions/test/browser/browser_ext_sidebarAction.js @@ -204,14 +204,16 @@ add_task(async function sidebar_isOpen() { }); add_task(async function testShortcuts() { - function verifyShortcut(id, commandKey) { + function verifyShortcut(id, commandKey, win = window) { + const doc = win.document; // We're just testing the command key since the modifiers have different // icons on different platforms. - let menuitem = document.getElementById( + let menuitem = doc.getElementById( `sidebarswitcher_menu_${makeWidgetId(id)}-sidebar-action` ); + ok(menuitem, `Expect a menuitem for ${id}`); ok(menuitem.hasAttribute("key"), "The menu item has a key specified"); - let key = document.getElementById(menuitem.getAttribute("key")); + let key = doc.getElementById(menuitem.getAttribute("key")); ok(key, "The key attribute finds the related key element"); ok( menuitem.getAttribute("acceltext").endsWith(commandKey), @@ -219,6 +221,16 @@ add_task(async function testShortcuts() { ); } + async function toggleSwitcherPanel(win = window) { + // Open and close the switcher panel to trigger shortcut content rendering. + let switcherPanelShown = promisePopupShown(win.SidebarUI._switcherPanel); + win.SidebarUI.showSwitcherPanel(); + await switcherPanelShown; + let switcherPanelHidden = promisePopupHidden(win.SidebarUI._switcherPanel); + win.SidebarUI.hideSwitcherPanel(); + await switcherPanelHidden; + } + let extension1 = ExtensionTestUtils.loadExtension( getExtData({ commands: { @@ -244,25 +256,48 @@ add_task(async function testShortcuts() { await extension1.startup(); await extension1.awaitMessage("sidebar"); + await extension2.startup(); + await extension2.awaitMessage("sidebar"); - // Open and close the switcher panel to trigger shortcut content rendering. - let switcherPanelShown = promisePopupShown(SidebarUI._switcherPanel); - SidebarUI.showSwitcherPanel(); - await switcherPanelShown; - let switcherPanelHidden = promisePopupHidden(SidebarUI._switcherPanel); - SidebarUI.hideSwitcherPanel(); - await switcherPanelHidden; + info("Open a second window"); + const win = await BrowserTestUtils.openNewBrowserWindow(); + info("Wait for extension2 sidebar to be open in the new window"); + await extension2.awaitMessage("sidebar"); + + info("Toggle switcher panel"); + await toggleSwitcherPanel(); + await toggleSwitcherPanel(win); // Test that the key is set for the extension after the shortcuts are rendered. verifyShortcut(extension1.id, "I"); - - await extension2.startup(); - await extension2.awaitMessage("sidebar"); + verifyShortcut(extension1.id, "I", win); // Once the switcher panel has been opened new shortcuts should be added // automatically. verifyShortcut(extension2.id, "E"); + verifyShortcut(extension2.id, "E", win); + + // Regression test (see Bug 1881820). + info( + "Reload the addon and verify the sidebar shortcut still works as expected" + ); + const addon = await AddonManager.getAddonByID(extension1.id); + await addon.reload(); + + const keysetId1 = `#ext-keyset-id-${makeWidgetId(extension1.id)}`; + Assert.equal( + window.document.querySelectorAll(keysetId1).length, + 1, + "Expect no keyset leaked in the 1st window after addon reload" + ); + Assert.equal( + win.document.querySelectorAll(keysetId1).length, + 1, + "Expect no keyset leaked in the 2nd window after addon reload" + ); await extension1.unload(); await extension2.unload(); + + await BrowserTestUtils.closeWindow(win); }); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_autoDiscardable.js b/browser/components/extensions/test/browser/browser_ext_tabs_autoDiscardable.js index 74043e2a3a..acca3638a0 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_autoDiscardable.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_autoDiscardable.js @@ -23,7 +23,7 @@ add_task(async function test_autoDiscardable() { ); const { ExtensionError } = ExtensionUtils; this.experiments = class extends ExtensionAPI { - getAPI(context) { + getAPI() { return { experiments: { async unload() { diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_discard_reversed.js b/browser/components/extensions/test/browser/browser_ext_tabs_discard_reversed.js index 5fad30a6fb..753b9b67a6 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_discard_reversed.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_discard_reversed.js @@ -44,7 +44,7 @@ add_task(async function tabs_discarded_load_and_discard() { title: [], url: [], }; - function tabsOnUpdatedAfterLoad(tabId, changeInfo, tab) { + function tabsOnUpdatedAfterLoad(tabId, changeInfo) { browser.test.assertEq(TAB_ID, tabId, "tabId for tabs.onUpdated"); for (let [prop, value] of Object.entries(changeInfo)) { observedChanges[prop].push(value); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js b/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js index 50c56ea796..f45b285311 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_duplicate.js @@ -46,7 +46,7 @@ add_task(async function testDuplicateTab() { add_task(async function testDuplicateTabLazily() { async function background() { let tabLoadComplete = new Promise(resolve => { - browser.test.onMessage.addListener((message, tabId, result) => { + browser.test.onMessage.addListener((message, tabId) => { if (message == "duplicate-tab-done") { resolve(tabId); } @@ -55,11 +55,7 @@ add_task(async function testDuplicateTabLazily() { function awaitLoad(tabId) { return new Promise(resolve => { - browser.tabs.onUpdated.addListener(function listener( - tabId_, - changed, - tab - ) { + browser.tabs.onUpdated.addListener(function listener(tabId_, changed) { if (tabId == tabId_ && changed.status == "complete") { browser.tabs.onUpdated.removeListener(listener); resolve(); @@ -282,7 +278,7 @@ add_task(async function testDuplicateResolvePromiseRightAway() { let resolvedRightAway = true; browser.tabs.onUpdated.addListener( - (tabId, changeInfo, tab) => { + () => { resolvedRightAway = false; }, { urls: [source.url] } diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_events.js b/browser/components/extensions/test/browser/browser_ext_tabs_events.js index fe9317b4a6..f323d1e55d 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_events.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_events.js @@ -211,7 +211,7 @@ add_task(async function test_tab_events_incognito_monitored() { // We have to explicitly wait for the event here, since its timing is // not predictable. let promiseAttached = new Promise(resolve => { - browser.tabs.onAttached.addListener(function listener(tabId) { + browser.tabs.onAttached.addListener(function listener() { browser.tabs.onAttached.removeListener(listener); resolve(); }); @@ -427,11 +427,7 @@ add_task(async function testTabRemovalEvent() { function awaitLoad(tabId) { return new Promise(resolve => { - browser.tabs.onUpdated.addListener(function listener( - tabId_, - changed, - tab - ) { + browser.tabs.onUpdated.addListener(function listener(tabId_, changed) { if (tabId == tabId_ && changed.status == "complete") { browser.tabs.onUpdated.removeListener(listener); resolve(); @@ -440,7 +436,7 @@ add_task(async function testTabRemovalEvent() { }); } - chrome.tabs.onRemoved.addListener((tabId, info) => { + chrome.tabs.onRemoved.addListener(tabId => { browser.test.assertEq( 0, events.length, @@ -466,7 +462,7 @@ add_task(async function testTabRemovalEvent() { let tab = await browser.tabs.create({ url: url }); await awaitLoad(tab.id); - chrome.tabs.onActivated.addListener(info => { + chrome.tabs.onActivated.addListener(() => { browser.test.assertEq( 1, events.length, @@ -522,7 +518,7 @@ add_task(async function testTabCreateRelated() { ); browser.test.fail("tabMoved was received"); }); - browser.tabs.onRemoved.addListener((tabId, info) => { + browser.tabs.onRemoved.addListener(tabId => { browser.test.assertEq(created, tabId, "removed id same as created"); browser.test.sendMessage("tabRemoved"); }); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js index c02aef3da9..f79b67f779 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript.js @@ -77,7 +77,7 @@ add_task(async function testExecuteScript() { code: "42", }) .then( - result => { + () => { browser.test.fail( "Expected not to be able to execute a script with both file and code" ); @@ -208,7 +208,7 @@ add_task(async function testExecuteScript() { code: "window", }) .then( - result => { + () => { browser.test.fail( "Expected error when returning non-structured-clonable object" ); @@ -232,7 +232,7 @@ add_task(async function testExecuteScript() { code: "Promise.resolve(window)", }) .then( - result => { + () => { browser.test.fail( "Expected error when returning non-structured-clonable object" ); @@ -256,7 +256,7 @@ add_task(async function testExecuteScript() { file: "script3.js", }) .then( - result => { + () => { browser.test.fail( "Expected error when returning non-structured-clonable object" ); @@ -281,7 +281,7 @@ add_task(async function testExecuteScript() { code: "42", }) .then( - result => { + () => { browser.test.fail( "Expected error when specifying invalid frame ID" ); @@ -303,7 +303,7 @@ add_task(async function testExecuteScript() { code: "42", }) .then( - result => { + () => { browser.test.fail( "Expected error when trying to execute on invalid domain" ); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js index e9d008bf92..648a6f7e30 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_executeScript_good.js @@ -8,7 +8,7 @@ async function testHasPermission(params) { let contentSetup = params.contentSetup || (() => Promise.resolve()); async function background(contentSetup) { - browser.runtime.onMessage.addListener((msg, sender) => { + browser.runtime.onMessage.addListener(msg => { browser.test.assertEq(msg, "script ran", "script ran"); browser.test.notifyPass("executeScript"); }); @@ -158,7 +158,7 @@ add_task(async function testGoodPermissions() { browser.contextMenus.create({ title: "activeTab", contexts: ["all"] }); return Promise.resolve(); }, - setup: async function (extension) { + setup: async function () { let contextMenu = document.getElementById("contentAreaContextMenu"); let awaitPopupShown = BrowserTestUtils.waitForEvent( contextMenu, diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_hide.js b/browser/components/extensions/test/browser/browser_ext_tabs_hide.js index 89c50db692..cb7373451d 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_hide.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_hide.js @@ -148,7 +148,7 @@ add_task(function test_doorhanger_disable() { add_task(async function test_tabs_showhide() { async function background() { - browser.test.onMessage.addListener(async (msg, data) => { + browser.test.onMessage.addListener(async msg => { switch (msg) { case "hideall": { let tabs = await browser.tabs.query({ hidden: false }); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js b/browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js index 7fbf185704..e840c0d640 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_hide_update.js @@ -28,7 +28,7 @@ function getExtension() { let tabs = await browser.tabs.query({ url: "http://example.com/" }); let testTab = tabs[0]; - browser.tabs.onUpdated.addListener((tabId, changeInfo, tab) => { + browser.tabs.onUpdated.addListener((tabId, changeInfo) => { if ("hidden" in changeInfo) { browser.test.assertEq(tabId, testTab.id, "correct tab was hidden"); browser.test.assertTrue(changeInfo.hidden, "tab is hidden"); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js index 1a4bbd0c74..374902f2f6 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_insertCSS.js @@ -63,7 +63,7 @@ add_task(async function testExecuteScript() { code: "* { background: rgb(100, 100, 100) !important }", cssOrigin: "author", }) - .then(r => + .then(() => browser.tabs.insertCSS({ code: "* { background: rgb(43, 43, 43) !important }", cssOrigin: "author", @@ -81,7 +81,7 @@ add_task(async function testExecuteScript() { code: "* { background: rgb(100, 100, 100) !important }", cssOrigin: "user", }) - .then(r => + .then(() => browser.tabs.insertCSS({ code: "* { background: rgb(44, 44, 44) !important }", cssOrigin: "author", diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_move_discarded.js b/browser/components/extensions/test/browser/browser_ext_tabs_move_discarded.js index ebee4fbc90..5c7f7e7eb1 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_move_discarded.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_move_discarded.js @@ -49,7 +49,7 @@ add_task(async function move_hidden_discarded_to_window() { // Listener with "urls" filter, regression test for // https://bugzilla.mozilla.org/show_bug.cgi?id=1695346 browser.tabs.onUpdated.addListener( - (tabId, changeInfo, tab) => { + (tabId, changeInfo) => { browser.test.assertTrue(changeInfo.hidden, "tab was hidden"); browser.test.sendMessage("onUpdated_urls_filter"); }, diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_newtab_private.js b/browser/components/extensions/test/browser/browser_ext_tabs_newtab_private.js index 19146fbe42..8855078faa 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_newtab_private.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_newtab_private.js @@ -9,7 +9,7 @@ const NEWTAB_EXTENSION_CONTROLLED = "browser.newtab.extensionControlled"; const NEWTAB_URI = "webext-newtab-1.html"; 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/browser/browser_ext_tabs_onCreated.js b/browser/components/extensions/test/browser/browser_ext_tabs_onCreated.js index b48047abde..0004f60853 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_onCreated.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_onCreated.js @@ -13,7 +13,7 @@ add_task(async function test_onCreated_active() { browser.tabs.remove(tab.id); browser.test.sendMessage("onCreated", tab); }); - browser.tabs.onUpdated.addListener((tabId, changes, tab) => { + browser.tabs.onUpdated.addListener((tabId, changes) => { browser.test.assertEq( '["status"]', JSON.stringify(Object.keys(changes)), diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js b/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js index a59fa21f8a..65c8c349cf 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated.js @@ -267,7 +267,7 @@ add_task(async function test_onUpdated_after_onRemoved() { // If remove happens fast and we never receive onUpdated, that is ok, but // we never want to receive onUpdated after onRemoved. - browser.tabs.onUpdated.addListener(function onUpdated(tabId, changeInfo) { + browser.tabs.onUpdated.addListener(function onUpdated(tabId) { if (!tab || tab.id !== tabId) { return; } @@ -277,7 +277,7 @@ add_task(async function test_onUpdated_after_onRemoved() { ); }); - browser.tabs.onRemoved.addListener((tabId, removedInfo) => { + browser.tabs.onRemoved.addListener(tabId => { if (!tab || tab.id !== tabId) { return; } diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated_filter.js b/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated_filter.js index 83d305e491..ed5cf6c525 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated_filter.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_onUpdated_filter.js @@ -23,7 +23,7 @@ add_task(async function test_filter_url() { let ext_perm = ExtensionTestUtils.loadExtension({ background() { browser.tabs.onUpdated.addListener( - (tabId, changeInfo) => { + () => { browser.test.fail( `received unexpected onUpdated event without tabs permission` ); @@ -73,7 +73,7 @@ add_task(async function test_filter_url_activeTab() { }, background() { browser.tabs.onUpdated.addListener( - (tabId, changeInfo) => { + () => { browser.test.fail( "should only have notification for activeTab, selectedTab is not activeTab" ); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_query.js b/browser/components/extensions/test/browser/browser_ext_tabs_query.js index 099588c701..30c05a4b83 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_query.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_query.js @@ -283,7 +283,7 @@ add_task(async function () { }, background: function () { - browser.test.onMessage.addListener(async msg => { + browser.test.onMessage.addListener(async () => { let tabs = await browser.tabs.query({ active: true }); browser.test.assertEq(tabs.length, 1, "should have one tab"); diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_saveAsPDF.js b/browser/components/extensions/test/browser/browser_ext_tabs_saveAsPDF.js index fdff1dddbf..7e33da8bed 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_saveAsPDF.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_saveAsPDF.js @@ -30,7 +30,7 @@ async function testReturnStatus(expectedStatus) { } let MockFilePicker = SpecialPowers.MockFilePicker; - MockFilePicker.init(window); + MockFilePicker.init(window.browsingContext); if (expectedStatus == "replaced" || expectedStatus == "not_replaced") { MockFilePicker.returnValue = MockFilePicker.returnReplace; @@ -42,7 +42,7 @@ async function testReturnStatus(expectedStatus) { MockFilePicker.displayDirectory = saveDir; - MockFilePicker.showCallback = fp => { + MockFilePicker.showCallback = () => { MockFilePicker.setFiles([saveFile]); MockFilePicker.filterIndex = 0; // *.* - all file extensions }; @@ -126,7 +126,7 @@ async function testFileName(expectedFileName) { } let MockFilePicker = SpecialPowers.MockFilePicker; - MockFilePicker.init(window); + MockFilePicker.init(window.browsingContext); MockFilePicker.returnValue = MockFilePicker.returnOK; diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js b/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js index 8c420c2821..699ab8613a 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_sendMessage.js @@ -19,7 +19,7 @@ add_task(async function tabsSendMessageReply() { background: async function () { let firstTab; let promiseResponse = new Promise(resolve => { - browser.runtime.onMessage.addListener((msg, sender, respond) => { + browser.runtime.onMessage.addListener((msg, sender) => { if (msg == "content-script-ready") { let tabId = sender.tab.id; @@ -265,7 +265,7 @@ add_task(async function tabsSendHidden() { background: async function () { let resolveContent; - browser.runtime.onMessage.addListener((msg, sender) => { + browser.runtime.onMessage.addListener(msg => { if (msg[0] == "content-ready") { resolveContent(msg[1]); } @@ -327,7 +327,7 @@ add_task(async function tabsSendHidden() { // properties of the possibly-hidden content window. let href = window.location.href; - browser.runtime.onMessage.addListener((msg, sender) => { + browser.runtime.onMessage.addListener(msg => { browser.test.assertEq( href, msg, diff --git a/browser/components/extensions/test/browser/browser_ext_tabs_sharingState.js b/browser/components/extensions/test/browser/browser_ext_tabs_sharingState.js index 47f2006307..86e6af2d6e 100644 --- a/browser/components/extensions/test/browser/browser_ext_tabs_sharingState.js +++ b/browser/components/extensions/test/browser/browser_ext_tabs_sharingState.js @@ -59,7 +59,7 @@ add_task(async function test_tabs_mediaIndicators() { tabs = await browser.tabs.query({ hidden: true }); browser.test.assertEq(tabs.length, 0, "unable to hide sharing tab"); - browser.tabs.onUpdated.addListener(async (tabId, changeInfo, tab) => { + browser.tabs.onUpdated.addListener(async (tabId, changeInfo) => { if (testTab.id !== tabId) { return; } diff --git a/browser/components/extensions/test/browser/browser_ext_webRequest_error_after_stopped_or_closed.js b/browser/components/extensions/test/browser/browser_ext_webRequest_error_after_stopped_or_closed.js index 75d85dd3bf..e14a498cd3 100644 --- a/browser/components/extensions/test/browser/browser_ext_webRequest_error_after_stopped_or_closed.js +++ b/browser/components/extensions/test/browser/browser_ext_webRequest_error_after_stopped_or_closed.js @@ -88,7 +88,7 @@ async function runTest(stopLoadFunc) { * our request. */ add_task(async function test_click_stop_button() { - await runTest(async slowTab => { + await runTest(async () => { // Stop the load let stopButton = document.getElementById("stop-button"); await TestUtils.waitForCondition(() => { diff --git a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js index 83fda199b7..9b7aea478a 100644 --- a/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js +++ b/browser/components/extensions/test/browser/browser_ext_windows_create_tabId.js @@ -34,8 +34,7 @@ add_task(async function testWindowCreate() { return new Promise(resolve => { browser.tabs.onUpdated.addListener(function listener( tabId, - changeInfo, - tab + changeInfo ) { if (changeInfo.url === expected) { browser.tabs.onUpdated.removeListener(listener); diff --git a/browser/components/extensions/test/browser/browser_ext_windows_update.js b/browser/components/extensions/test/browser/browser_ext_windows_update.js index 7331b2c0cc..663f7a54d7 100644 --- a/browser/components/extensions/test/browser/browser_ext_windows_update.js +++ b/browser/components/extensions/test/browser/browser_ext_windows_update.js @@ -260,7 +260,7 @@ add_task(async function testPositionBoundaryCheck() { const extension = ExtensionTestUtils.loadExtension({ async background() { function waitMessage() { - return new Promise((resolve, reject) => { + return new Promise(resolve => { const onMessage = message => { if (message == "continue") { browser.test.onMessage.removeListener(onMessage); @@ -309,7 +309,7 @@ add_task(async function testPositionBoundaryCheck() { }, }); - const promisedWin = new Promise((resolve, reject) => { + const promisedWin = new Promise(resolve => { const windowListener = (window, topic) => { if (topic == "domwindowopened") { Services.ww.unregisterNotification(windowListener); diff --git a/browser/components/extensions/test/browser/browser_unified_extensions_overflowable_toolbar.js b/browser/components/extensions/test/browser/browser_unified_extensions_overflowable_toolbar.js index 9758a96636..2082bc29a9 100644 --- a/browser/components/extensions/test/browser/browser_unified_extensions_overflowable_toolbar.js +++ b/browser/components/extensions/test/browser/browser_unified_extensions_overflowable_toolbar.js @@ -217,7 +217,7 @@ async function withWindowOverflowed( return this._deferred.promise; }, - onWidgetAdded(widgetID, area) { + onWidgetAdded(widgetID) { if (widgetID.endsWith("-browser-action")) { this._remainingBrowserActions--; } @@ -263,7 +263,7 @@ async function withWindowOverflowed( return this._deferred.promise; }, - onWidgetOverflow(widgetNode, areaNode) { + onWidgetOverflow() { this._remainingOverflowables--; if (!this._remainingOverflowables) { this._deferred.resolve(); @@ -489,7 +489,7 @@ add_task(async function test_context_menu() { let win = await BrowserTestUtils.openNewBrowserWindow(); await withWindowOverflowed(win, { - whenOverflowed: async (defaultList, unifiedExtensionList, extensionIDs) => { + whenOverflowed: async (defaultList, unifiedExtensionList) => { Assert.ok( unifiedExtensionList.children.length, "Should have items in the Unified Extension list." @@ -587,7 +587,7 @@ add_task(async function test_message_deck() { let win = await BrowserTestUtils.openNewBrowserWindow(); await withWindowOverflowed(win, { - whenOverflowed: async (defaultList, unifiedExtensionList, extensionIDs) => { + whenOverflowed: async (defaultList, unifiedExtensionList) => { Assert.ok( unifiedExtensionList.children.length, "Should have items in the Unified Extension list." @@ -825,7 +825,7 @@ add_task(async function test_pinning_to_toolbar_when_overflowed() { "expected no .toolbarbutton-1 CSS class on the menu button in the panel" ); }, - whenOverflowed: async (defaultList, unifiedExtensionList, extensionIDs) => { + whenOverflowed: async (defaultList, unifiedExtensionList) => { ok( actionButton.classList.contains("subviewbutton"), "expected .subviewbutton CSS class on the action button in the panel" @@ -893,7 +893,7 @@ add_task(async function test_unpin_overflowed_widget() { let extensionID; await withWindowOverflowed(win, { - whenOverflowed: async (defaultList, unifiedExtensionList, extensionIDs) => { + whenOverflowed: async (defaultList, unifiedExtensionList) => { const firstExtensionWidget = unifiedExtensionList.children[0]; Assert.ok(firstExtensionWidget, "expected an extension widget"); extensionID = firstExtensionWidget.dataset.extensionid; @@ -1120,7 +1120,7 @@ add_task(async function test_overflow_with_a_second_window() { "expected no .subviewbutton CSS class on the menu button in the second window" ); }, - whenOverflowed: async (defaultList, unifiedExtensionList, extensionIDs) => { + whenOverflowed: async () => { // The DOM node should have been overflowed. Assert.ok( aNode.hasAttribute("overflowedItem"), @@ -1356,7 +1356,7 @@ add_task(async function test_overflowed_extension_cannot_be_moved() { let extensionID; await withWindowOverflowed(win, { - whenOverflowed: async (defaultList, unifiedExtensionList, extensionIDs) => { + whenOverflowed: async (defaultList, unifiedExtensionList) => { const secondExtensionWidget = unifiedExtensionList.children[1]; Assert.ok(secondExtensionWidget, "expected an extension widget"); extensionID = secondExtensionWidget.dataset.extensionid; diff --git a/browser/components/extensions/test/browser/head.js b/browser/components/extensions/test/browser/head.js index 02f905d05c..344eb3cca7 100644 --- a/browser/components/extensions/test/browser/head.js +++ b/browser/components/extensions/test/browser/head.js @@ -169,7 +169,7 @@ function promiseAnimationFrame(win = window) { function promisePopupHidden(popup) { return new Promise(resolve => { - let onPopupHidden = event => { + let onPopupHidden = () => { popup.removeEventListener("popuphidden", onPopupHidden); resolve(); }; @@ -323,7 +323,7 @@ var awaitExtensionPanel = function (extension, win = window, awaitLoad = true) { return AppUiTestDelegate.awaitExtensionPanel(win, extension.id, awaitLoad); }; -function getCustomizableUIPanelID(win = window) { +function getCustomizableUIPanelID() { return CustomizableUI.AREA_ADDONS; } @@ -605,7 +605,7 @@ async function openChromeContextMenu(menuId, target, win = window) { return menu; } -async function openSubmenu(submenuItem, win = window) { +async function openSubmenu(submenuItem) { const submenu = submenuItem.menupopup; const shown = BrowserTestUtils.waitForEvent(submenu, "popupshown"); submenuItem.openMenu(true); @@ -763,7 +763,7 @@ function closePageAction(extension, win = window) { } function promisePrefChangeObserved(pref) { - return new Promise((resolve, reject) => + return new Promise(resolve => Preferences.observe(pref, function prefObserver() { Preferences.ignore(pref, prefObserver); resolve(); diff --git a/browser/components/extensions/test/browser/search-engines/search-config-v2.json b/browser/components/extensions/test/browser/search-engines/search-config-v2.json new file mode 100644 index 0000000000..a696b26a75 --- /dev/null +++ b/browser/components/extensions/test/browser/search-engines/search-config-v2.json @@ -0,0 +1,97 @@ +{ + "data": [ + { + "recordType": "engine", + "identifier": "basic", + "base": { + "name": "basic", + "urls": { + "search": { + "base": "https://mochi.test:8888/browser/browser/components/search/test/browser/", + "params": [ + { + "name": "foo", + "value": "1" + } + ], + "searchTermParamName": "search" + }, + "suggestions": { + "base": "https://mochi.test:8888/browser/browser/modules/test/browser/usageTelemetrySearchSuggestions.sjs", + "searchTermParamName": "q" + } + } + }, + "variants": [ + { + "environment": { "allRegionsAndLocales": true } + } + ] + }, + { + "recordType": "engine", + "identifier": "simple", + "base": { + "name": "Simple Engine", + "urls": { + "search": { + "base": "https://example.com", + "params": [ + { + "name": "sourceId", + "value": "Mozilla-search" + } + ], + "searchTermParamName": "search" + }, + "suggestions": { + "base": "https://example.com", + "searchTermParamName": "search" + } + } + }, + "variants": [ + { + "environment": { "allRegionsAndLocales": true } + } + ] + }, + { + "recordType": "engine", + "identifier": "another", + "base": { + "name": "another", + "urls": { + "search": { + "base": "https://mochi.test:8888/browser/browser/components/search/test/browser/", + "params": [ + { + "name": "bar", + "value": "1" + } + ], + "searchTermParamName": "search" + }, + "suggestions": { + "base": "https://mochi.test:8888/browser/browser/modules/test/browser/usageTelemetrySearchSuggestions.sjs", + "searchTermParamName": "q" + } + } + }, + "variants": [ + { + "environment": { "allRegionsAndLocales": true } + } + ] + }, + { + "recordType": "defaultEngines", + "globalDefault": "basic", + "specificDefaults": [] + }, + { + "recordType": "engineOrders", + "orders": [] + } + ] +} 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" ); } |