summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.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_remove_profile_engine.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_remove_profile_engine.js')
-rw-r--r--toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js b/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js
new file mode 100644
index 0000000000..76a67b39c2
--- /dev/null
+++ b/toolkit/components/search/tests/xpcshell/test_remove_profile_engine.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+// This test is to ensure that we remove xml files from searchplugins/ in the
+// profile directory when a user removes the actual engine from their profile.
+
+add_task(async function setup() {
+ await SearchTestUtils.useTestEngines("data1");
+ await AddonTestUtils.promiseStartupManager();
+});
+
+add_task(async function run_test() {
+ // Copy an engine to [profile]/searchplugin/
+ let dir = do_get_profile().clone();
+ dir.append("searchplugins");
+ if (!dir.exists()) {
+ dir.create(dir.DIRECTORY_TYPE, FileUtils.PERMS_DIRECTORY);
+ }
+ do_get_file("data/engine.xml").copyTo(dir, "test-search-engine.xml");
+
+ let file = dir.clone();
+ file.append("test-search-engine.xml");
+ Assert.ok(file.exists());
+
+ let data = await readJSONFile(do_get_file("data/search-legacy.json"));
+
+ // Put the filePath inside the settings file, to simulate what a pre-58 version
+ // of Firefox would have done.
+ for (let engine of data.engines) {
+ if (engine._name == "Test search engine") {
+ engine.filePath = file.path;
+ }
+ }
+
+ await promiseSaveSettingsData(data);
+
+ await Services.search.init();
+
+ // test the engine is loaded ok.
+ let engine = Services.search.getEngineByName("Test search engine");
+ Assert.notEqual(engine, null, "Should have found the engine");
+
+ // remove the engine and verify the file has been removed too.
+ await Services.search.removeEngine(engine);
+ Assert.ok(!file.exists(), "Should have removed the file.");
+});