Backed out changeset ff3a260bd20d (bug 1529001) for l10n-check bustages on a CLOSED TREE.
authorGurzau Raul <rgurzau@mozilla.com>
Tue, 26 Feb 2019 22:51:41 +0200
changeset 519133 db427d696aaac383eb4a61c7357854df6746078c
parent 519132 1d7d1c75a9a561b3356f0ad8183f6d6759728200
child 519134 177cf2f812d59db13ad3f7fde4dfa227fe03de21
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1529001
milestone67.0a1
backs outff3a260bd20df53104c0c419bf7c37d4689fbd66
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Backed out changeset ff3a260bd20d (bug 1529001) for l10n-check bustages on a CLOSED TREE.
browser/extensions/fxmonitor/locale/en-US/strings.properties
browser/extensions/fxmonitor/locales/en-US/fxmonitor.properties
browser/extensions/fxmonitor/locales/jar.mn
browser/extensions/fxmonitor/locales/moz.build
browser/extensions/fxmonitor/moz.build
browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm
browser/locales/l10n.ini
browser/locales/l10n.toml
rename from browser/extensions/fxmonitor/locales/en-US/fxmonitor.properties
rename to browser/extensions/fxmonitor/locale/en-US/strings.properties
deleted file mode 100644
--- a/browser/extensions/fxmonitor/locales/jar.mn
+++ /dev/null
@@ -1,8 +0,0 @@
-#filter substitution
-# 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/.
-
-[features/fxmonitor@mozilla.org] @AB_CD@.jar:
-% locale fxmonitor @AB_CD@ %locale/@AB_CD@/
-  locale/@AB_CD@/fxmonitor.properties (%fxmonitor.properties)
deleted file mode 100644
--- a/browser/extensions/fxmonitor/locales/moz.build
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- Mode: python; indent-tabs-mode: nil; tab-width: 40 -*-
-# vim: set filetype=python:
-# 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/.
-
-JAR_MANIFESTS += ['jar.mn']
--- a/browser/extensions/fxmonitor/moz.build
+++ b/browser/extensions/fxmonitor/moz.build
@@ -2,18 +2,16 @@
 # vim: set filetype=python:
 # 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/.
 
 DEFINES['MOZ_APP_VERSION'] = CONFIG['MOZ_APP_VERSION']
 DEFINES['MOZ_APP_MAXVERSION'] = CONFIG['MOZ_APP_MAXVERSION']
 
-DIRS += ['locales']
-
 FINAL_TARGET_FILES.features['fxmonitor@mozilla.org'] += [
   'background.js',
   'manifest.json'
 ]
 
 FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['assets'] += [
   'assets/alert.svg',
   'assets/monitor32.svg'
@@ -27,10 +25,14 @@ FINAL_TARGET_FILES.features['fxmonitor@m
 ]
 
 FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['privileged']['subscripts'] += [
   'privileged/subscripts/EveryWindow.jsm',
   'privileged/subscripts/Globals.jsm',
   'privileged/subscripts/PanelUI.jsm'
 ]
 
+FINAL_TARGET_FILES.features['fxmonitor@mozilla.org']['locale']['en-US'] += [
+  'locale/en-US/strings.properties'
+]
+
 with Files('**'):
   BUG_COMPONENT = ('Firefox', 'Firefox Monitor')
--- a/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm
+++ b/browser/extensions/fxmonitor/privileged/FirefoxMonitor.jsm
@@ -17,18 +17,17 @@ this.FirefoxMonitor = {
 
   // Reference to the extension object from the WebExtension context.
   // Used for getting URIs for resources packaged in the extension.
   extension: null,
 
   // Whether we've started observing for the user visiting a breached site.
   observerAdded: false,
 
-  // This is here for documentation, will be redefined to a lazy getter
-  // that creates and returns a string bundle in loadStrings().
+  // loadStrings loads a stringbundle into this property.
   strings: null,
 
   // This is here for documentation, will be redefined to a pref getter
   // using XPCOMUtils.defineLazyPreferenceGetter in init().
   enabled: null,
 
   kEnabledPref: "extensions.fxmonitor.enabled",
 
@@ -79,16 +78,17 @@ this.FirefoxMonitor = {
       }
     );
 
     if (this.enabled) {
       this.startObserving();
     }
   },
 
+
   // Used to enforce idempotency of delayedInit. delayedInit is
   // called in startObserving() to ensure we load our strings, etc.
   _delayedInited: false,
   async delayedInit() {
     if (this._delayedInited) {
       return;
     }
 
@@ -140,37 +140,37 @@ this.FirefoxMonitor = {
       this.kFirstAlertShownPref, false);
 
     await this.loadStrings();
     await this.loadBreaches();
 
     this._delayedInited = true;
   },
 
-  loadStrings() {
-    let l10nManifest;
-    if (this.extension.rootURI instanceof Ci.nsIJARURI) {
-      l10nManifest = this.extension.rootURI.JARFile
-                            .QueryInterface(Ci.nsIFileURL).file;
-    } else if (this.extension.rootURI instanceof Ci.nsIFileURL) {
-      l10nManifest = this.extension.rootURI.file;
+  async loadStrings() {
+    // Services.strings.createBundle has a whitelist of URL schemes that it
+    // accepts. moz-extension: is not one of them, so we work around that
+    // by reading the file manually and creating a data: URL (allowed).
+    let response;
+    let locale = Services.locale.defaultLocale;
+    try {
+      response = await fetch(this.getURL(`locale/${locale}/strings.properties`));
+    } catch (e) {
+      Cu.reportError(`Firefox Monitor: no strings available for ${locale}. Falling back to en-US.`);
+      response = await fetch(this.getURL(`locale/en-US/strings.properties`));
     }
-
-    if (l10nManifest) {
-      Components.manager.addBootstrappedManifestLocation(l10nManifest);
-
-      XPCOMUtils.defineLazyGetter(this, "strings", () => {
-        return Services.strings.createBundle(
-          "chrome://fxmonitor/locale/fxmonitor.properties");
-      });
-    } else {
-      // Something is very strange if we reach this line, so we throw
-      // in order to prevent init from completing and burst the stack.
-      throw "Cannot find fxmonitor chrome.manifest for registering translated strings";
+    let buffer = await response.arrayBuffer();
+    let binary = "";
+    let bytes = new Uint8Array(buffer);
+    let len = bytes.byteLength;
+    for (let i = 0; i < len; i++) {
+      binary += String.fromCharCode(bytes[i]);
     }
+    let b64 = btoa(binary);
+    this.strings = Services.strings.createBundle(`data:text/plain;base64,${b64}`);
   },
 
   kRemoteSettingsKey: "fxmonitor-breaches",
   async loadBreaches() {
     let populateSites = (data) => {
       this.domainMap.clear();
       data.forEach(site => {
         if (!site.Domain || !site.Name || !site.PwnCount || !site.BreachDate || !site.AddedDate) {
--- a/browser/locales/l10n.ini
+++ b/browser/locales/l10n.ini
@@ -8,17 +8,16 @@ all = browser/locales/all-locales
 
 [compare]
 dirs = browser
      other-licenses/branding/firefox
      browser/branding/official
      devtools/client
      devtools/startup
      browser/extensions/formautofill
-     browser/extensions/fxmonitor
      browser/extensions/webcompat-reporter
 
 [includes]
 # non-central apps might want to use %(topsrcdir)s here, or other vars
 # RFE: that needs to be supported by compare-locales, too, though
 toolkit = toolkit/locales/l10n.ini
 services_sync = services/sync/locales/l10n.ini
 
--- a/browser/locales/l10n.toml
+++ b/browser/locales/l10n.toml
@@ -124,20 +124,16 @@ locales = [
     reference = "browser/branding/official/locales/en-US/**"
     l10n = "{l}browser/branding/official/**"
 
 [[paths]]
     reference = "browser/extensions/formautofill/locales/en-US/**"
     l10n = "{l}browser/extensions/formautofill/**"
 
 [[paths]]
-    reference = "browser/extensions/fxmonitor/locales/en-US/**"
-    l10n = "{l}browser/extensions/fxmonitor/**"
-
-[[paths]]
     reference = "browser/extensions/webcompat-reporter/locales/en-US/**"
     l10n = "{l}browser/extensions/webcompat-reporter/**"
 
 [[paths]]
     reference = "services/sync/locales/en-US/**"
     l10n = "{l}services/sync/**"