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_distribution_langpack.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_distribution_langpack.js | 112 |
1 files changed, 112 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_distribution_langpack.js b/toolkit/mozapps/extensions/test/xpcshell/test_distribution_langpack.js new file mode 100644 index 0000000000..0e594d60ec --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_distribution_langpack.js @@ -0,0 +1,112 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This verifies that add-ons distributed with the application in +// langauge subdirectories correctly get installed + +// Allow distributed add-ons to install +Services.prefs.setBoolPref("extensions.installDistroAddons", true); + +createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + +const profileDir = gProfD.clone(); +profileDir.append("extensions"); +const distroDir = gProfD.clone(); +distroDir.append("distribution"); +distroDir.append("extensions"); +registerDirectory("XREAppDist", distroDir.parent); +const enUSDistroDir = distroDir.clone(); +enUSDistroDir.append("locale-en-US"); +const deDEDistroDir = distroDir.clone(); +deDEDistroDir.append("locale-de-DE"); +const esESDistroDir = distroDir.clone(); +esESDistroDir.append("locale-es-ES"); + +const enUSID = "addon-en-US@tests.mozilla.org"; +const deDEID = "addon-de-DE@tests.mozilla.org"; +const esESID = "addon-es-ES@tests.mozilla.org"; + +async function writeDistroAddons(version) { + let xpi = await createTempWebExtensionFile({ + manifest: { + version, + browser_specific_settings: { gecko: { id: enUSID } }, + }, + }); + xpi.copyTo(enUSDistroDir, `${enUSID}.xpi`); + + xpi = await createTempWebExtensionFile({ + manifest: { + version, + browser_specific_settings: { gecko: { id: deDEID } }, + }, + }); + xpi.copyTo(deDEDistroDir, `${deDEID}.xpi`); + + xpi = await createTempWebExtensionFile({ + manifest: { + version, + browser_specific_settings: { gecko: { id: esESID } }, + }, + }); + xpi.copyTo(esESDistroDir, `${esESID}.xpi`); +} + +add_task(async function setup() { + await writeDistroAddons("1.0"); +}); + +// Tests that on the first startup the requested locale +// add-on gets installed, and others don't. +add_task(async function run_locale_test() { + Services.locale.availableLocales = ["de-DE", "en-US"]; + Services.locale.requestedLocales = ["de-DE"]; + + Assert.equal(Services.locale.requestedLocale, "de-DE"); + + await promiseStartupManager(); + + let a1 = await AddonManager.getAddonByID(deDEID); + Assert.notEqual(a1, null); + Assert.equal(a1.version, "1.0"); + Assert.ok(a1.isActive); + Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE); + Assert.ok(!a1.foreignInstall); + + let a2 = await AddonManager.getAddonByID(enUSID); + Assert.equal(a2, null); + + let a3 = await AddonManager.getAddonByID(esESID); + Assert.equal(a3, null); + + await a1.uninstall(); + await promiseShutdownManager(); +}); + +// Tests that on the first startup the correct fallback locale +// add-on gets installed, and others don't. +add_task(async function run_fallback_test() { + Services.locale.availableLocales = ["es-ES", "en-US"]; + Services.locale.requestedLocales = ["es-UY"]; + + Assert.equal(Services.locale.requestedLocale, "es-UY"); + + await promiseStartupManager(); + + let a1 = await AddonManager.getAddonByID(esESID); + Assert.notEqual(a1, null); + Assert.equal(a1.version, "1.0"); + Assert.ok(a1.isActive); + Assert.equal(a1.scope, AddonManager.SCOPE_PROFILE); + Assert.ok(!a1.foreignInstall); + + let a2 = await AddonManager.getAddonByID(enUSID); + Assert.equal(a2, null); + + let a3 = await AddonManager.getAddonByID(deDEID); + Assert.equal(a3, null); + + await a1.uninstall(); + await promiseShutdownManager(); +}); |