mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1176437 - Don't show fallback "Search with" result when the awesomebar is empty. r=mak
This commit is contained in:
parent
f173f97e68
commit
8781905fe7
@ -38,7 +38,9 @@ add_task(function*() {
|
||||
let result = yield promise_first_result("keyword something");
|
||||
isnot(result, null, "Expect a keyword result");
|
||||
|
||||
is(result.getAttribute("type"), "action keyword", "Expect correct `type` attribute");
|
||||
let types = new Set(result.getAttribute("type").split(/\s+/));
|
||||
Assert.ok(types.has("action"));
|
||||
Assert.ok(types.has("keyword"));
|
||||
is(result.getAttribute("actiontype"), "keyword", "Expect correct `actiontype` attribute");
|
||||
is(result.getAttribute("title"), "example.com", "Expect correct title");
|
||||
|
||||
|
@ -768,8 +768,14 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
// Trim popup selected values, but never trim results coming from
|
||||
// autofill.
|
||||
let styles = new Set(
|
||||
this.popup.selectedIndex == -1 ? [] :
|
||||
this.mController.getStyleAt(this.popup.selectedIndex).split(/\s+/)
|
||||
);
|
||||
if (this.popup.selectedIndex == -1 ||
|
||||
this.mController.getStyleAt(this.popup.selectedIndex) == "autofill") {
|
||||
this.mController
|
||||
.getStyleAt(this.popup.selectedIndex)
|
||||
.split(/\s+/).indexOf("autofill") >= 0) {
|
||||
this._disableTrim = true;
|
||||
}
|
||||
this.value = val;
|
||||
@ -1586,7 +1592,13 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
// ie, hitting page-down will only cause is to wrap if we're already
|
||||
// at one end of the list.
|
||||
|
||||
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
|
||||
// Do not allow the selection to be removed if UnifiedComplete is
|
||||
// enabled and the popup's first result is a heuristic result.
|
||||
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete") ||
|
||||
(this.input.mController.matchCount > 0 &&
|
||||
this.input.mController
|
||||
.getStyleAt(0)
|
||||
.split(/\s+/).indexOf("heuristic") == -1)) {
|
||||
if (reverse && index == -1 || newIndex > maxRow && index != maxRow)
|
||||
newIndex = maxRow;
|
||||
else if (!reverse && index == -1 || newIndex < 0 && index != 0)
|
||||
@ -1792,18 +1804,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
<method name="createResultLabel">
|
||||
<parameter name="aTitle"/>
|
||||
<parameter name="aUrl"/>
|
||||
<parameter name="aType"/>
|
||||
<parameter name="aTypes"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
let label = aTitle + " " + aUrl;
|
||||
// convert aType (ex: "ac-result-type-<aType>") to text to be spoke aloud
|
||||
// by screen readers. convert "tag" and "bookmark" to the localized versions,
|
||||
// but don't do anything for "favicon" (the default)
|
||||
let type = aTypes.find(v => v != "action" && v != "heuristic");
|
||||
try {
|
||||
label += " " + this._bundle.GetStringFromName(aType + "ResultLabel");
|
||||
} catch (e) {
|
||||
// Undefined result label, do nothing.
|
||||
}
|
||||
// Some types intentionally do not map to strings, which is not
|
||||
// an error.
|
||||
label += " " + this._bundle.GetStringFromName(type + "ResultLabel");
|
||||
} catch (e) {}
|
||||
|
||||
return label;
|
||||
]]>
|
||||
@ -1816,11 +1826,16 @@ file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete"))
|
||||
return;
|
||||
|
||||
// If nothing is selected yet, select the first result if it is a
|
||||
// pre-selected "heuristic" result. (See UnifiedComplete.js.)
|
||||
if (this._matchCount > 0 && this.selectedIndex == -1) {
|
||||
// Don't handle this as a user-initiated action.
|
||||
this._ignoreNextSelect = true;
|
||||
this.selectedIndex = 0;
|
||||
this._ignoreNextSelect = false;
|
||||
let styles = this.input.mController.getStyleAt(0).split(/\s+/);
|
||||
if (styles.indexOf("heuristic") >= 0) {
|
||||
// Don't handle this as a user-initiated action.
|
||||
this._ignoreNextSelect = true;
|
||||
this.selectedIndex = 0;
|
||||
this._ignoreNextSelect = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.input.gotResultForCurrentQuery = true;
|
||||
|
@ -847,52 +847,12 @@ Search.prototype = {
|
||||
}
|
||||
queries.push(this._searchQuery);
|
||||
|
||||
// When actions are enabled, we run a series of heuristics to determine what
|
||||
// the first result should be - which is always a special result.
|
||||
// |hasFirstResult| is used to keep track of whether we've obtained such a
|
||||
// result yet, so we can skip further heuristics and not add any additional
|
||||
// special results.
|
||||
let hasFirstResult = false;
|
||||
|
||||
if (this._searchTokens.length > 0) {
|
||||
// This may be a Places keyword.
|
||||
hasFirstResult = yield this._matchPlacesKeyword();
|
||||
}
|
||||
|
||||
if (this.pending && this._enableActions && !hasFirstResult) {
|
||||
// If it's not a Places keyword, then it may be a search engine
|
||||
// with an alias - which works like a keyword.
|
||||
hasFirstResult = yield this._matchSearchEngineAlias();
|
||||
}
|
||||
|
||||
let shouldAutofill = this._shouldAutofill;
|
||||
if (this.pending && !hasFirstResult && shouldAutofill) {
|
||||
// It may also look like a URL we know from the database.
|
||||
hasFirstResult = yield this._matchKnownUrl(conn);
|
||||
}
|
||||
|
||||
if (this.pending && !hasFirstResult && shouldAutofill) {
|
||||
// Or it may look like a URL we know about from search engines.
|
||||
hasFirstResult = yield this._matchSearchEngineUrl();
|
||||
}
|
||||
|
||||
if (this.pending && this._enableActions && !hasFirstResult) {
|
||||
// If we don't have a result that matches what we know about, then
|
||||
// we use a fallback for things we don't know about.
|
||||
|
||||
// We may not have auto-filled, but this may still look like a URL.
|
||||
// However, even if the input is a valid URL, we may not want to use
|
||||
// it as such. This can happen if the host would require whitelisting,
|
||||
// but isn't in the whitelist.
|
||||
hasFirstResult = yield this._matchUnknownUrl();
|
||||
}
|
||||
|
||||
if (this.pending && this._enableActions && !hasFirstResult) {
|
||||
// When all else fails, we search using the current search engine.
|
||||
hasFirstResult = yield this._matchCurrentSearchEngine();
|
||||
}
|
||||
|
||||
// IMPORTANT: No other first result heuristics should run after this point.
|
||||
// Add the first heuristic result, if any. Set _addingHeuristicFirstMatch
|
||||
// to true so that when the result is added, "heuristic" can be included in
|
||||
// its style.
|
||||
this._addingHeuristicFirstMatch = true;
|
||||
yield this._matchFirstHeuristicResult(conn);
|
||||
this._addingHeuristicFirstMatch = false;
|
||||
|
||||
yield this._sleep(Prefs.delay);
|
||||
if (!this.pending)
|
||||
@ -926,6 +886,68 @@ Search.prototype = {
|
||||
yield Promise.all(this._remoteMatchesPromises);
|
||||
}),
|
||||
|
||||
*_matchFirstHeuristicResult(conn) {
|
||||
// We always try to make the first result a special "heuristic" result. The
|
||||
// heuristics below determine what type of result it will be, if any.
|
||||
|
||||
if (this._searchTokens.length > 0) {
|
||||
// This may be a Places keyword.
|
||||
let matched = yield this._matchPlacesKeyword();
|
||||
if (matched) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pending && this._enableActions) {
|
||||
// If it's not a Places keyword, then it may be a search engine
|
||||
// with an alias - which works like a keyword.
|
||||
let matched = yield this._matchSearchEngineAlias();
|
||||
if (matched) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let shouldAutofill = this._shouldAutofill;
|
||||
if (this.pending && shouldAutofill) {
|
||||
// It may also look like a URL we know from the database.
|
||||
let matched = yield this._matchKnownUrl(conn);
|
||||
if (matched) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pending && shouldAutofill) {
|
||||
// Or it may look like a URL we know about from search engines.
|
||||
let matched = yield this._matchSearchEngineUrl();
|
||||
if (matched) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pending && this._enableActions) {
|
||||
// If we don't have a result that matches what we know about, then
|
||||
// we use a fallback for things we don't know about.
|
||||
|
||||
// We may not have auto-filled, but this may still look like a URL.
|
||||
// However, even if the input is a valid URL, we may not want to use
|
||||
// it as such. This can happen if the host would require whitelisting,
|
||||
// but isn't in the whitelist.
|
||||
let matched = yield this._matchUnknownUrl();
|
||||
if (matched) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.pending && this._enableActions && this._originalSearchString) {
|
||||
// When all else fails, and the search string is non-empty, we search
|
||||
// using the current search engine.
|
||||
let matched = yield this._matchCurrentSearchEngine();
|
||||
if (matched) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
*_matchSearchSuggestions() {
|
||||
// Limit the string sent for search suggestions to a maximum length.
|
||||
let searchString = this._searchTokens.join(" ")
|
||||
@ -1298,6 +1320,10 @@ Search.prototype = {
|
||||
this._maybeRestyleSearchMatch(match);
|
||||
}
|
||||
|
||||
if (this._addingHeuristicFirstMatch) {
|
||||
match.style += " heuristic";
|
||||
}
|
||||
|
||||
match.icon = match.icon || PlacesUtils.favicons.defaultFavicon.spec;
|
||||
match.finalCompleteValue = match.finalCompleteValue || "";
|
||||
|
||||
@ -1576,7 +1602,7 @@ Search.prototype = {
|
||||
if (!Prefs.autofill)
|
||||
return false;
|
||||
|
||||
if (!this._searchTokens.length == 1)
|
||||
if (this._searchTokens.length != 1)
|
||||
return false;
|
||||
|
||||
// autoFill can only cope with history or bookmarks entries.
|
||||
|
@ -362,10 +362,14 @@ function makeSearchMatch(input, extra = {}) {
|
||||
searchQuery: "searchQuery" in extra ? extra.searchQuery : input,
|
||||
alias: extra.alias, // may be undefined which is expected.
|
||||
}
|
||||
let style = [ "action", "searchengine" ];
|
||||
if (extra.heuristic) {
|
||||
style.push("heuristic");
|
||||
}
|
||||
return {
|
||||
uri: makeActionURI("searchengine", params),
|
||||
title: params.engineName,
|
||||
style: [ "action", "searchengine" ],
|
||||
style,
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,10 +383,14 @@ function makeVisitMatch(input, url, extra = {}) {
|
||||
url,
|
||||
input,
|
||||
}
|
||||
let style = [ "action", "visiturl" ];
|
||||
if (extra.heuristic) {
|
||||
style.push("heuristic");
|
||||
}
|
||||
return {
|
||||
uri: makeActionURI("visiturl", params),
|
||||
title: extra.title || url,
|
||||
style: [ "action", "visiturl" ],
|
||||
style,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict history, typed visit, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "ty",
|
||||
matches: [ { uri: uri1, title: "typed", style: [ "autofill" ],
|
||||
matches: [ { uri: uri1, title: "typed", style: [ "autofill", "heuristic" ],
|
||||
icon: "chrome://global/skin/icons/information-16.png" } ],
|
||||
autofilled: "typed/",
|
||||
completed: "typed/"
|
||||
@ -60,7 +60,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict history, typed bookmark, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "tp",
|
||||
matches: [ { uri: uri4, title: "tpbk", style: [ "autofill" ] } ],
|
||||
matches: [ { uri: uri4, title: "tpbk", style: [ "autofill", "heuristic" ] } ],
|
||||
autofilled: "tpbk/",
|
||||
completed: "tpbk/"
|
||||
});
|
||||
@ -73,7 +73,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict history, bookmark, autoFill.typed = false, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "bo",
|
||||
matches: [ { uri: uri3, title: "bookmarked", style: [ "bookmark" ], style: [ "autofill" ],
|
||||
matches: [ { uri: uri3, title: "bookmarked", style: [ "bookmark" ], style: [ "autofill", "heuristic" ],
|
||||
icon: "chrome://global/skin/icons/error-16.png" } ],
|
||||
autofilled: "bookmarked/",
|
||||
completed: "bookmarked/"
|
||||
@ -82,7 +82,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict history, common visit, autoFill.typed = false, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "vi",
|
||||
matches: [ { uri: uri2, title: "visited", style: [ "autofill" ] } ],
|
||||
matches: [ { uri: uri2, title: "visited", style: [ "autofill", "heuristic" ] } ],
|
||||
autofilled: "visited/",
|
||||
completed: "visited/"
|
||||
});
|
||||
@ -103,7 +103,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict typed, typed visit, autofill.typed = false, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "ty",
|
||||
matches: [ { uri: uri1, title: "typed", style: [ "autofill" ],
|
||||
matches: [ { uri: uri1, title: "typed", style: [ "autofill", "heuristic" ],
|
||||
icon: "chrome://global/skin/icons/information-16.png"} ],
|
||||
autofilled: "typed/",
|
||||
completed: "typed/"
|
||||
@ -120,7 +120,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict typed, typed bookmark, autofill.typed = false, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "tp",
|
||||
matches: [ { uri: uri4, title: "tpbk", style: [ "autofill" ] } ],
|
||||
matches: [ { uri: uri4, title: "tpbk", style: [ "autofill", "heuristic" ] } ],
|
||||
autofilled: "tpbk/",
|
||||
completed: "tpbk/"
|
||||
});
|
||||
@ -160,7 +160,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict bookmarks, typed bookmark, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "tp",
|
||||
matches: [ { uri: uri4, title: "tpbk", style: [ "autofill" ] } ],
|
||||
matches: [ { uri: uri4, title: "tpbk", style: [ "autofill", "heuristic" ] } ],
|
||||
autofilled: "tpbk/",
|
||||
completed: "tpbk/"
|
||||
});
|
||||
@ -170,7 +170,7 @@ add_task(function* test_default_behavior_host() {
|
||||
do_print("Restrict bookmarks, bookmark, autofill.typed = false, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "bo",
|
||||
matches: [ { uri: uri3, title: "bookmarked", style: [ "autofill" ],
|
||||
matches: [ { uri: uri3, title: "bookmarked", style: [ "autofill", "heuristic" ],
|
||||
icon: "chrome://global/skin/icons/error-16.png" } ],
|
||||
autofilled: "bookmarked/",
|
||||
completed: "bookmarked/"
|
||||
@ -232,7 +232,7 @@ add_task(function* test_default_behavior_url() {
|
||||
do_print("URL: Restrict history, typed visit, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "typed/t",
|
||||
matches: [ { uri: uri1, title: "typed/ty/", style: [ "autofill" ],
|
||||
matches: [ { uri: uri1, title: "typed/ty/", style: [ "autofill", "heuristic" ],
|
||||
icon: "chrome://global/skin/icons/information-16.png"} ],
|
||||
autofilled: "typed/ty/",
|
||||
completed: "http://typed/ty/"
|
||||
@ -251,7 +251,7 @@ add_task(function* test_default_behavior_url() {
|
||||
do_print("URL: Restrict history, typed bookmark, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "tpbk/t",
|
||||
matches: [ { uri: uri4, title: "tpbk/tp/", style: [ "autofill" ] } ],
|
||||
matches: [ { uri: uri4, title: "tpbk/tp/", style: [ "autofill", "heuristic" ] } ],
|
||||
autofilled: "tpbk/tp/",
|
||||
completed: "http://tpbk/tp/"
|
||||
});
|
||||
@ -290,7 +290,7 @@ add_task(function* test_default_behavior_url() {
|
||||
do_print("URL: Restrict bookmarks, typed bookmark, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "tpbk/t",
|
||||
matches: [ { uri: uri4, title: "tpbk/tp/", style: [ "autofill" ] } ],
|
||||
matches: [ { uri: uri4, title: "tpbk/tp/", style: [ "autofill", "heuristic" ] } ],
|
||||
autofilled: "tpbk/tp/",
|
||||
completed: "http://tpbk/tp/"
|
||||
});
|
||||
@ -300,7 +300,7 @@ add_task(function* test_default_behavior_url() {
|
||||
do_print("URL: Restrict bookmarks, bookmark, autofill.typed = false, should autoFill");
|
||||
yield check_autocomplete({
|
||||
search: "bookmarked/b",
|
||||
matches: [ { uri: uri3, title: "bookmarked/bo/", style: [ "autofill" ],
|
||||
matches: [ { uri: uri3, title: "bookmarked/bo/", style: [ "autofill", "heuristic" ],
|
||||
icon: "chrome://global/skin/icons/error-16.png" } ],
|
||||
autofilled: "bookmarked/bo/",
|
||||
completed: "http://bookmarked/bo/"
|
||||
|
@ -17,7 +17,7 @@ add_task(function* test_dupe_urls() {
|
||||
completed: "mozilla.org/",
|
||||
matches: [ { uri: NetUtil.newURI("http://mozilla.org/"),
|
||||
title: "mozilla.org",
|
||||
style: [ "autofill" ] } ]
|
||||
style: [ "autofill", "heuristic" ] } ]
|
||||
});
|
||||
yield cleanup();
|
||||
});
|
||||
|
@ -43,7 +43,7 @@ add_task(function* test_javascript_match() {
|
||||
yield check_autocomplete({
|
||||
search: "foo",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("foo"),
|
||||
matches: [ makeSearchMatch("foo", { heuristic: true }),
|
||||
{ uri: uri1, title: "title" },
|
||||
{ uri: uri2, title: "title", style: ["bookmark"] },
|
||||
{ uri: uri3, title: "title" },
|
||||
@ -87,7 +87,6 @@ add_task(function* test_javascript_match() {
|
||||
search: "",
|
||||
searchParam: "enable-actions",
|
||||
matches: [
|
||||
makeSearchMatch(""),
|
||||
makeSwitchToTabMatch("http://t.foo/6", { title: "title" }),
|
||||
]
|
||||
});
|
||||
|
@ -24,43 +24,43 @@ add_task(function* test_keyword_searc() {
|
||||
do_print("Plain keyword query");
|
||||
yield check_autocomplete({
|
||||
search: "key term",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=term"), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=term"), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
do_print("Multi-word keyword query");
|
||||
yield check_autocomplete({
|
||||
search: "key multi word",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=multi+word"), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=multi+word"), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword query with +");
|
||||
yield check_autocomplete({
|
||||
search: "key blocking+",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=blocking%2B"), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=blocking%2B"), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
do_print("Unescaped term in query");
|
||||
yield check_autocomplete({
|
||||
search: "key ユニコード",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=ユニコード"), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=ユニコード"), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword that happens to match a page");
|
||||
yield check_autocomplete({
|
||||
search: "key ThisPageIsInHistory",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=ThisPageIsInHistory"), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search=ThisPageIsInHistory"), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword without query (without space)");
|
||||
yield check_autocomplete({
|
||||
search: "key",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword without query (with space)");
|
||||
yield check_autocomplete({
|
||||
search: "key ",
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "abc", style: ["keyword"] } ]
|
||||
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "abc", style: ["keyword", "heuristic"] } ]
|
||||
});
|
||||
|
||||
yield cleanup();
|
||||
|
@ -25,49 +25,49 @@ add_task(function* test_keyword_search() {
|
||||
yield check_autocomplete({
|
||||
search: "key term",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=term", input: "key term"}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=term", input: "key term"}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("Multi-word keyword query");
|
||||
yield check_autocomplete({
|
||||
search: "key multi word",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=multi+word", input: "key multi word"}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=multi+word", input: "key multi word"}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword query with +");
|
||||
yield check_autocomplete({
|
||||
search: "key blocking+",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=blocking%2B", input: "key blocking+"}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=blocking%2B", input: "key blocking+"}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("Unescaped term in query");
|
||||
yield check_autocomplete({
|
||||
search: "key ユニコード",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=ユニコード", input: "key ユニコード"}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=ユニコード", input: "key ユニコード"}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword that happens to match a page");
|
||||
yield check_autocomplete({
|
||||
search: "key ThisPageIsInHistory",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=ThisPageIsInHistory", input: "key ThisPageIsInHistory"}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=ThisPageIsInHistory", input: "key ThisPageIsInHistory"}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword without query (without space)");
|
||||
yield check_autocomplete({
|
||||
search: "key",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=", input: "key"}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=", input: "key"}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("Keyword without query (with space)");
|
||||
yield check_autocomplete({
|
||||
search: "key ",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=", input: "key "}), title: "abc", style: [ "action", "keyword" ] } ]
|
||||
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=", input: "key "}), title: "abc", style: [ "action", "keyword", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
yield cleanup();
|
||||
|
@ -12,25 +12,25 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "doit",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("doit", { engineName: "AliasedMozSearch", searchQuery: "", alias: "doit" }) ]
|
||||
matches: [ makeSearchMatch("doit", { engineName: "AliasedMozSearch", searchQuery: "", alias: "doit", heuristic: true }) ]
|
||||
});
|
||||
|
||||
yield check_autocomplete({
|
||||
search: "doit ",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("doit ", { engineName: "AliasedMozSearch", searchQuery: "", alias: "doit" }) ]
|
||||
matches: [ makeSearchMatch("doit ", { engineName: "AliasedMozSearch", searchQuery: "", alias: "doit", heuristic: true }) ]
|
||||
});
|
||||
|
||||
yield check_autocomplete({
|
||||
search: "doit mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("doit mozilla", { engineName: "AliasedMozSearch", searchQuery: "mozilla", alias: "doit" }) ]
|
||||
matches: [ makeSearchMatch("doit mozilla", { engineName: "AliasedMozSearch", searchQuery: "mozilla", alias: "doit", heuristic: true }) ]
|
||||
});
|
||||
|
||||
yield check_autocomplete({
|
||||
search: "doit mozzarella mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("doit mozzarella mozilla", { engineName: "AliasedMozSearch", searchQuery: "mozzarella mozilla", alias: "doit" }) ]
|
||||
matches: [ makeSearchMatch("doit mozzarella mozilla", { engineName: "AliasedMozSearch", searchQuery: "mozzarella mozilla", alias: "doit", heuristic: true }) ]
|
||||
});
|
||||
|
||||
yield cleanup();
|
||||
|
@ -12,21 +12,21 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("mozilla") ]
|
||||
matches: [ makeSearchMatch("mozilla", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
do_print("search engine, uri-like input");
|
||||
yield check_autocomplete({
|
||||
search: "http:///",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("http:///") ]
|
||||
matches: [ makeSearchMatch("http:///", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
do_print("search engine, multiple words");
|
||||
yield check_autocomplete({
|
||||
search: "mozzarella cheese",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("mozzarella cheese") ]
|
||||
matches: [ makeSearchMatch("mozzarella cheese", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
do_print("search engine, after current engine has changed");
|
||||
@ -38,7 +38,7 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("mozilla", { engineName: "MozSearch2" }) ]
|
||||
matches: [ makeSearchMatch("mozilla", { engineName: "MozSearch2", heuristic: true }) ]
|
||||
});
|
||||
|
||||
yield cleanup();
|
||||
|
@ -24,7 +24,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "abc.com",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeVisitMatch("abc.com", "http://abc.com/"),
|
||||
matches: [ makeVisitMatch("abc.com", "http://abc.com/", { heuristic: true }),
|
||||
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }) ]
|
||||
});
|
||||
|
||||
@ -32,7 +32,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "abc",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("abc"),
|
||||
matches: [ makeSearchMatch("abc", { heuristic: true }),
|
||||
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
|
||||
{ uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
|
||||
});
|
||||
@ -42,7 +42,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "abc",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("abc"),
|
||||
matches: [ makeSearchMatch("abc", { heuristic: true }),
|
||||
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
|
||||
makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ]
|
||||
});
|
||||
@ -52,7 +52,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "abc",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("abc"),
|
||||
matches: [ makeSearchMatch("abc", { heuristic: true }),
|
||||
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
|
||||
makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ]
|
||||
});
|
||||
@ -61,7 +61,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "abc",
|
||||
searchParam: "enable-actions disable-private-actions",
|
||||
matches: [ makeSearchMatch("abc"),
|
||||
matches: [ makeSearchMatch("abc", { heuristic: true }),
|
||||
{ uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
|
||||
{ uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
|
||||
});
|
||||
@ -80,7 +80,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "abc",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("abc"),
|
||||
matches: [ makeSearchMatch("abc", { heuristic: true }),
|
||||
{ uri: uri1, title: "ABC rocks", style: [ "favicon" ] },
|
||||
{ uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ]
|
||||
});
|
||||
@ -90,7 +90,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: gTabRestrictChar + " abc",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch(gTabRestrictChar + " abc"),
|
||||
matches: [ makeSearchMatch(gTabRestrictChar + " abc", { heuristic: true }),
|
||||
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }) ]
|
||||
});
|
||||
|
||||
@ -98,7 +98,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: "mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("mozilla"),
|
||||
matches: [ makeSearchMatch("mozilla", { heuristic: true }),
|
||||
makeSwitchToTabMatch("about:mozilla") ]
|
||||
});
|
||||
|
||||
@ -106,7 +106,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: gTabRestrictChar + " mozilla",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch(gTabRestrictChar + " mozilla"),
|
||||
matches: [ makeSearchMatch(gTabRestrictChar + " mozilla", { heuristic: true }),
|
||||
makeSwitchToTabMatch("about:mozilla") ]
|
||||
});
|
||||
|
||||
@ -114,7 +114,7 @@ add_task(function* test_tab_matches() {
|
||||
yield check_autocomplete({
|
||||
search: gTabRestrictChar,
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch(gTabRestrictChar),
|
||||
matches: [ makeSearchMatch(gTabRestrictChar, { heuristic: true }),
|
||||
makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }),
|
||||
makeSwitchToTabMatch("about:mozilla"),
|
||||
makeSwitchToTabMatch("data:text/html,test") ]
|
||||
|
@ -7,21 +7,21 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "mozilla.org",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "http://mozilla.org/", input: "mozilla.org"}), title: "http://mozilla.org/", style: [ "action", "visiturl" ] } ]
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "http://mozilla.org/", input: "mozilla.org"}), title: "http://mozilla.org/", style: [ "action", "visiturl", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("visit url, with protocol");
|
||||
yield check_autocomplete({
|
||||
search: "https://mozilla.org",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "https://mozilla.org/", input: "https://mozilla.org"}), title: "https://mozilla.org/", style: [ "action", "visiturl" ] } ]
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "https://mozilla.org/", input: "https://mozilla.org"}), title: "https://mozilla.org/", style: [ "action", "visiturl", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
do_print("visit url, about: protocol (no host)");
|
||||
yield check_autocomplete({
|
||||
search: "about:config",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "about:config", input: "about:config"}), title: "about:config", style: [ "action", "visiturl" ] } ]
|
||||
matches: [ { uri: makeActionURI("visiturl", {url: "about:config", input: "about:config"}), title: "about:config", style: [ "action", "visiturl", "heuristic" ] } ]
|
||||
});
|
||||
|
||||
// This is distinct because of how we predict being able to url autofill via
|
||||
@ -33,7 +33,7 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "mozilla.org/rum",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeVisitMatch("mozilla.org/rum", "http://mozilla.org/rum") ]
|
||||
matches: [ makeVisitMatch("mozilla.org/rum", "http://mozilla.org/rum", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
// And hosts with no dot in them are special, due to requiring whitelisting.
|
||||
@ -44,7 +44,7 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "mozilla/rum",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeSearchMatch("mozilla/rum") ]
|
||||
matches: [ makeSearchMatch("mozilla/rum", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
// ipv4 and ipv6 literal addresses should offer to visit.
|
||||
@ -52,14 +52,14 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "127.0.0.1",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeVisitMatch("127.0.0.1", "http://127.0.0.1/") ]
|
||||
matches: [ makeVisitMatch("127.0.0.1", "http://127.0.0.1/", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
do_print("visit url, ipv6 literal");
|
||||
yield check_autocomplete({
|
||||
search: "[2001:db8::1]",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeVisitMatch("[2001:db8::1]", "http://[2001:db8::1]/") ]
|
||||
matches: [ makeVisitMatch("[2001:db8::1]", "http://[2001:db8::1]/", { heuristic: true }) ]
|
||||
});
|
||||
|
||||
// Setting keyword.enabled to false should always try to visit.
|
||||
@ -71,6 +71,6 @@ add_task(function*() {
|
||||
yield check_autocomplete({
|
||||
search: "bacon",
|
||||
searchParam: "enable-actions",
|
||||
matches: [ makeVisitMatch("bacon", "http://bacon/") ]
|
||||
matches: [ makeVisitMatch("bacon", "http://bacon/", { heuristic: true }) ]
|
||||
});
|
||||
});
|
||||
|
@ -1383,6 +1383,9 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
<property name="label" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
// This property is a string that is read aloud by screen readers,
|
||||
// so it must not contain anything that should not be user-facing.
|
||||
|
||||
var title = this.getAttribute("title");
|
||||
var url = this.getAttribute("url");
|
||||
var panel = this.parentNode.parentNode;
|
||||
@ -1391,15 +1394,9 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
// the label values for the richlistitems
|
||||
if (panel.createResultLabel) {
|
||||
let types = this.getAttribute("type").split(/\s+/);
|
||||
// We only want one type for createResultLabel, so get the first
|
||||
// that isn't "action".
|
||||
let type = types.find(v => v != "action");
|
||||
|
||||
return panel.createResultLabel(title, url, type);
|
||||
return panel.createResultLabel(title, url, types);
|
||||
}
|
||||
|
||||
// aType (ex: "ac-result-type-<aType>") is related to the class of the image,
|
||||
// and is not "visible" text so don't use it for the label (for accessibility).
|
||||
return title + " " + url;
|
||||
]]>
|
||||
</getter>
|
||||
@ -1691,10 +1688,18 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
this._titleOverflowEllipsis.hidden = false;
|
||||
|
||||
let types = new Set(type.split(/\s+/));
|
||||
|
||||
// Remove types that should ultimately not be in the `type` string.
|
||||
let initialTypes = new Set(types);
|
||||
types.delete("action");
|
||||
types.delete("autofill");
|
||||
types.delete("heuristic");
|
||||
types.delete("search");
|
||||
|
||||
type = [...types][0] || "";
|
||||
|
||||
// If the type includes an action, set up the item appropriately.
|
||||
if (types.has("action")) {
|
||||
if (initialTypes.has("action")) {
|
||||
let action = this._parseActionUrl(url);
|
||||
this.setAttribute("actiontype", action.type);
|
||||
|
||||
@ -1764,13 +1769,10 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
]);
|
||||
}
|
||||
|
||||
// Remove the "action" substring so that the correct style, if any,
|
||||
// is applied below.
|
||||
types.delete("action");
|
||||
}
|
||||
|
||||
// Check if we have a search engine name
|
||||
if (types.has("search")) {
|
||||
if (initialTypes.has("search")) {
|
||||
emphasiseUrl = false;
|
||||
|
||||
const TITLE_SEARCH_ENGINE_SEPARATOR = " \u00B7\u2013\u00B7 ";
|
||||
@ -1778,26 +1780,18 @@ extends="chrome://global/content/bindings/popup.xml#popup">
|
||||
let searchEngine = "";
|
||||
[title, searchEngine] = title.split(TITLE_SEARCH_ENGINE_SEPARATOR);
|
||||
displayUrl = this._stringBundle.formatStringFromName("searchWithEngine", [searchEngine], 1);
|
||||
|
||||
// Remove the "search" substring so that the correct style, if any,
|
||||
// is applied below.
|
||||
types.delete("search");
|
||||
}
|
||||
|
||||
// Check if we have an auto-fill URL
|
||||
if (types.has("autofill")) {
|
||||
if (initialTypes.has("autofill")) {
|
||||
emphasiseUrl = false;
|
||||
|
||||
let sourceStr = this._stringBundle.GetStringFromName("visitURL");
|
||||
title = this._generateEmphasisPairs(sourceStr, [
|
||||
[displayUrl, "match"],
|
||||
]);
|
||||
|
||||
types.delete("autofill");
|
||||
}
|
||||
|
||||
type = [...types].join(" ");
|
||||
|
||||
// If we have a tag match, show the tags and icon
|
||||
if (type == "tag" || type == "bookmark-tag") {
|
||||
// Configure the extra box for tags display
|
||||
|
Loading…
Reference in New Issue
Block a user