diff --git a/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs b/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs index 96862ef07b59..d2e7dcd79795 100644 --- a/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs +++ b/browser/components/urlbar/QuickActionsLoaderDefault.sys.mjs @@ -54,6 +54,13 @@ let openAddonsUrl = url => { }; }; +// There are various actions that will either fail or do not +// make sense to use unless the user is viewing web content, +// Screenshots for example cannot be taken on about: pages. +// We may want to show these as disabled buttons, that may +// aid discovery but may also confuse users. +let currentPageIsWebContentFilter = () => + !currentBrowser()?.currentURI.spec.startsWith("about:"); let currentBrowser = () => lazy.BrowserWindowTracker.getTopWindow()?.gBrowser.selectedBrowser; let currentTab = () => @@ -176,9 +183,7 @@ const DEFAULT_ACTIONS = { l10nCommands: ["quickactions-cmd-screenshot", "quickactions-screenshot3"], label: "quickactions-screenshot3", icon: "chrome://browser/skin/screenshot.svg", - isActive: () => { - return !lazy.BrowserWindowTracker.getTopWindow().gScreenshots.shouldScreenshotsButtonBeDisabled(); - }, + isActive: currentPageIsWebContentFilter, onPick: () => { lazy.BrowserWindowTracker.getTopWindow() .document.getElementById("Browser:Screenshot") diff --git a/browser/components/urlbar/tests/browser/browser_quickactions.js b/browser/components/urlbar/tests/browser/browser_quickactions.js index 826ce3ec12de..6f8244e5c710 100644 --- a/browser/components/urlbar/tests/browser/browser_quickactions.js +++ b/browser/components/urlbar/tests/browser/browser_quickactions.js @@ -214,13 +214,7 @@ add_task(async function test_disabled() { UrlbarProviderQuickActions.removeAction("disabledaction"); }); -/** - * The first part of this test confirms that when the screenshots component is enabled - * the screenshot quick action button will be enabled on about: pages. - * The second part confirms that when the screenshots extension is enabled the - * screenshot quick action button will be disbaled on about: pages. - */ -add_task(async function test_screenshot_enabled_or_disabled() { +add_task(async function test_screenshot_disabled() { let onLoaded = BrowserTestUtils.browserLoaded( gBrowser.selectedBrowser, false, @@ -241,30 +235,6 @@ add_task(async function test_screenshot_enabled_or_disabled() { let screenshotButton = window.document.querySelector( ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-row" ); - Assert.ok( - !screenshotButton.hasAttribute("disabled"), - "Screenshot button is disabled on about pages" - ); - - await UrlbarTestUtils.promisePopupClose(window); - EventUtils.synthesizeKey("KEY_Escape"); - - await SpecialPowers.pushPrefEnv({ - set: [["screenshots.browser.component.enabled", false]], - }); - - await UrlbarTestUtils.promiseAutocompleteResultPopup({ - window, - value: "screenshot", - }); - Assert.equal( - UrlbarTestUtils.getResultCount(window), - 2, - "The action is displayed" - ); - screenshotButton = window.document.querySelector( - ".urlbarView-row[dynamicType=quickactions] .urlbarView-quickaction-row" - ); Assert.equal( screenshotButton.getAttribute("disabled"), "disabled", @@ -273,8 +243,6 @@ add_task(async function test_screenshot_enabled_or_disabled() { await UrlbarTestUtils.promisePopupClose(window); EventUtils.synthesizeKey("KEY_Escape"); - - await SpecialPowers.popPrefEnv(); }); add_task(async function match_in_phrase() {