mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-14 22:13:31 +00:00
Bug 1074167 - Autocomplete results for aliased search engines should use the search engine icon. r=mak
This commit is contained in:
parent
8cf1101045
commit
c73356bf6d
@ -43,6 +43,8 @@ add_task(function* () {
|
||||
|
||||
let result = yield promise_first_result("open a search");
|
||||
isnot(result, null, "Should have a result");
|
||||
is(result.hasAttribute("image"), false, "Result shouldn't have an image attribute");
|
||||
|
||||
let tabPromise = promiseTabLoaded(gBrowser.selectedTab);
|
||||
EventUtils.synthesizeMouseAtCenter(result, {});
|
||||
yield tabPromise;
|
||||
|
@ -3,14 +3,13 @@
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/
|
||||
**/
|
||||
|
||||
let gOriginalEngine;
|
||||
let gOriginalEngine;
|
||||
|
||||
add_task(function* () {
|
||||
// This test is only relevant if UnifiedComplete is enabled.
|
||||
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete"))
|
||||
return;
|
||||
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
|
||||
|
||||
Services.search.addEngineWithDetails("MozSearch", "", "moz", "", "GET",
|
||||
let iconURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
|
||||
Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET",
|
||||
"http://example.com/?q={searchTerms}");
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
gOriginalEngine = Services.search.currentEngine;
|
||||
@ -22,6 +21,7 @@ add_task(function* () {
|
||||
Services.search.currentEngine = gOriginalEngine;
|
||||
let engine = Services.search.getEngineByName("MozSearch");
|
||||
Services.search.removeEngine(engine);
|
||||
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
|
||||
|
||||
try {
|
||||
gBrowser.removeTab(tab);
|
||||
@ -35,6 +35,12 @@ add_task(function* () {
|
||||
EventUtils.synthesizeKey("h" , {});
|
||||
yield promiseSearchComplete();
|
||||
|
||||
let result = gURLBar.popup.richlistbox.children[0];
|
||||
ok(result.hasAttribute("image"), "Result should have an image attribute");
|
||||
// Image attribute gets a suffix (-moz-resolution) added in the value.
|
||||
ok(result.getAttribute("image").startsWith(engine.iconURI.spec),
|
||||
"Image attribute should have the search engine's icon");
|
||||
|
||||
EventUtils.synthesizeKey("VK_RETURN" , { });
|
||||
yield promiseTabLoaded(gBrowser.selectedTab);
|
||||
|
||||
|
@ -859,11 +859,12 @@ Search.prototype = {
|
||||
if (this._searchTokens.length < 2)
|
||||
return false;
|
||||
|
||||
let match = yield PlacesSearchAutocompleteProvider.findMatchByAlias(
|
||||
this._searchTokens[0]);
|
||||
let alias = this._searchTokens[0];
|
||||
let match = yield PlacesSearchAutocompleteProvider.findMatchByAlias(alias);
|
||||
if (!match)
|
||||
return false;
|
||||
|
||||
match.engineAlias = alias;
|
||||
let query = this._searchTokens.slice(1).join(" ");
|
||||
|
||||
yield this._addSearchEngineMatch(match, query);
|
||||
@ -881,11 +882,15 @@ Search.prototype = {
|
||||
},
|
||||
|
||||
_addSearchEngineMatch: function* (match, query) {
|
||||
let value = makeActionURL("searchengine", {
|
||||
let actionURLParams = {
|
||||
engineName: match.engineName,
|
||||
input: this._originalSearchString,
|
||||
searchQuery: query,
|
||||
});
|
||||
};
|
||||
if (match.engineAlias) {
|
||||
actionURLParams.alias = match.engineAlias;
|
||||
}
|
||||
let value = makeActionURL("searchengine", actionURLParams);
|
||||
|
||||
this._addMatch({
|
||||
value: value,
|
||||
|
@ -20,13 +20,13 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "doit mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("searchengine", {engineName: "AliasedMozSearch", input: "doit mozilla", searchQuery: "mozilla"}), title: "AliasedMozSearch" }, ]
|
||||
matches: [ { uri: makeActionURI("searchengine", {engineName: "AliasedMozSearch", input: "doit mozilla", searchQuery: "mozilla", alias: "doit"}), title: "AliasedMozSearch" }, ]
|
||||
});
|
||||
|
||||
yield check_autocomplete({
|
||||
search: "doit mozzarella mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("searchengine", {engineName: "AliasedMozSearch", input: "doit mozzarella mozilla", searchQuery: "mozzarella mozilla"}), title: "AliasedMozSearch" }, ]
|
||||
matches: [ { uri: makeActionURI("searchengine", {engineName: "AliasedMozSearch", input: "doit mozzarella mozilla", searchQuery: "mozzarella mozilla", alias: "doit"}), title: "AliasedMozSearch" }, ]
|
||||
});
|
||||
|
||||
yield cleanup();
|
||||
|
@ -1586,9 +1586,15 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
[action.params.engineName, false],
|
||||
[action.params.searchQuery, true]
|
||||
]);
|
||||
// Remove the image, so we can style it ourselves with a generic
|
||||
// search icon.
|
||||
this.removeAttribute("image");
|
||||
// If this is a default search match, we remove the image so we
|
||||
// can style it ourselves with a generic search icon.
|
||||
// We don't do this when matching an aliased search engine,
|
||||
// because the icon helps with recognising which engine will be
|
||||
// used (when using the default engine, we don't need that
|
||||
// recognition).
|
||||
if (!action.params.alias) {
|
||||
this.removeAttribute("image");
|
||||
}
|
||||
} else if (action.type == "visiturl") {
|
||||
emphasiseUrl = false;
|
||||
url = action.params.url;
|
||||
|
Loading…
x
Reference in New Issue
Block a user