rename from toolkit/mozapps/extensions/test/xpcshell/test_bug397778.js
rename to toolkit/mozapps/extensions/test/xpcshell/test_manifest_locales.js
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug397778.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_manifest_locales.js
@@ -55,114 +55,86 @@ const ADDON = {
{
locale: ["en-CA"],
name: "en-CA Name",
description: "en-CA Description",
},
],
};
-const XPI = createTempXPIFile(ADDON);
+function changeLocales(locales) {
+ Services.locale.setRequestedLocales(locales);
+ return promiseRestartManager();
+}
-function run_test() {
- // Setup for test
- do_test_pending();
+add_task(async function setup() {
createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1");
Services.locale.setRequestedLocales(["fr-FR"]);
- // Install test add-on
- startupManager();
- installAllFiles([XPI], function() {
- restartManager();
-
- run_test_1();
- });
-}
-
-function run_test_1() {
- AddonManager.getAddonByID(ID, callback_soon(function(addon) {
- Assert.notEqual(addon, null);
- Assert.equal(addon.name, "fr Name");
- Assert.equal(addon.description, "fr Description");
-
- // Disable item
- addon.userDisabled = true;
- restartManager();
-
- AddonManager.getAddonByID(ID, function(newAddon) {
- Assert.notEqual(newAddon, null);
- Assert.equal(newAddon.name, "fr Name");
+ await promiseStartupManager();
+ await promiseInstallXPI(ADDON);
+});
- executeSoon(run_test_2);
- });
- }));
-}
-
-function run_test_2() {
- // Change locale. The more specific de-DE is the best match
- Services.locale.setRequestedLocales(["de"]);
- restartManager();
+add_task(async function test_1() {
+ let addon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(addon, null);
+ Assert.equal(addon.name, "fr Name");
+ Assert.equal(addon.description, "fr Description");
- AddonManager.getAddonByID(ID, function(addon) {
- Assert.notEqual(addon, null);
- Assert.equal(addon.name, "Deutsches W\u00f6rterbuch");
- Assert.equal(addon.description, null);
-
- executeSoon(run_test_3);
- });
-}
-
-function run_test_3() {
- // Change locale. Locale case should have no effect
- Services.locale.setRequestedLocales(["DE-de"]);
+ // Disable item
+ addon.userDisabled = true;
restartManager();
- AddonManager.getAddonByID(ID, function(addon) {
- Assert.notEqual(addon, null);
- Assert.equal(addon.name, "Deutsches W\u00f6rterbuch");
- Assert.equal(addon.description, null);
+ let newAddon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(newAddon, null);
+ Assert.equal(newAddon.name, "fr Name");
+});
- executeSoon(run_test_4);
- });
-}
+add_task(async function test_2() {
+ // Change locale. The more specific de-DE is the best match
+ await changeLocales(["de"]);
-function run_test_4() {
- // Change locale. es-ES should closely match
- Services.locale.setRequestedLocales(["es-AR"]);
- restartManager();
+ let addon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(addon, null);
+ Assert.equal(addon.name, "Deutsches W\u00f6rterbuch");
+ Assert.equal(addon.description, null);
+});
- AddonManager.getAddonByID(ID, function(addon) {
- Assert.notEqual(addon, null);
- Assert.equal(addon.name, "es-ES Name");
- Assert.equal(addon.description, "es-ES Description");
+add_task(async function test_3() {
+ // Change locale. Locale case should have no effect
+ await changeLocales(["DE-de"]);
- executeSoon(run_test_5);
- });
-}
+ let addon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(addon, null);
+ Assert.equal(addon.name, "Deutsches W\u00f6rterbuch");
+ Assert.equal(addon.description, null);
+});
-function run_test_5() {
- // Change locale. Either zh-CN or zh-TW could match
- Services.locale.setRequestedLocales(["zh"]);
- restartManager();
+add_task(async function test_4() {
+ // Change locale. es-ES should closely match
+ await changeLocales(["es-AR"]);
- AddonManager.getAddonByID(ID, function(addon) {
- Assert.notEqual(addon, null);
- if (addon.name != "zh-TW Name" && addon.name != "zh-CN Name")
- do_throw("zh matched to " + addon.name);
+ let addon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(addon, null);
+ Assert.equal(addon.name, "es-ES Name");
+ Assert.equal(addon.description, "es-ES Description");
+});
- executeSoon(run_test_6);
- });
-}
+add_task(async function test_5() {
+ // Change locale. Either zh-CN or zh-TW could match
+ await changeLocales(["zh"]);
-function run_test_6() {
+ let addon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(addon, null);
+ ok(addon.name == "zh-TW Name" || addon.name == "zh-CN Name",
+ `Add-on name mismatch: ${addon.name}`);
+});
+
+add_task(async function test_6() {
// Unknown locale should try to match against en-US as well. Of en,en-GB
// en should match as being less specific
- Services.locale.setRequestedLocales(["nl-NL"]);
- restartManager();
+ await changeLocales(["nl-NL"]);
- AddonManager.getAddonByID(ID, function(addon) {
- Assert.notEqual(addon, null);
- Assert.equal(addon.name, "en Name");
- Assert.equal(addon.description, "en Description");
-
- executeSoon(do_test_finished);
- });
-}
+ let addon = await AddonManager.getAddonByID(ID);
+ Assert.notEqual(addon, null);
+ Assert.equal(addon.name, "en Name");
+ Assert.equal(addon.description, "en Description");
+});
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini
@@ -42,19 +42,16 @@ tags = blocklist
requesttimeoutfactor = 2
tags = blocklist
[test_bootstrap.js]
skip-if = true # Bug 1358846 Bug 1365021 Bug 676992
[test_bootstrap_const.js]
[test_bootstrap_globals.js]
[test_bug1180901_2.js]
skip-if = os != "win"
-[test_bug397778.js]
-# Bug 676992: test consistently hangs on Android
-skip-if = os == "android"
[test_bug430120.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
tags = blocklist
[test_bug449027.js]
# Bug 676992: test consistently hangs on Android
skip-if = os == "android"
tags = blocklist
@@ -176,16 +173,19 @@ skip-if = os == "android"
[test_invalid_install_rdf.js]
[test_isDebuggable.js]
[test_isReady.js]
[test_json_updatecheck.js]
[test_legacy.js]
skip-if = !allow_legacy_extensions || appname == "thunderbird"
[test_locale.js]
[test_manifest.js]
+[test_manifest_locales.js]
+# Bug 676992: test consistently hangs on Android
+skip-if = os == "android"
[test_migrate_state_prefs.js]
[test_no_addons.js]
[test_nodisable_hidden.js]
[test_onPropertyChanged_appDisabled.js]
[test_overrideblocklist.js]
run-sequentially = Uses global XCurProcD dir.
tags = blocklist
[test_pass_symbol.js]