1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
4 const Cc = Components.classes;
5 const Ci = Components.interfaces;
7 const kSearchEngineID = "browser_urifixup_search_engine";
8 const kSearchEngineURL = "http://example.com/?search={searchTerms}";
9 Services.search.addEngineWithDetails(kSearchEngineID, "", "", "", "get",
12 let oldDefaultEngine = Services.search.defaultEngine;
13 Services.search.defaultEngine = Services.search.getEngineByName(kSearchEngineID);
19 let escapedParams = encodeURIComponent(searchParams).replace("%20", "+");
20 let expectedURL = kSearchEngineURL.replace("{searchTerms}", escapedParams);
21 is(tab.linkedBrowser.currentURI.spec, expectedURL,
22 "New tab should have loaded with expected url.");
25 function addPageShowListener(aFunc) {
26 gBrowser.selectedBrowser.addEventListener("pageshow", function loadListener() {
27 gBrowser.selectedBrowser.removeEventListener("pageshow", loadListener, false);
32 function locationBarEnter(aCallback) {
33 executeSoon(function() {
35 EventUtils.synthesizeKey("VK_RETURN", {});
36 addPageShowListener(aCallback);
42 "brokenprotocol:somethingelse"
45 waitForExplicitFinish();
51 searchParams = urlbarInput.pop();
52 tab = gBrowser.selectedTab = gBrowser.addTab();
54 gURLBar.value = searchParams;
55 locationBarEnter(function() {
57 gBrowser.removeTab(tab);
59 if (urlbarInput.length) {
67 registerCleanupFunction(function () {
69 gBrowser.removeTab(tab);
72 if (oldDefaultEngine) {
73 Services.search.defaultEngine = oldDefaultEngine;
75 let engine = Services.search.getEngineByName(kSearchEngineID);
77 Services.search.removeEngine(engine);