summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js')
-rw-r--r--toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js52
1 files changed, 52 insertions, 0 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js b/toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js
new file mode 100644
index 0000000000..155079ce4b
--- /dev/null
+++ b/toolkit/components/search/tests/xpcshell/test_nodb_pluschanges.js
@@ -0,0 +1,52 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/*
+ * test_nodb: Start search service without existing settings file.
+ *
+ * Ensure that :
+ * - nothing explodes;
+ * - if we change the order, search.json.mozlz4 is updated;
+ * - this search.json.mozlz4 can be parsed;
+ * - the order stored in search.json.mozlz4 is consistent.
+ *
+ * Notes:
+ * - we install the search engines of test "test_downloadAndAddEngines.js"
+ * to ensure that this test is independent from locale, commercial agreements
+ * and configuration of Firefox.
+ */
+
+add_task(async function setup() {
+ useHttpServer();
+ await AddonTestUtils.promiseStartupManager();
+});
+
+add_task(async function test_nodb_pluschanges() {
+ let engine1 = await SearchTestUtils.promiseNewSearchEngine({
+ url: `${gDataUrl}engine.xml`,
+ });
+ let engine2 = await SearchTestUtils.promiseNewSearchEngine({
+ url: `${gDataUrl}engine2.xml`,
+ });
+ await promiseAfterSettings();
+
+ let search = Services.search;
+
+ await search.moveEngine(engine1, 0);
+ await search.moveEngine(engine2, 1);
+
+ // This is needed to avoid some reentrency issues in nsSearchService.
+ info("Next step is forcing flush");
+ await new Promise(resolve => executeSoon(resolve));
+
+ info("Forcing flush");
+ let promiseCommit = promiseAfterSettings();
+ search.QueryInterface(Ci.nsIObserver).observe(null, "quit-application", "");
+ await promiseCommit;
+ info("Commit complete");
+
+ // Check that the entries are placed as specified correctly
+ let metadata = await promiseEngineMetadata();
+ Assert.equal(metadata["Test search engine"].order, 1);
+ Assert.equal(metadata["A second test engine"].order, 2);
+});