summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.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 'toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js')
-rw-r--r--toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js95
1 files changed, 95 insertions, 0 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js b/toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js
new file mode 100644
index 0000000000..9e98e5e73a
--- /dev/null
+++ b/toolkit/components/search/tests/xpcshell/test_reload_engines_locales.js
@@ -0,0 +1,95 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Tests reloading engines when changing the in-use locale of a WebExtension,
+ * where the name of the engine changes as well.
+ */
+
+"use strict";
+
+const CONFIG = [
+ {
+ webExtension: {
+ id: "engine@search.mozilla.org",
+ },
+ appliesTo: [
+ {
+ included: { everywhere: true },
+ default: "yes",
+ },
+ ],
+ },
+ {
+ webExtension: {
+ id: "engine-diff-name@search.mozilla.org",
+ },
+ appliesTo: [
+ {
+ included: { everywhere: true },
+ excluded: { locales: { matches: ["gd"] } },
+ },
+ {
+ included: { locales: { matches: ["gd"] } },
+ webExtension: {
+ locales: ["gd"],
+ },
+ },
+ ],
+ },
+];
+
+add_setup(async () => {
+ Services.locale.availableLocales = [
+ ...Services.locale.availableLocales,
+ "en",
+ "gd",
+ ];
+ Services.locale.requestedLocales = ["gd"];
+
+ await SearchTestUtils.useTestEngines("data", null, CONFIG);
+ await AddonTestUtils.promiseStartupManager();
+ await Services.search.init();
+});
+
+add_task(async function test_config_updated_engine_changes() {
+ let engines = await Services.search.getEngines();
+ Assert.deepEqual(
+ engines.map(e => e.name),
+ ["Test search engine", "engine-diff-name-gd"],
+ "Should have the correct engines installed"
+ );
+
+ let engine = await Services.search.getEngineByName("engine-diff-name-gd");
+ Assert.equal(
+ engine.name,
+ "engine-diff-name-gd",
+ "Should have the correct engine name"
+ );
+ Assert.equal(
+ engine.getSubmission("test").uri.spec,
+ "https://gd.wikipedia.com/search",
+ "Should have the gd search url"
+ );
+
+ await promiseSetLocale("en");
+
+ engines = await Services.search.getEngines();
+ Assert.deepEqual(
+ engines.map(e => e.name),
+ ["Test search engine", "engine-diff-name-en"],
+ "Should have the correct engines installed after locale change"
+ );
+
+ engine = await Services.search.getEngineByName("engine-diff-name-en");
+ Assert.equal(
+ engine.name,
+ "engine-diff-name-en",
+ "Should have the correct engine name"
+ );
+ Assert.equal(
+ engine.getSubmission("test").uri.spec,
+ "https://en.wikipedia.com/search",
+ "Should have the en search url"
+ );
+});