зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1544525 - Update about:addons's AMO title; r=Pike,JanH
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 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
2fb90cc7cb
Коммит
d90041e847
|
@ -9,6 +9,7 @@
|
|||
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";
|
||||
|
@ -261,13 +262,34 @@ var Addons = {
|
|||
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);
|
||||
|
|
|
@ -8,6 +8,8 @@ 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
|
||||
addon.options=Options
|
||||
|
|
|
@ -34,6 +34,9 @@ public class StringHelper {
|
|||
// 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";
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.mozilla.gecko.tests;
|
|||
|
||||
import org.json.JSONObject;
|
||||
import org.mozilla.gecko.Actions;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
|
||||
import android.util.DisplayMetrics;
|
||||
|
||||
|
@ -21,7 +22,9 @@ 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();
|
||||
|
||||
|
@ -31,13 +34,20 @@ public class testAddonManager extends PixelTest {
|
|||
// 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);
|
||||
|
|
Загрузка…
Ссылка в новой задаче