Backed out changeset 9b44720d645b (bug 1357902) for android xpcshell failures in test_ext_startup_cache.js a=backout

MozReview-Commit-ID: KzJWDUsEJoK
This commit is contained in:
Wes Kocher 2017-07-17 23:28:33 -07:00
Родитель 87798d9abf
Коммит e58c76131e
9 изменённых файлов: 31 добавлений и 127 удалений

Просмотреть файл

@ -21,7 +21,6 @@ support-files =
file_dummy.html
file_inspectedwindow_reload_target.sjs
file_serviceWorker.html
locale/chrome.manifest
webNav_createdTarget.html
webNav_createdTargetSource.html
webNav_createdTargetSource_subframe.html

Просмотреть файл

@ -6,18 +6,6 @@
// 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;

Просмотреть файл

@ -1 +0,0 @@
locale global es-ES resource://gre/chrome/en-US/locale/en-US/global/

Просмотреть файл

@ -61,6 +61,8 @@ 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",
@ -905,7 +907,7 @@ this.Extension = class extends ExtensionData {
}
parseManifest() {
return StartupCache.manifests.get([this.id, this.version, Services.locale.getAppLocaleAsLangTag()],
return StartupCache.manifests.get([this.id, this.version, Locale.getLocale()],
() => super.parseManifest());
}
@ -1026,12 +1028,12 @@ this.Extension = class extends ExtensionData {
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);

Просмотреть файл

@ -18,6 +18,8 @@ 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",
@ -1240,7 +1242,8 @@ LocaleData.prototype = {
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";
@ -1345,7 +1348,7 @@ LocaleData.prototype = {
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, "_");
},
};

Просмотреть файл

@ -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/

Просмотреть файл

@ -13,7 +13,6 @@ 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");
});
@ -162,82 +161,6 @@ add_task(async function test_i18n() {
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(
@ -371,15 +294,12 @@ add_task(async function test_get_ui_language() {
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();

Просмотреть файл

@ -98,26 +98,23 @@ add_task(async function test_i18n_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();

Просмотреть файл

@ -61,7 +61,6 @@ add_task(async function() {
return extension.awaitMessage("manifest");
}
Components.manager.addBootstrappedManifestLocation(do_get_file("data/locales/"));
await extension.startup();
@ -80,7 +79,6 @@ add_task(async function() {
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();