Bug 1544525 - Update about:addons's AMO title; r=Pike,JanH a=pascalc l10n=flod
authorPetru Lingurar <petru.lingurar@softvision.ro>
Fri, 19 Apr 2019 07:14:54 +0000
changeset 523301 ec55d1e895f99a9cc3085d2bcf54dc962abdbdcc
parent 523300 b73974383bce7dd7bddb7f59a371ff766a1f4369
child 523302 d9dcd33ef48b1322bb19956d35baf72083e7fcca
push id11138
push userarchaeopteryx@coole-files.de
push dateTue, 23 Apr 2019 19:02:09 +0000
treeherdermozilla-beta@c53e3fd76964 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPike, JanH, pascalc
bugs1544525
milestone67.0
Bug 1544525 - Update about:addons's AMO title; r=Pike,JanH a=pascalc l10n=flod And ensure we will always show a localized title, even if we have to fallback to the old already localized one. Differential Revision: https://phabricator.services.mozilla.com/D27858
mobile/android/chrome/content/aboutAddons.js
mobile/android/locales/en-US/chrome/aboutAddons.properties
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/StringHelper.java
mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAddonManager.java
--- a/mobile/android/chrome/content/aboutAddons.js
+++ b/mobile/android/chrome/content/aboutAddons.js
@@ -4,16 +4,17 @@
 
 "use strict";
 
 /* globals gChromeWin */
 
 const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm");
 const {AddonManager} = ChromeUtils.import("resource://gre/modules/AddonManager.jsm");
 const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
+const {EventDispatcher} = ChromeUtils.import("resource://gre/modules/Messaging.jsm");
 
 const AMO_ICON = "chrome://browser/skin/images/amo-logo.png";
 const UPDATE_INDICATOR = "chrome://browser/skin/images/extension-update.svg";
 
 var gStringBundle = Services.strings.createBundle("chrome://browser/locale/aboutAddons.properties");
 
 XPCOMUtils.defineLazyGetter(window, "gChromeWin", function() {
   return window.docShell.rootTreeItem.domWindow
@@ -256,23 +257,44 @@ var Addons = {
     outer.appendChild(img);
 
     let inner = document.createElement("div");
     inner.className = "inner";
 
     let title = document.createElement("div");
     title.id = "browse-title";
     title.className = "title";
-    title.textContent = gStringBundle.GetStringFromName("addons.browseAll");
+    title.textContent = this._getAmoTitle();
     inner.appendChild(title);
 
     outer.appendChild(inner);
     return outer;
   },
 
+  // Ensure we get a localized string by using the previous title as a fallback
+  // if the new one has not yet been translated.
+  _getAmoTitle: function _getAmoTitle() {
+    const initialTitleUS = "Browse all Firefox Add-ons";
+    const updatedTitleUS = "Browse Firefox’s Recommended Extensions";
+    const initialTitleLocalized = gStringBundle.GetStringFromName("addons.browseAll");
+    const updatedTitleLocalized = gStringBundle.GetStringFromName("addons.browseRecommended");
+    let title = initialTitleLocalized;
+
+    const titleWasLocalized = updatedTitleLocalized !== updatedTitleUS;
+    const localeIsDefaultUS = updatedTitleLocalized === updatedTitleUS &&
+                              initialTitleLocalized === initialTitleUS;
+
+    if (titleWasLocalized || localeIsDefaultUS) {
+        title = updatedTitleLocalized;
+    }
+
+    EventDispatcher.instance.dispatch("about:addons", {amoTitle: title} );
+    return title;
+  },
+
   _createItemForAddon: function _createItemForAddon(aAddon) {
     let opType = this._getOpTypeForOperations(aAddon.pendingOperations);
     let hasUpdate = this._addonHasUpdate(aAddon);
 
     let optionsURL = aAddon.optionsURL || "";
 
     let blocked = "";
     switch (aAddon.blocklistState) {
--- a/mobile/android/locales/en-US/chrome/aboutAddons.properties
+++ b/mobile/android/locales/en-US/chrome/aboutAddons.properties
@@ -3,11 +3,13 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 addonType.extension=Extension
 addonType.theme=Theme
 addonType.locale=Locale
 
 addonStatus.uninstalled=%S will be uninstalled after restart.
 
+# Will keep both strings and at runtime will fallback on the old one if the new one is not yet localized
 addons.browseAll=Browse all Firefox Add-ons
+addons.browseRecommended=Browse Firefox’s Recommended Extensions
 
-addon.options=Options
\ No newline at end of file
+addon.options=Options
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/StringHelper.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/StringHelper.java
@@ -29,16 +29,19 @@ public class StringHelper {
     public final String ABOUT_FIREFOX_URL;
     public final String ABOUT_HOME_URL = "about:home";
     public final String ABOUT_ADDONS_URL = "about:addons";
     public final String ABOUT_SCHEME = "about:";
 
     // About pages' titles
     public final String ABOUT_HOME_TITLE = "";
 
+    // To be kept in sync with 'addons.browseRecommended' from 'aboutAddons.properties'
+    public final String ABOUT_ADDONS_AMO_TITLE = "Browse Firefox’s Recommended Extensions";
+
     // Context Menu item strings
     public final String CONTEXT_MENU_BOOKMARK_LINK = "Bookmark Link";
     public final String CONTEXT_MENU_OPEN_LINK_IN_NEW_TAB = "Open Link in New Tab";
     public final String CONTEXT_MENU_OPEN_IN_NEW_TAB;
     public final String CONTEXT_MENU_OPEN_LINK_IN_PRIVATE_TAB = "Open Link in Private Tab";
     public final String CONTEXT_MENU_OPEN_IN_PRIVATE_TAB;
     public final String CONTEXT_MENU_COPY_LINK = "Copy Link";
     public final String CONTEXT_MENU_SHARE_LINK = "Share Link";
--- a/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAddonManager.java
+++ b/mobile/android/tests/browser/robocop/src/org/mozilla/gecko/tests/testAddonManager.java
@@ -1,48 +1,58 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 package org.mozilla.gecko.tests;
 
 import org.json.JSONObject;
 import org.mozilla.gecko.Actions;
+import org.mozilla.gecko.util.GeckoBundle;
 
 import android.util.DisplayMetrics;
 
 /**
  * This test performs the following steps to check the behavior of the Add-on Manager:
  *
  * 1) Open the Add-on Manager from the Add-ons menu item, and then close it.
  * 2) Open the Add-on Manager by visiting about:addons in the URL bar.
  * 3) Open a new tab, select the Add-ons menu item, then verify that the existing
  *    Add-on Manager tab was selected, instead of opening a new tab.
  */
 public class testAddonManager extends PixelTest  {
     public void testAddonManager() {
         Actions.EventExpecter tabEventExpecter;
         Actions.EventExpecter contentEventExpecter;
+        Actions.EventExpecter amoTitleExpecter;
         final String aboutAddonsURL = mStringHelper.ABOUT_ADDONS_URL;
+        final String amoTitle = mStringHelper.ABOUT_ADDONS_AMO_TITLE;
 
         blockForGeckoReady();
 
         // Use the menu to open the Addon Manger
         selectMenuItem(mStringHelper.ADDONS_LABEL);
 
         // Set up listeners to catch the page load we're about to do
         tabEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Tab:Added");
         contentEventExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "Content:DOMContentLoaded");
+        amoTitleExpecter = mActions.expectGlobalEvent(Actions.EventType.UI, "about:addons");
 
         // Wait for the new tab and page to load
         tabEventExpecter.blockForEvent();
         contentEventExpecter.blockForEvent();
+        GeckoBundle addonsPageBundle = amoTitleExpecter.blockForBundle();
 
         tabEventExpecter.unregisterListener();
         contentEventExpecter.unregisterListener();
+        amoTitleExpecter.unregisterListener();
+
+        // Verify the AMO title
+        final String actualAmoTitle = addonsPageBundle.getString("amoTitle");
+        mAsserter.is(actualAmoTitle, amoTitle, "Incorrect AMO title");
 
         // Verify the url
         verifyUrlBarTitle(aboutAddonsURL);
 
         // Close the Add-on Manager
         mSolo.goBack();
 
         // Load the about:addons page and verify it was loaded