gecko-dev/browser/base/content/test/urlbar/browser_search_favicon.js
Marco Bonardo 06932c74d1 Bug 1223728 - Remove the unifiedcomplete pref, the urlinline component and stop bundling the old autocomplete component in Firefox. r=adw
MozReview-Commit-ID: Ee08mDGxBjJ

--HG--
extra : rebase_source : 4473da657f85e443e5095b43b3e774e85292ecd1
extra : amend_source : c9c322ebae255a24c28e6367b9fe93474db21d6d
2016-05-05 00:14:51 +02:00

53 lines
2.2 KiB
JavaScript

var gOriginalEngine;
var gEngine;
var gRestyleSearchesPref = "browser.urlbar.restyleSearches";
registerCleanupFunction(() => {
Services.prefs.clearUserPref(gRestyleSearchesPref);
Services.search.currentEngine = gOriginalEngine;
Services.search.removeEngine(gEngine);
return PlacesTestUtils.clearHistory();
});
add_task(function*() {
Services.prefs.setBoolPref(gRestyleSearchesPref, true);
});
add_task(function*() {
Services.search.addEngineWithDetails("SearchEngine", "", "", "",
"GET", "http://s.example.com/search");
gEngine = Services.search.getEngineByName("SearchEngine");
gEngine.addParam("q", "{searchTerms}", null);
gOriginalEngine = Services.search.currentEngine;
Services.search.currentEngine = gEngine;
let uri = NetUtil.newURI("http://s.example.com/search?q=foo&client=1");
yield PlacesTestUtils.addVisits({ uri: uri, title: "Foo - SearchEngine Search" });
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(gBrowser.selectedTab);
// The first autocomplete result has the action searchengine, while
// the second result is the "search favicon" element.
yield promiseAutocompleteResultPopup("foo");
let result = gURLBar.popup.richlistbox.children[1];
isnot(result, null, "Expect a search result");
is(result.getAttribute("type"), "searchengine", "Expect correct `type` attribute");
let titleHbox = result._titleText.parentNode.parentNode;
ok(titleHbox.classList.contains("ac-title"), "Title hbox sanity check");
is_element_visible(titleHbox, "Title element should be visible");
let urlHbox = result._urlText.parentNode.parentNode;
ok(urlHbox.classList.contains("ac-url"), "URL hbox sanity check");
is_element_hidden(urlHbox, "URL element should be hidden");
let actionHbox = result._actionText.parentNode.parentNode;
ok(actionHbox.classList.contains("ac-action"), "Action hbox sanity check");
is_element_hidden(actionHbox, "Action element should be hidden because it is not selected");
is(result._actionText.textContent, "Search with SearchEngine", "Action text should be as expected");
gBrowser.removeCurrentTab();
});