diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/mozapps/extensions/test/xpcshell/test_locale.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_locale.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_locale.js b/toolkit/mozapps/extensions/test/xpcshell/test_locale.js new file mode 100644 index 0000000000..2824c489b4 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_locale.js @@ -0,0 +1,103 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ +add_task(async function setup() { + // Setup for test + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + await promiseStartupManager(); +}); + +// Tests that the localized properties are visible before installation +add_task(async function test_1() { + await restartWithLocales(["fr-FR"]); + + let xpi = AddonTestUtils.createTempWebExtensionFile({ + manifest: { + name: "__MSG_name__", + description: "__MSG_description__", + default_locale: "en", + + browser_specific_settings: { + gecko: { + id: "addon1@tests.mozilla.org", + }, + }, + }, + + files: { + "_locales/en/messages.json": { + name: { + message: "Fallback Name", + description: "name", + }, + description: { + message: "Fallback Description", + description: "description", + }, + }, + "_locales/fr_FR/messages.json": { + name: { + message: "fr-FR Name", + description: "name", + }, + description: { + message: "fr-FR Description", + description: "description", + }, + }, + "_locales/de-DE/messages.json": { + name: { + message: "de-DE Name", + description: "name", + }, + }, + }, + }); + + let install = await AddonManager.getInstallForFile(xpi); + Assert.equal(install.addon.name, "fr-FR Name"); + Assert.equal(install.addon.description, "fr-FR Description"); + await install.install(); +}); + +// Tests that the localized properties are visible after installation +add_task(async function test_2() { + let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org"); + Assert.notEqual(addon, null); + + Assert.equal(addon.name, "fr-FR Name"); + Assert.equal(addon.description, "fr-FR Description"); + + await addon.disable(); +}); + +// Test that the localized properties are still there when disabled. +add_task(async function test_3() { + let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org"); + Assert.notEqual(addon, null); + Assert.equal(addon.name, "fr-FR Name"); +}); + +// Test that changing locale works +add_task(async function test_5() { + await restartWithLocales(["de-DE"]); + + let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org"); + Assert.notEqual(addon, null); + + Assert.equal(addon.name, "de-DE Name"); + Assert.equal(addon.description, "Fallback Description"); +}); + +// Test that missing locales use the fallbacks +add_task(async function test_6() { + await restartWithLocales(["nl-NL"]); + + let addon = await AddonManager.getAddonByID("addon1@tests.mozilla.org"); + Assert.notEqual(addon, null); + + Assert.equal(addon.name, "Fallback Name"); + Assert.equal(addon.description, "Fallback Description"); + + await addon.enable(); +}); |