From d9f57391095d922589b90d7fc8843a9bd5ba1d37 Mon Sep 17 00:00:00 2001 From: Mark Striemer Date: Fri, 1 Nov 2019 16:26:32 +0000 Subject: [PATCH] Bug 1525175 - Part 1: Convert about:addons header to HTML r=rpl,fluent-reviewers,flod Differential Revision: https://phabricator.services.mozilla.com/D43610 --HG-- rename : toolkit/mozapps/extensions/test/browser/browser_bug567127.js => toolkit/mozapps/extensions/test/browser/browser_page_options_install_addon.js rename : toolkit/mozapps/extensions/test/browser/browser_bug570760.js => toolkit/mozapps/extensions/test/browser/browser_search_bar_focus.js extra : moz-landing-system : lando --- .../browser_permissions_local_file.js | 9 +- .../browser_update_checkForUpdates.js | 2 +- .../browser_update_interactive_noprompt.js | 4 +- .../base/content/test/webextensions/head.js | 30 +- .../bug_1525175_about_addons_header.py | 81 +++ .../mozapps/extensions/extensions.properties | 3 - .../en-US/toolkit/about/aboutAddons.ftl | 74 +-- toolkit/modules/BrowserUtils.jsm | 3 + .../extensions/content/aboutaddons.css | 81 ++- .../extensions/content/aboutaddons.html | 58 +- .../mozapps/extensions/content/aboutaddons.js | 594 +++++++++++++++++- .../extensions/content/aboutaddonsCommon.js | 51 +- .../mozapps/extensions/content/extensions.js | 483 +------------- .../mozapps/extensions/content/extensions.xul | 96 +-- .../mozapps/extensions/content/panel-item.css | 4 + .../extensions/test/browser/browser.ini | 9 +- .../browser/browser_about_debugging_link.js | 28 +- .../test/browser/browser_bug570760.js | 42 -- .../test/browser/browser_bug586574.js | 368 ----------- .../test/browser/browser_html_detail_view.js | 4 +- .../browser/browser_html_discover_view.js | 7 +- .../browser/browser_html_recent_updates.js | 16 +- .../test/browser/browser_html_updates.js | 7 +- .../browser/browser_interaction_telemetry.js | 52 +- .../test/browser/browser_manage_shortcuts.js | 19 +- ... => browser_page_options_install_addon.js} | 48 +- .../browser/browser_page_options_updates.js | 163 +++++ .../browser/browser_panel_item_accesskey.js | 100 +++ .../test/browser/browser_recentupdates.js | 105 ---- .../test/browser/browser_search_bar_focus.js | 42 ++ .../browser_shortcuts_duplicate_check.js | 4 +- 31 files changed, 1356 insertions(+), 1231 deletions(-) create mode 100644 python/l10n/fluent_migrations/bug_1525175_about_addons_header.py delete mode 100644 toolkit/mozapps/extensions/test/browser/browser_bug570760.js delete mode 100644 toolkit/mozapps/extensions/test/browser/browser_bug586574.js rename toolkit/mozapps/extensions/test/browser/{browser_bug567127.js => browser_page_options_install_addon.js} (65%) create mode 100644 toolkit/mozapps/extensions/test/browser/browser_page_options_updates.js create mode 100644 toolkit/mozapps/extensions/test/browser/browser_panel_item_accesskey.js delete mode 100644 toolkit/mozapps/extensions/test/browser/browser_recentupdates.js create mode 100644 toolkit/mozapps/extensions/test/browser/browser_search_bar_focus.js diff --git a/browser/base/content/test/webextensions/browser_permissions_local_file.js b/browser/base/content/test/webextensions/browser_permissions_local_file.js index d675979ab0f2..438e917cbb4c 100644 --- a/browser/base/content/test/webextensions/browser_permissions_local_file.js +++ b/browser/base/content/test/webextensions/browser_permissions_local_file.js @@ -14,11 +14,14 @@ async function installFile(filename) { MockFilePicker.setFiles([file]); MockFilePicker.afterOpenCallback = MockFilePicker.cleanup; - await BrowserOpenAddonsMgr("addons://list/extension"); - let contentWin = gBrowser.selectedTab.linkedBrowser.contentWindow; + let managerWin = await BrowserOpenAddonsMgr("addons://list/extension"); // Do the install... - contentWin.gViewController.doCommand("cmd_installFromFile"); + await BrowserTestUtils.waitForEvent(managerWin.document, "ViewChanged"); + let installButton = managerWin + .getHtmlBrowser() + .contentDocument.querySelector('[action="install-from-file"]'); + installButton.click(); } add_task(async function test_install_extension_from_local_file() { diff --git a/browser/base/content/test/webextensions/browser_update_checkForUpdates.js b/browser/base/content/test/webextensions/browser_update_checkForUpdates.js index 298e3b6e0bbc..b902527caef0 100644 --- a/browser/base/content/test/webextensions/browser_update_checkForUpdates.js +++ b/browser/base/content/test/webextensions/browser_update_checkForUpdates.js @@ -1,6 +1,6 @@ // Invoke the "Check for Updates" menu item function checkAll(win) { - win.gViewController.doCommand("cmd_findAllUpdates"); + triggerPageOptionsAction(win, "check-for-updates"); return new Promise(resolve => { let observer = { observe(subject, topic, data) { diff --git a/browser/base/content/test/webextensions/browser_update_interactive_noprompt.js b/browser/base/content/test/webextensions/browser_update_interactive_noprompt.js index 3253ec2205fd..312899e732f6 100644 --- a/browser/base/content/test/webextensions/browser_update_interactive_noprompt.js +++ b/browser/base/content/test/webextensions/browser_update_interactive_noprompt.js @@ -35,6 +35,8 @@ async function testUpdateNoPrompt( // Go to Extensions in about:addons let win = await BrowserOpenAddonsMgr("addons://list/extension"); + await BrowserTestUtils.waitForEvent(win.document, "ViewChanged"); + let sawPopup = false; function popupListener() { sawPopup = true; @@ -43,7 +45,7 @@ async function testUpdateNoPrompt( // Trigger an update check, we should see the update get applied let updatePromise = waitForUpdate(addon); - win.gViewController.doCommand("cmd_findAllUpdates"); + triggerPageOptionsAction(win, "check-for-updates"); await updatePromise; addon = await AddonManager.getAddonByID(id); diff --git a/browser/base/content/test/webextensions/head.js b/browser/base/content/test/webextensions/head.js index 2e85d845bd30..0ba36acb8b47 100644 --- a/browser/base/content/test/webextensions/head.js +++ b/browser/base/content/test/webextensions/head.js @@ -175,6 +175,16 @@ async function waitForUpdate(addon) { return newAddon; } +/** + * Trigger an action from the page options menu. + */ +function triggerPageOptionsAction(win, action) { + win + .getHtmlBrowser() + .contentDocument.querySelector(`#page-options [action="${action}"]`) + .click(); +} + function isDefaultIcon(icon) { // These are basically the same icon, but code within webextensions // generates references to the former and generic add-ons manager code @@ -474,12 +484,20 @@ async function interactiveUpdateTest(autoUpdate, checkFn) { if (manualUpdatePromise) { await manualUpdatePromise; - const availableUpdates = win.document.getElementById( - "updates-manualUpdatesFound-btn" - ); - availableUpdates.click(); let doc = win.getHtmlBrowser().contentDocument; - let card = await BrowserTestUtils.waitForCondition(() => { + if (win.gViewController.currentViewId !== "addons://updates/available") { + let showUpdatesBtn = doc.querySelector("addon-updates-message").button; + await TestUtils.waitForCondition(() => { + return !showUpdatesBtn.hidden; + }, "Wait for show updates button"); + let viewChanged = BrowserTestUtils.waitForEvent( + win.document, + "ViewChanged" + ); + showUpdatesBtn.click(); + await viewChanged; + } + let card = await TestUtils.waitForCondition(() => { return doc.querySelector(`addon-card[addon-id="${ID}"]`); }, `Wait addon card for "${ID}"`); let updateBtn = card.querySelector('panel-item[action="install-update"]'); @@ -504,6 +522,8 @@ async function interactiveUpdateTest(autoUpdate, checkFn) { let win = await BrowserOpenAddonsMgr("addons://list/extension"); + await BrowserTestUtils.waitForEvent(win.document, "ViewChanged"); + // Trigger an update check let popupPromise = promisePopupNotificationShown("addon-webext-permissions"); let { promise: checkPromise } = await triggerUpdate(win, addon); diff --git a/python/l10n/fluent_migrations/bug_1525175_about_addons_header.py b/python/l10n/fluent_migrations/bug_1525175_about_addons_header.py new file mode 100644 index 000000000000..c5418c8994cf --- /dev/null +++ b/python/l10n/fluent_migrations/bug_1525175_about_addons_header.py @@ -0,0 +1,81 @@ + +# Any copyright is dedicated to the Public Domain. +# http://creativecommons.org/publicdomain/zero/1.0/ + +from __future__ import absolute_import +import fluent.syntax.ast as FTL +from fluent.migrate.helpers import transforms_from +from fluent.migrate import COPY_PATTERN, COPY, REPLACE +from fluent.migrate.helpers import TERM_REFERENCE + + +def migrate(ctx): + """Bug 1525175 - Convert about:addons header to HTML, part {index}""" + + ctx.add_transforms( + 'toolkit/toolkit/about/aboutAddons.ftl', + 'toolkit/toolkit/about/aboutAddons.ftl', + transforms_from( +""" +addon-updates-check-for-updates = { COPY_PATTERN(from_path, "extensions-updates-check-for-updates.label") } + .accesskey = { COPY_PATTERN(from_path, "extensions-updates-check-for-updates.accesskey") } +addon-updates-view-updates = { COPY_PATTERN(from_path, "extensions-updates-view-updates.label") } + .accesskey = { COPY_PATTERN(from_path, "extensions-updates-view-updates.accesskey") } +addon-updates-update-addons-automatically = { COPY_PATTERN(from_path, "extensions-updates-update-addons-automatically.label") } + .accesskey = { COPY_PATTERN(from_path, "extensions-updates-update-addons-automatically.accesskey") } +addon-updates-reset-updates-to-automatic = { COPY_PATTERN(from_path, "extensions-updates-reset-updates-to-automatic.label") } + .accesskey = { COPY_PATTERN(from_path, "extensions-updates-reset-updates-to-automatic.accesskey") } +addon-updates-reset-updates-to-manual = { COPY_PATTERN(from_path, "extensions-updates-reset-updates-to-manual.label") } + .accesskey = { COPY_PATTERN(from_path, "extensions-updates-reset-updates-to-manual.accesskey") } +addon-updates-updating = { COPY_PATTERN(from_path, "extensions-updates-updating.value") } +addon-updates-installed = { COPY_PATTERN(from_path, "extensions-updates-installed.value") } +addon-updates-none-found = { COPY_PATTERN(from_path, "extensions-updates-none-found.value") } +addon-updates-manual-updates-found = { COPY_PATTERN(from_path, "extensions-updates-manual-updates-found.label") } +addon-install-from-file = { COPY_PATTERN(from_path, "install-addon-from-file.label") } + .accesskey = { COPY_PATTERN(from_path, "install-addon-from-file.accesskey") } +addon-open-about-debugging = { COPY_PATTERN(from_path, "debug-addons.label") } + .accesskey = { COPY_PATTERN(from_path, "debug-addons.accesskey") } +addon-manage-extensions-shortcuts = { COPY_PATTERN(from_path, "manage-extensions-shortcuts.label") } + .accesskey = { COPY_PATTERN(from_path, "manage-extensions-shortcuts.accesskey") } +addons-heading-search-input = + .placeholder = { COPY_PATTERN(from_path, "search-header.placeholder") } +""" + , from_path='toolkit/toolkit/about/aboutAddons.ftl') + ) + + ctx.add_transforms( + 'toolkit/toolkit/about/aboutAddons.ftl', + 'toolkit/toolkit/about/aboutAddons.ftl', + transforms_from( +""" +addon-install-from-file-dialog-title = { COPY(from_path, "installFromFile.dialogTitle") } +addon-install-from-file-filter-name = { COPY(from_path, "installFromFile.filterName") } +extension-heading = { COPY(from_path, "listHeading.extension") } +theme-heading = { COPY(from_path, "listHeading.theme") } +plugin-heading = { COPY(from_path, "listHeading.plugin") } +dictionary-heading = { COPY(from_path, "listHeading.dictionary") } +locale-heading = { COPY(from_path, "listHeading.locale") } +shortcuts-heading = { COPY(from_path, "listHeading.shortcuts") } +theme-heading-search-label = { COPY(from_path, "searchLabel.theme") } +extension-heading-search-label = { COPY(from_path, "searchLabel.extension") } +""" + , from_path='toolkit/chrome/mozapps/extensions/extensions.properties') + ) + + ctx.add_transforms( + 'toolkit/toolkit/about/aboutAddons.ftl', + 'toolkit/toolkit/about/aboutAddons.ftl', + [ + FTL.Message( + id=FTL.Identifier("discover-heading"), + value=REPLACE( + "toolkit/chrome/mozapps/extensions/extensions.properties", + "listHeading.discover", + { + "%1$S": TERM_REFERENCE("brand-short-name") + }, + normalize_printf=True + ) + ), + ] + ) diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties b/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties index 45cb3aeca081..f579a26a6b76 100644 --- a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties +++ b/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.properties @@ -62,9 +62,6 @@ details.notification.restartless-uninstall=%1$S will be uninstalled after you cl #LOCALIZATION NOTE (details.notification.gmpPending) %1$S is the add-on name details.notification.gmpPending=%1$S will be installed shortly. -installFromFile.dialogTitle=Select add-on to install -installFromFile.filterName=Add-ons - type.extension.name=Extensions type.themes.name=Themes type.locale.name=Languages diff --git a/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl b/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl index 00660774a5a9..16f759132b87 100644 --- a/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl +++ b/toolkit/locales/en-US/toolkit/about/aboutAddons.ftl @@ -30,10 +30,6 @@ list-empty-find-updates = list-empty-button = .label = Learn more about add-ons -install-addon-from-file = - .label = Install Add-on From File… - .accesskey = I - help-button = Add-ons Support preferences = @@ -51,10 +47,6 @@ show-unsigned-extensions-button = show-all-extensions-button = .label = Show all extensions -debug-addons = - .label = Debug Add-ons - .accesskey = b - cmd-show-details = .label = Show More Information .accesskey = S @@ -260,19 +252,15 @@ extensions-warning-update-security-enable = ## Strings connected to add-on updates -extensions-updates-check-for-updates = - .label = Check for Updates +addon-updates-check-for-updates = Check for Updates .accesskey = C - -extensions-updates-view-updates = - .label = View Recent Updates +addon-updates-view-updates = View Recent Updates .accesskey = V # This menu item is a checkbox that toggles the default global behavior for # add-on update checking. -extensions-updates-update-addons-automatically = - .label = Update Add-ons Automatically +addon-updates-update-addons-automatically = Update Add-ons Automatically .accesskey = A ## Specific add-ons can have custom update checking behaviors ("Manually", @@ -281,37 +269,33 @@ extensions-updates-update-addons-automatically = ## (which itself is either "Automatically" or "Manually", controlled by the ## extensions-updates-update-addons-automatically.label menu item). -extensions-updates-reset-updates-to-automatic = - .label = Reset All Add-ons to Update Automatically +addon-updates-reset-updates-to-automatic = Reset All Add-ons to Update Automatically .accesskey = R - -extensions-updates-reset-updates-to-manual = - .label = Reset All Add-ons to Update Manually +addon-updates-reset-updates-to-manual = Reset All Add-ons to Update Manually .accesskey = R ## Status messages displayed when updating add-ons -extensions-updates-updating = - .value = Updating add-ons -extensions-updates-installed = - .value = Your add-ons have been updated. -extensions-updates-downloaded = - .value = Your add-on updates have been downloaded. -extensions-updates-restart = - .label = Restart now to complete installation -extensions-updates-none-found = - .value = No updates found -extensions-updates-manual-updates-found = - .label = View Available Updates -extensions-updates-update-selected = - .label = Install Updates - .tooltiptext = Install available updates in this list +addon-updates-updating = Updating add-ons +addon-updates-installed = Your add-ons have been updated. +addon-updates-none-found = No updates found +addon-updates-manual-updates-found = View Available Updates + +## Add-on install/debug strings for page options menu + +addon-install-from-file = Install Add-on From File… + .accesskey = I +addon-install-from-file-dialog-title = Select add-on to install +addon-install-from-file-filter-name = Add-ons +addon-open-about-debugging = Debug Add-ons + .accesskey = b ## Extension shortcut management -manage-extensions-shortcuts = - .label = Manage Extension Shortcuts +# This is displayed in the page options menu +addon-manage-extensions-shortcuts = Manage Extension Shortcuts .accesskey = S + shortcuts-no-addons = You don’t have any extensions enabled. shortcuts-no-commands = The following extensions do not have shortcuts: shortcuts-input = @@ -494,3 +478,19 @@ recommended-themes-heading = Recommended Themes # A recommendation for the Firefox Color theme shown at the bottom of the theme # list view. The "Firefox Color" name itself should not be translated. recommended-theme-1 = Feeling creative? Build your own theme with Firefox Color. + +## Page headings + +extension-heading = Manage Your Extensions +theme-heading = Manage Your Themes +plugin-heading = Manage Your Plugins +dictionary-heading = Manage Your Dictionaries +locale-heading = Manage Your Languages +updates-heading = Manage Your Updates +discover-heading = Personalize Your { -brand-short-name } +shortcuts-heading = Manage Extension Shortcuts + +theme-heading-search-label = Find more themes +extension-heading-search-label = Find more extensions +addons-heading-search-input = + .placeholder = Search addons.mozilla.org diff --git a/toolkit/modules/BrowserUtils.jsm b/toolkit/modules/BrowserUtils.jsm index 0ee4f78e375e..3547cb696b42 100644 --- a/toolkit/modules/BrowserUtils.jsm +++ b/toolkit/modules/BrowserUtils.jsm @@ -345,6 +345,9 @@ var BrowserUtils = { canFindInPage(location) { return ( !location.startsWith("about:addons") && + !location.startsWith( + "chrome://mozapps/content/extensions/aboutaddons.html" + ) && !location.startsWith("about:preferences") ); }, diff --git a/toolkit/mozapps/extensions/content/aboutaddons.css b/toolkit/mozapps/extensions/content/aboutaddons.css index a174233785fa..474c4aadf449 100644 --- a/toolkit/mozapps/extensions/content/aboutaddons.css +++ b/toolkit/mozapps/extensions/content/aboutaddons.css @@ -1,6 +1,7 @@ :root { --section-width: 664px; --addon-icon-size: 32px; + --z-index-sticky-container: 1; } *|*[hidden] { @@ -15,6 +16,67 @@ body { -moz-user-select: initial; } +.sticky-container { + width: 100%; + position: sticky; + top: 0; + z-index: var(--z-index-sticky-container); + background: var(--in-content-page-background); +} + +.main-search { + display: flex; + justify-content: flex-end; + align-items: center; + padding-inline-start: 28px; + padding-top: 20px; + padding-bottom: 30px; + width: var(--section-width); +} + +search-addons > search-textbox { + margin-inline-end: 0; + width: 20em; +} + +.search-label { + margin-inline-end: 8px; +} + +.main-heading { + display: flex; + margin-inline-start: 28px; + padding-bottom: 16px; + width: var(--section-width); +} + +.spacer { + flex-grow: 1; +} + +#updates-message { + display: flex; + align-items: center; + margin-inline-end: 8px; +} + +.back-button { + -moz-context-properties: fill; + fill: currentColor; + background-image: url("chrome://global/skin/icons/arrow-left.svg"); + background-repeat: no-repeat; + background-position: center; + min-width: auto; + width: 32px; + margin-block: 0; + margin-inline-start: 0; + margin-inline-end: 16px; +} + +.back-button:dir(rtl) { + transform: scaleX(-1); +} + #main { margin-inline-start: 28px; margin-bottom: 28px; @@ -190,6 +252,17 @@ addon-card:not([expanded]) .addon-description { overflow-x: hidden; } +.page-options-menu { + position: relative; + align-self: center; +} + +.page-options-menu > .more-options-button { + background-image: url("chrome://mozapps/skin/extensions/utilities.svg"); + width: 32px; + height: 32px; +} + .more-options-menu { position: relative; /* Add some negative margin to account for the button's padding */ @@ -355,7 +428,9 @@ addon-details { margin: 0; -moz-context-properties: fill; fill: currentColor; - background: url("chrome://global/skin/icons/more.svg") no-repeat center center; + background-image: url("chrome://global/skin/icons/more.svg"); + background-repeat: no-repeat; + background-position: center center; position: relative; } @@ -444,3 +519,7 @@ addon-permissions-list > .addon-detail-row:first-of-type { /* Pull the buttons flush with the side of the card */ margin-inline: calc(var(--card-padding) * -1); } + +panel-list { + font-size: 13px; +} diff --git a/toolkit/mozapps/extensions/content/aboutaddons.html b/toolkit/mozapps/extensions/content/aboutaddons.html index 5a20cbaab198..59787dc2152c 100644 --- a/toolkit/mozapps/extensions/content/aboutaddons.html +++ b/toolkit/mozapps/extensions/content/aboutaddons.html @@ -6,9 +6,11 @@ - + + + @@ -18,14 +20,17 @@ - - - - - - + + + + + + + + + @@ -35,6 +40,40 @@ + + + + - -