summaryrefslogtreecommitdiffstats
path: root/browser/base/content/test/urlbar/browser_action_searchengine.js
diff options
context:
space:
mode:
Diffstat (limited to 'browser/base/content/test/urlbar/browser_action_searchengine.js')
-rw-r--r--browser/base/content/test/urlbar/browser_action_searchengine.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/browser/base/content/test/urlbar/browser_action_searchengine.js b/browser/base/content/test/urlbar/browser_action_searchengine.js
new file mode 100644
index 000000000..d2115abba
--- /dev/null
+++ b/browser/base/content/test/urlbar/browser_action_searchengine.js
@@ -0,0 +1,36 @@
+add_task(function* () {
+ Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
+ "http://example.com/?q={searchTerms}");
+ let engine = Services.search.getEngineByName("MozSearch");
+ let originalEngine = Services.search.currentEngine;
+ Services.search.currentEngine = engine;
+
+ let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:mozilla");
+
+ registerCleanupFunction(() => {
+ Services.search.currentEngine = originalEngine;
+ let engine = Services.search.getEngineByName("MozSearch");
+ Services.search.removeEngine(engine);
+
+ try {
+ gBrowser.removeTab(tab);
+ } catch (ex) { /* tab may have already been closed in case of failure */ }
+
+ return PlacesTestUtils.clearHistory();
+ });
+
+ yield promiseAutocompleteResultPopup("open a search");
+ let result = gURLBar.popup.richlistbox.firstChild;
+
+ isnot(result, null, "Should have a result");
+ is(result.getAttribute("url"),
+ `moz-action:searchengine,{"engineName":"MozSearch","input":"open%20a%20search","searchQuery":"open%20a%20search"}`,
+ "Result should be a moz-action: for the correct search engine");
+ is(result.hasAttribute("image"), false, "Result shouldn't have an image attribute");
+
+ let tabPromise = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
+ result.click();
+ yield tabPromise;
+
+ is(gBrowser.selectedBrowser.currentURI.spec, "http://example.com/?q=open+a+search", "Correct URL should be loaded");
+});