Bug 1295894 - Show localized strings for browserAction/pageAction title. r=kmag, a=gchang
authorHector Zhao <bzhao@mozilla.com>
Wed, 17 Aug 2016 14:39:33 +0800
changeset 349929 5eb305dd00ae7a6f949727e7a1c82d11e5310f21
parent 349928 5e9947ac9881a64256dd518ec8352f206fd0e68a
child 349930 295ba38f59c87aa0ece0a187e403e71adcf5c9b7
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, gchang
bugs1295894
milestone50.0a2
Bug 1295894 - Show localized strings for browserAction/pageAction title. r=kmag, a=gchang MozReview-Commit-ID: 1SMd3cnUOH4
browser/components/extensions/test/browser/browser_ext_pageAction_context.js
toolkit/components/extensions/Extension.jsm
--- a/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
+++ b/browser/components/extensions/test/browser/browser_ext_pageAction_context.js
@@ -126,22 +126,26 @@ function* runTests(options) {
           extension.sendMessage("runTests");
         });
       } else {
         resolve();
       }
     });
   });
 
+  yield SpecialPowers.pushPrefEnv({set: [["general.useragent.locale", "es-ES"]]});
+
   yield extension.startup();
 
   yield awaitFinish;
 
   yield extension.unload();
 
+  yield SpecialPowers.popPrefEnv();
+
   let node = document.getElementById(pageActionId);
   is(node, null, "pageAction image removed from document");
 
   currentWindow = null;
   for (let win of windows.splice(0)) {
     node = win.document.getElementById(pageActionId);
     is(node, null, "pageAction image removed from second document");
 
@@ -173,35 +177,47 @@ add_task(function* testTabSwitchContext(
         },
 
         "title": {
           "message": "Title",
           "description": "Title",
         },
       },
 
+      "_locales/es_ES/messages.json": {
+        "popup": {
+          "message": "default.html",
+          "description": "Popup",
+        },
+
+        "title": {
+          "message": "T\u00edtulo",
+          "description": "Title",
+        },
+      },
+
       "default.png": imageBuffer,
       "1.png": imageBuffer,
       "2.png": imageBuffer,
     },
 
     getTests(tabs) {
       let details = [
         {"icon": browser.runtime.getURL("default.png"),
          "popup": browser.runtime.getURL("default.html"),
-         "title": "Default Title \u263a"},
+         "title": "Default T\u00edtulo \u263a"},
         {"icon": browser.runtime.getURL("1.png"),
          "popup": browser.runtime.getURL("default.html"),
-         "title": "Default Title \u263a"},
+         "title": "Default T\u00edtulo \u263a"},
         {"icon": browser.runtime.getURL("2.png"),
          "popup": browser.runtime.getURL("2.html"),
          "title": "Title 2"},
         {"icon": browser.runtime.getURL("2.png"),
          "popup": browser.runtime.getURL("2.html"),
-         "title": "Default Title \u263a"},
+         "title": "Default T\u00edtulo \u263a"},
       ];
 
       let promiseTabLoad = details => {
         return new Promise(resolve => {
           browser.tabs.onUpdated.addListener(function listener(tabId, changed) {
             if (tabId == details.id && changed.url == details.url) {
               browser.tabs.onUpdated.removeListener(listener);
               resolve();
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -891,17 +891,17 @@ ExtensionData.prototype = {
         logError: error => {
           this.logger.warn(`Loading extension '${this.id}': Reading manifest: ${error}`);
         },
 
         preprocessors: {},
       };
 
       if (this.localeData) {
-        context.preprocessors.localize = this.localize.bind(this);
+        context.preprocessors.localize = (value, context) => this.localize(value);
       }
 
       let normalized = Schemas.normalize(this.manifest, "manifest.WebExtensionManifest", context);
       if (normalized.error) {
         this.manifestError(normalized.error);
       } else {
         this.manifest = normalized.value;
       }
@@ -1524,11 +1524,11 @@ Extension.prototype = extend(Object.crea
     }
   },
 
   hasPermission(perm) {
     return this.permissions.has(perm);
   },
 
   get name() {
-    return this.localize(this.manifest.name);
+    return this.manifest.name;
   },
 });