Backed out changeset 9b44720d645b (bug 1357902) for android xpcshell failures in test_ext_startup_cache.js a=backout
authorWes Kocher <wkocher@mozilla.com>
Mon, 17 Jul 2017 23:28:33 -0700
changeset 418114 4460f088ace5ed0bd03fe079afc8a4331200a9d8
parent 418113 28ad124c24e13f9bfc71ab7eef66e1618f8ff134
child 418115 878fe0c8aa814859489c89b284e4f13c64801831
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1357902
milestone56.0a1
backs out9b44720d645bc7f4d9698ecdc0c7ffbf073b36e6
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 9b44720d645b (bug 1357902) for android xpcshell failures in test_ext_startup_cache.js a=backout MozReview-Commit-ID: KzJWDUsEJoK
browser/components/extensions/test/browser/browser-common.ini
browser/components/extensions/test/browser/head_pageAction.js
browser/components/extensions/test/browser/locale/chrome.manifest
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/ExtensionCommon.jsm
toolkit/components/extensions/test/xpcshell/data/locales/chrome.manifest
toolkit/components/extensions/test/xpcshell/test_ext_i18n.js
toolkit/components/extensions/test/xpcshell/test_ext_i18n_css.js
toolkit/components/extensions/test/xpcshell/test_ext_startup_cache.js
--- a/browser/components/extensions/test/browser/browser-common.ini
+++ b/browser/components/extensions/test/browser/browser-common.ini
@@ -16,17 +16,16 @@ support-files =
   file_iframe_document.sjs
   file_bypass_cache.sjs
   file_language_fr_en.html
   file_language_ja.html
   file_language_tlh.html
   file_dummy.html
   file_inspectedwindow_reload_target.sjs
   file_serviceWorker.html
-  locale/chrome.manifest
   webNav_createdTarget.html
   webNav_createdTargetSource.html
   webNav_createdTargetSource_subframe.html
   serviceWorker.js
   searchSuggestionEngine.xml
   searchSuggestionEngine.sjs
   ../../../../../toolkit/components/extensions/test/mochitest/head_webrequest.js
 
--- a/browser/components/extensions/test/browser/head_pageAction.js
+++ b/browser/components/extensions/test/browser/head_pageAction.js
@@ -1,28 +1,16 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 /* exported runTests */
 // This file is imported into the same scope as head.js.
 /* import-globals-from head.js */
 
-{
-  const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);
-
-  let localeDir = new URL("locale/", gTestPath).href;
-  let {file} = chromeRegistry.convertChromeURL(Services.io.newURI(localeDir)).QueryInterface(Ci.nsIFileURL);
-
-  Components.manager.addBootstrappedManifestLocation(file);
-  registerCleanupFunction(() => {
-    Components.manager.removeBootstrappedManifestLocation(file);
-  });
-}
-
 async function runTests(options) {
   function background(getTests) {
     let tabs;
     let tests;
 
     // Gets the current details of the page action, and returns a
     // promise that resolves to an object containing them.
     async function getDetails() {
deleted file mode 100644
--- a/browser/components/extensions/test/browser/locale/chrome.manifest
+++ /dev/null
@@ -1,1 +0,0 @@
-locale global es-ES resource://gre/chrome/en-US/locale/en-US/global/
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -56,16 +56,18 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionCommon",
                                   "resource://gre/modules/ExtensionCommon.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionPermissions",
                                   "resource://gre/modules/ExtensionPermissions.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionStorage",
                                   "resource://gre/modules/ExtensionStorage.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionTestCommon",
                                   "resource://testing-common/ExtensionTestCommon.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Locale",
+                                  "resource://gre/modules/Locale.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Log",
                                   "resource://gre/modules/Log.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MessageChannel",
                                   "resource://gre/modules/MessageChannel.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
                                   "resource://gre/modules/NetUtil.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
@@ -900,17 +902,17 @@ this.Extension = class extends Extension
     return StartupCache.locales.get([this.id, this.version, locale],
                                     () => super.readLocaleFile(locale))
       .then(result => {
         this.localeData.messages.set(locale, result);
       });
   }
 
   parseManifest() {
-    return StartupCache.manifests.get([this.id, this.version, Services.locale.getAppLocaleAsLangTag()],
+    return StartupCache.manifests.get([this.id, this.version, Locale.getLocale()],
                                       () => super.parseManifest());
   }
 
   loadManifest() {
     return super.loadManifest().then(manifest => {
       if (this.errors.length) {
         return Promise.reject({errors: this.errors});
       }
@@ -1021,22 +1023,22 @@ this.Extension = class extends Extension
 
   // Reads the locale file for the given Gecko-compatible locale code, or if
   // no locale is given, the available locale closest to the UI locale.
   // Sets the currently selected locale on success.
   async initLocale(locale = undefined) {
     if (locale === undefined) {
       let locales = await this.promiseLocales();
 
-      let matches = Services.locale.negotiateLanguages(
-        Services.locale.getAppLocalesAsLangTags(),
-        Array.from(locales.keys()),
-        this.defaultLocale);
+      let localeList = Array.from(locales.keys(), locale => {
+        return {name: locale, locales: [locale]};
+      });
 
-      locale = matches[0];
+      let match = Locale.findClosestLocale(localeList);
+      locale = match ? match.name : this.defaultLocale;
     }
 
     return super.initLocale(locale);
   }
 
   initUnlimitedStoragePermission() {
     const principal = this.principal;
 
--- a/toolkit/components/extensions/ExtensionCommon.jsm
+++ b/toolkit/components/extensions/ExtensionCommon.jsm
@@ -13,16 +13,18 @@ const {classes: Cc, interfaces: Ci, util
 
 /* exported ExtensionCommon */
 
 this.EXPORTED_SYMBOLS = ["ExtensionCommon"];
 
 Cu.import("resource://gre/modules/Services.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
+XPCOMUtils.defineLazyModuleGetter(this, "Locale",
+                                  "resource://gre/modules/Locale.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "MessageChannel",
                                   "resource://gre/modules/MessageChannel.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
                                   "resource://gre/modules/Preferences.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
                                   "resource://gre/modules/PrivateBrowsingUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Schemas",
                                   "resource://gre/modules/Schemas.jsm");
@@ -1235,17 +1237,18 @@ LocaleData.prototype = {
         return str.replace(/\$(?:([1-9]\d*)|(\$+))/g, replacer);
       }
     }
 
     // Check for certain pre-defined messages.
     if (message == "@@ui_locale") {
       return this.uiLocale;
     } else if (message.startsWith("@@bidi_")) {
-      let rtl = Services.locale.isAppLocaleRTL;
+      let registry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIXULChromeRegistry);
+      let rtl = registry.isLocaleRTL("global");
 
       if (message == "@@bidi_dir") {
         return rtl ? "rtl" : "ltr";
       } else if (message == "@@bidi_reversed_dir") {
         return rtl ? "ltr" : "rtl";
       } else if (message == "@@bidi_start_edge") {
         return rtl ? "right" : "left";
       } else if (message == "@@bidi_end_edge") {
@@ -1340,17 +1343,17 @@ LocaleData.prototype = {
     let result = Preferences.get("intl.accept_languages", "", Ci.nsIPrefLocalizedString);
     return result.split(/\s*,\s*/g);
   },
 
 
   get uiLocale() {
     // Return the browser locale, but convert it to a Chrome-style
     // locale code.
-    return Services.locale.getAppLocaleAsBCP47().replace(/-/g, "_");
+    return Locale.getLocale().replace(/-/g, "_");
   },
 };
 
 defineLazyGetter(LocaleData.prototype, "availableLocales", function() {
   return new Set([this.BUILTIN, this.selectedLocale, this.defaultLocale]
                  .filter(locale => this.messages.has(locale)));
 });
 
deleted file mode 100644
--- a/toolkit/components/extensions/test/xpcshell/data/locales/chrome.manifest
+++ /dev/null
@@ -1,2 +0,0 @@
-locale global fr resource://gre/chrome/en-US/locale/en-US/global/
-locale global jp resource://gre/chrome/en-US/locale/en-US/global/
--- a/toolkit/components/extensions/test/xpcshell/test_ext_i18n.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_i18n.js
@@ -8,17 +8,16 @@ ExtensionTestUtils.mockAppInfo();
 
 const server = createHttpServer();
 server.registerDirectory("/data/", do_get_file("data"));
 
 const BASE_URL = `http://localhost:${server.identity.primaryPort}/data`;
 
 do_register_cleanup(() => {
   Preferences.reset("intl.accept_languages");
-  Preferences.reset("intl.locale.matchOS");
   Preferences.reset("general.useragent.locale");
 });
 
 
 add_task(async function test_i18n() {
   function runTests(assertEq) {
     let _ = browser.i18n.getMessage.bind(browser.i18n);
 
@@ -157,92 +156,16 @@ add_task(async function test_i18n() {
 
   let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
   await extension.awaitMessage("content-script-finished");
   await contentPage.close();
 
   await extension.unload();
 });
 
-add_task(async function test_i18n_negotiation() {
-  function runTests(expected) {
-    let _ = browser.i18n.getMessage.bind(browser.i18n);
-
-    browser.test.assertEq(expected, _("foo"), "Got expected message");
-  }
-
-  let extensionData = {
-    manifest: {
-      "default_locale": "en_US",
-
-      content_scripts: [
-        {"matches": ["http://*/*/file_sample.html"],
-         "js": ["content.js"]},
-      ],
-    },
-
-
-    files: {
-      "_locales/en_US/messages.json": {
-        "foo": {
-          "message": "English.",
-          "description": "foo",
-        },
-      },
-
-      "_locales/jp/messages.json": {
-        "foo": {
-          "message": "\u65e5\u672c\u8a9e",
-          "description": "foo",
-        },
-      },
-
-      "content.js": "new " + function(runTestsFn) {
-        browser.test.onMessage.addListener(expected => {
-          runTestsFn(expected);
-
-          browser.test.sendMessage("content-script-finished");
-        });
-        browser.test.sendMessage("content-ready");
-      } + `(${runTests})`,
-    },
-
-    background: "new " + function(runTestsFn) {
-      browser.test.onMessage.addListener(expected => {
-        runTestsFn(expected);
-
-        browser.test.sendMessage("background-script-finished");
-      });
-    } + `(${runTests})`,
-  };
-
-  Components.manager.addBootstrappedManifestLocation(do_get_file("data/locales/"));
-
-  let contentPage = await ExtensionTestUtils.loadContentPage(`${BASE_URL}/file_sample.html`);
-
-  Preferences.set("intl.locale.matchOS", false);
-  for (let [lang, msg] of [["en-US", "English."], ["jp", "\u65e5\u672c\u8a9e"]]) {
-    Preferences.set("general.useragent.locale", lang);
-
-    let extension = ExtensionTestUtils.loadExtension(extensionData);
-    await extension.startup();
-    await extension.awaitMessage("content-ready");
-
-    extension.sendMessage(msg);
-    await extension.awaitMessage("background-script-finished");
-    await extension.awaitMessage("content-script-finished");
-
-    await extension.unload();
-  }
-  Preferences.reset("general.useragent.locale");
-
-  await contentPage.close();
-});
-
-
 add_task(async function test_get_accept_languages() {
   function checkResults(source, results, expected) {
     browser.test.assertEq(
       expected.length,
       results.length,
       `got expected number of languages in ${source}`);
     results.forEach((lang, index) => {
       browser.test.assertEq(
@@ -366,25 +289,22 @@ add_task(async function test_get_ui_lang
 
   await extension.startup();
 
   extension.sendMessage(["expect-results", "en_US"]);
 
   await extension.awaitMessage("background-done");
   await extension.awaitMessage("content-done");
 
-  // We don't currently have a good way to mock this.
-  if (false) {
-    Preferences.set("general.useragent.locale", "he");
+  Preferences.set("general.useragent.locale", "he");
 
-    extension.sendMessage(["expect-results", "he"]);
+  extension.sendMessage(["expect-results", "he"]);
 
-    await extension.awaitMessage("background-done");
-    await extension.awaitMessage("content-done");
-  }
+  await extension.awaitMessage("background-done");
+  await extension.awaitMessage("content-done");
 
   await contentPage.close();
 
   await extension.unload();
 });
 
 
 add_task(async function test_detect_language() {
--- a/toolkit/components/extensions/test/xpcshell/test_ext_i18n_css.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_i18n_css.js
@@ -93,32 +93,29 @@ add_task(async function test_i18n_css() 
 
   await contentPage.close();
 
   cssURL = cssURL.replace(/foo.css$/, "locale.css");
 
   css = await fetch(cssURL);
   equal(css, '* { content: "en_US ltr rtl left right" }', "CSS file localized in mochitest scope");
 
-  // We don't currently have a good way to mock this.
-  if (false) {
-    const LOCALE = "general.useragent.locale";
-    const DIR = "intl.uidirection";
-    const DIR_LEGACY = "intl.uidirection.en"; // Needed for Android until bug 1215247 is resolved
+  const LOCALE = "general.useragent.locale";
+  const DIR = "intl.uidirection";
+  const DIR_LEGACY = "intl.uidirection.en"; // Needed for Android until bug 1215247 is resolved
 
-    // We don't wind up actually switching the chrome registry locale, since we
-    // don't have a chrome package for Hebrew. So just override it, and force
-    // RTL directionality.
-    Preferences.set(LOCALE, "he");
-    Preferences.set(DIR, 1);
-    Preferences.set(DIR_LEGACY, "rtl");
+  // We don't wind up actually switching the chrome registry locale, since we
+  // don't have a chrome package for Hebrew. So just override it, and force
+  // RTL directionality.
+  Preferences.set(LOCALE, "he");
+  Preferences.set(DIR, 1);
+  Preferences.set(DIR_LEGACY, "rtl");
 
-    css = await fetch(cssURL);
-    equal(css, '* { content: "he rtl ltr right left" }', "CSS file localized in mochitest scope");
+  css = await fetch(cssURL);
+  equal(css, '* { content: "he rtl ltr right left" }', "CSS file localized in mochitest scope");
 
-    Preferences.reset(LOCALE);
-    Preferences.reset(DIR);
-    Preferences.reset(DIR_LEGACY);
-  }
+  Preferences.reset(LOCALE);
+  Preferences.reset(DIR);
+  Preferences.reset(DIR_LEGACY);
 
   await extension.awaitFinish("i18n-css");
   await extension.unload();
 });
--- a/toolkit/components/extensions/test/xpcshell/test_ext_startup_cache.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_startup_cache.js
@@ -56,17 +56,16 @@ add_task(async function() {
   let extension = ExtensionTestUtils.loadExtension(
     makeExtension({version: "1.0"}));
 
   function getManifest() {
     extension.sendMessage("get-manifest");
     return extension.awaitMessage("manifest");
   }
 
-  Components.manager.addBootstrappedManifestLocation(do_get_file("data/locales/"));
 
   await extension.startup();
 
   equal(extension.version, "1.0", "Expected extension version");
   let manifest = await getManifest();
   equal(manifest.name, "en-US 1.0", "Got expected manifest name");
 
 
@@ -75,17 +74,16 @@ add_task(async function() {
   await extension.awaitStartup();
 
   equal(extension.version, "1.0", "Expected extension version");
   manifest = await getManifest();
   equal(manifest.name, "en-US 1.0", "Got expected manifest name");
 
 
   do_print("Change locale to 'fr' and restart");
-  Preferences.set("intl.locale.matchOS", false);
   Preferences.set("general.useragent.locale", "fr");
   await AddonTestUtils.promiseRestartManager();
   await extension.awaitStartup();
 
   equal(extension.version, "1.0", "Expected extension version");
   manifest = await getManifest();
   equal(manifest.name, "fr 1.0", "Got expected manifest name");