summaryrefslogtreecommitdiffstats
path: root/toolkit/components/search/tests/xpcshell/test_addEngineWithDetails.js
diff options
context:
space:
mode:
Diffstat (limited to 'toolkit/components/search/tests/xpcshell/test_addEngineWithDetails.js')
-rw-r--r--toolkit/components/search/tests/xpcshell/test_addEngineWithDetails.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/toolkit/components/search/tests/xpcshell/test_addEngineWithDetails.js b/toolkit/components/search/tests/xpcshell/test_addEngineWithDetails.js
new file mode 100644
index 0000000000..71f97d34bd
--- /dev/null
+++ b/toolkit/components/search/tests/xpcshell/test_addEngineWithDetails.js
@@ -0,0 +1,46 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const kSearchEngineID = "addEngineWithDetails_test_engine";
+const kSearchEngineURL = "http://example.com/?search={searchTerms}";
+const kSearchTerm = "foo";
+
+add_task(async function setup() {
+ await AddonTestUtils.promiseStartupManager();
+});
+
+add_task(async function test_addEngineWithDetails() {
+ Assert.ok(!Services.search.isInitialized);
+
+ await Services.search.addEngineWithDetails(kSearchEngineID, {
+ method: "get",
+ template: kSearchEngineURL,
+ });
+
+ // An engine added with addEngineWithDetails should have a load path, even
+ // though we can't point to a specific file.
+ let engine = Services.search.getEngineByName(kSearchEngineID);
+ Assert.equal(
+ engine.wrappedJSObject._loadPath,
+ `[other]addEngineWithDetails:${kSearchEngineID}@test.engine`
+ );
+ Assert.ok(
+ !engine.isAppProvided,
+ "Should not be shown as an app-provided engine"
+ );
+ Assert.equal(engine.searchUrlPublicSuffix, "com");
+
+ // Set the engine as default; this should set a loadPath verification hash,
+ // which should ensure we don't show the search reset prompt.
+ await Services.search.setDefault(engine);
+
+ let expectedURL = kSearchEngineURL.replace("{searchTerms}", kSearchTerm);
+ let submission = (await Services.search.getDefault()).getSubmission(
+ kSearchTerm,
+ null,
+ "searchbar"
+ );
+ Assert.equal(submission.uri.spec, expectedURL);
+});