Bug 1125117 - Use the new keywords API in autocomplete. r=ttaubert

This commit is contained in:
Marco Bonardo 2015-03-26 21:16:07 +01:00
Родитель 7e6dfb40de
Коммит 80a46b8d07
27 изменённых файлов: 495 добавлений и 522 удалений

Просмотреть файл

@ -13,34 +13,34 @@ function* promise_first_result(inputText) {
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla");
let tabs = [tab];
registerCleanupFunction(() => {
registerCleanupFunction(function* () {
for (let tab of tabs)
gBrowser.removeTab(tab);
PlacesUtils.bookmarks.removeItem(itemId);
yield PlacesUtils.bookmarks.remove(bm);
});
yield promiseTabLoadEvent(tab);
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/?q=%s",
title: "test" });
yield PlacesUtils.keywords.insert({ keyword: "keyword",
url: "http://example.com/?q=%s" });
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");
is(result.getAttribute("actiontype"), "keyword", "Expect correct `actiontype` attribute");
is(result.getAttribute("title"), "test", "Expect correct title");
is(result.getAttribute("title"), "example.com", "Expect correct title");
// We need to make a real URI out of this to ensure it's normalised for
// comparison.
@ -50,9 +50,9 @@ add_task(function*() {
is_element_visible(result._title, "Title element should be visible");
is(result._title.childNodes.length, 1, "Title element should have 1 child");
is(result._title.childNodes[0].nodeName, "#text", "That child should be a text node");
is(result._title.childNodes[0].data, "test", "Node should contain the name of the bookmark");
is(result._title.childNodes[0].data, "example.com", "Node should contain the name of the bookmark");
is_element_visible(result._extra, "Extra element should be visible");
is_element_visible(result._extraBox, "Extra element should be visible");
is(result._extra.childNodes.length, 1, "Title element should have 1 child");
is(result._extra.childNodes[0].nodeName, "span", "That child should be a span node");
let span = result._extra.childNodes[0];

Просмотреть файл

@ -1,19 +1,19 @@
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
PlacesUtils.bookmarks.removeItem(itemId);
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/?q=%s",
title: "test" });
yield PlacesUtils.keywords.insert({ keyword: "keyword",
url: "http://example.com/?q=%s" })
registerCleanupFunction(function* () {
yield PlacesUtils.bookmarks.remove(bm);
});
yield promiseAutocompleteResultPopup("keyword search");
@ -21,12 +21,12 @@ add_task(function*() {
info("Before override");
is_element_hidden(result._url, "URL element should be hidden");
is_element_visible(result._extra, "Extra element should be visible");
is_element_visible(result._extraBox, "Extra element should be visible");
info("During override");
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keydown" });
is_element_hidden(result._url, "URL element should be hidden");
is_element_visible(result._extra, "Extra element should be visible");
is_element_visible(result._extraBox, "Extra element should be visible");
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keyup" });

Просмотреть файл

@ -3,10 +3,11 @@
add_task(function* () {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
Services.search.addEngineWithDetails("MozSearch", "", "", "", "GET",
"http://example.com/?q={searchTerms}");

Просмотреть файл

@ -4,7 +4,12 @@
**/
add_task(function* () {
// This test is only relevant if UnifiedComplete is enabled.
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let iconURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET",
@ -20,7 +25,6 @@ add_task(function* () {
Services.search.currentEngine = originalEngine;
let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine);
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
try {
gBrowser.removeTab(tab);

Просмотреть файл

@ -3,10 +3,11 @@
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let tab = gBrowser.addTab("about:about");
yield promiseTabLoaded(tab);

Просмотреть файл

@ -10,12 +10,15 @@ function is_selected(index) {
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
registerCleanupFunction(() => PlacesTestUtils.clearHistory());
registerCleanupFunction(function* () {
yield PlacesTestUtils.clearHistory();
});
let visits = [];
repeat(10, i => {

Просмотреть файл

@ -3,16 +3,15 @@ add_task(function*() {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
yield PlacesUtils.bookmarks.remove(bm);
});
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
let bm = yield PlacesUtils.bookmarks.insert({ parentGuid: PlacesUtils.unfiledGuid,
url: "http://example.com/?q=%s",
title: "test" });
yield PlacesUtils.keywords.insert({ keyword: "keyword",
url: "http://example.com/?q=%s" });
yield new Promise(resolve => waitForFocus(resolve, window));

Просмотреть файл

@ -3,10 +3,11 @@
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);

Просмотреть файл

@ -15,8 +15,7 @@ add_task(function*() {
return;
}
registerCleanupFunction(() => PlacesTestUtils.clearHistory());
yield PlacesTestUtils.clearHistory();
let visits = [];
repeat(10, i => {
visits.push({
@ -25,13 +24,18 @@ add_task(function*() {
});
yield PlacesTestUtils.addVisits(visits);
registerCleanupFunction(function* () {
yield PlacesTestUtils.clearHistory();
});
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);
yield promiseAutocompleteResultPopup("example.com/autocomplete");
let popup = gURLBar.popup;
let results = popup.richlistbox.children;
is(results.length, 10, "Should get 11 results");
let results = popup.richlistbox.children.filter(is_visible);
is(results.length, 10, "Should get 10 results");
is_selected(-1);
info("Key Down to select the next item");

Просмотреть файл

@ -4,10 +4,11 @@
add_task(function* test_switchtab_override() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let testURL = "http://example.org/browser/browser/base/content/test/general/dummy_page.html";

Просмотреть файл

@ -7,29 +7,32 @@ function is_selected(index) {
add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled.
if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
todo(false, "Stop supporting old autocomplete components.");
return;
}
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete");
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true);
registerCleanupFunction(() => {
PlacesUtils.bookmarks.removeFolderChildren(PlacesUtils.unfiledBookmarksFolderId);
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref);
});
let itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/?q=%s"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"test");
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, "keyword");
let bookmarks = [];
bookmarks.push((yield PlacesUtils.bookmarks
.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/?q=%s",
title: "test" })));
yield PlacesUtils.keywords.insert({ keyword: "keyword",
url: "http://example.com/?q=%s" });
// This item only needed so we can select the keyword item, select something
// else, then select the keyword item again.
itemId =
PlacesUtils.bookmarks.insertBookmark(PlacesUtils.unfiledBookmarksFolderId,
NetUtil.newURI("http://example.com/keyword"),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"keyword abc");
bookmarks.push((yield PlacesUtils.bookmarks
.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: "http://example.com/keyword",
title: "keyword abc" })));
registerCleanupFunction(function* () {
for (let bm of bookmarks) {
yield PlacesUtils.bookmarks.remove(bm);
}
});
let tab = gBrowser.selectedTab = gBrowser.addTab("about:mozilla", {animate: false});
yield promiseTabLoaded(tab);

Просмотреть файл

@ -16,7 +16,9 @@ function is_selected(index) {
}
add_task(function*() {
registerCleanupFunction(() => PlacesTestUtils.clearHistory());
registerCleanupFunction(function* () {
yield PlacesTestUtils.clearHistory();
});
yield PlacesTestUtils.clearHistory();
let tabCount = gBrowser.tabs.length;

Просмотреть файл

@ -46,11 +46,10 @@ const MATCH_BEGINNING_CASE_SENSITIVE = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING
// AutoComplete query type constants.
// Describes the various types of queries that we can process rows for.
const QUERYTYPE_KEYWORD = 0;
const QUERYTYPE_FILTERED = 1;
const QUERYTYPE_AUTOFILL_HOST = 2;
const QUERYTYPE_AUTOFILL_URL = 3;
const QUERYTYPE_AUTOFILL_PREDICTURL = 4;
const QUERYTYPE_FILTERED = 0;
const QUERYTYPE_AUTOFILL_HOST = 1;
const QUERYTYPE_AUTOFILL_URL = 2;
const QUERYTYPE_AUTOFILL_PREDICTURL = 3;
// This separator is used as an RTL-friendly way to split the title and tags.
// It can also be used by an nsIAutoCompleteResult consumer to re-split the
@ -64,7 +63,7 @@ const TITLE_SEARCH_ENGINE_SEPARATOR = " \u00B7\u2013\u00B7 ";
const TELEMETRY_1ST_RESULT = "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS";
const TELEMETRY_6_FIRST_RESULTS = "PLACES_AUTOCOMPLETE_6_FIRST_RESULTS_TIME_MS";
// The default frecency value used when inserting matches with unknown frecency.
const FRECENCY_SEARCHENGINES_DEFAULT = 1000;
const FRECENCY_DEFAULT = 1000;
// Sqlite result row index constants.
const QUERYINDEX_QUERYTYPE = 0;
@ -149,23 +148,6 @@ const SQL_ADAPTIVE_QUERY =
:matchBehavior, :searchBehavior)
ORDER BY rank DESC, h.frecency DESC`;
const SQL_KEYWORD_QUERY =
`/* do not warn (bug 487787) */
SELECT :query_type,
REPLACE(h.url, '%s', :query_string) AS search_url, h.title,
IFNULL(f.url, (SELECT f.url
FROM moz_places
JOIN moz_favicons f ON f.id = favicon_id
WHERE rev_host = h.rev_host
ORDER BY frecency DESC
LIMIT 1)
),
1, NULL, NULL, h.visit_count, h.typed, h.id, t.open_count, h.frecency
FROM moz_keywords k
JOIN moz_places h ON k.place_id = h.id
LEFT JOIN moz_favicons f ON f.id = h.favicon_id
LEFT JOIN moz_openpages_temp t ON t.url = search_url
WHERE k.keyword = LOWER(:keyword)`;
function hostQuery(conditions = "") {
let query =
@ -731,6 +713,8 @@ Search.prototype = {
// Since we call the synchronous parseSubmissionURL function later, we must
// wait for the initialization of PlacesSearchAutocompleteProvider first.
yield PlacesSearchAutocompleteProvider.ensureInitialized();
if (!this.pending)
return;
// For any given search, we run many queries/heuristics:
// 1) by alias (as defined in SearchService)
@ -738,7 +722,7 @@ Search.prototype = {
// 3) inline completion for hosts (this._hostQuery) or urls (this._urlQuery)
// 4) directly typed in url (ie, can be navigated to as-is)
// 5) submission for the current search engine
// 6) keywords (this._keywordQuery)
// 6) Places keywords
// 7) adaptive learning (this._adaptiveQuery)
// 8) open pages not supported by history (this._switchToTabQuery)
// 9) query based on match behavior
@ -772,15 +756,13 @@ Search.prototype = {
// special results.
let hasFirstResult = false;
if (this._searchTokens.length > 0 &&
PlacesUtils.bookmarks.getURIForKeyword(this._searchTokens[0])) {
// This may be a keyword of a bookmark.
queries.unshift(this._keywordQuery);
hasFirstResult = true;
if (this._searchTokens.length > 0) {
// This may be a Places keyword.
hasFirstResult = yield this._matchPlacesKeyword();
}
if (this._enableActions && !hasFirstResult) {
// If it's not a bookmarked keyword, then it may be a search engine
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();
}
@ -875,6 +857,35 @@ Search.prototype = {
return gotResult;
},
_matchPlacesKeyword: function* () {
// The first word could be a keyword, so that's what we'll search.
let keyword = this._searchTokens[0];
let entry = yield PlacesUtils.keywords.fetch(this._searchTokens[0]);
if (!entry)
return false;
// Build the url.
let searchString = this._trimmedOriginalSearchString;
let queryString = "";
let queryIndex = searchString.indexOf(" ");
if (queryIndex != -1) {
queryString = searchString.substring(queryIndex + 1);
}
// We need to escape the parameters as if they were the query in a URL
queryString = encodeURIComponent(queryString).replace(/%20/g, "+");
let escapedURL = entry.url.href.replace("%s", queryString);
let style = (this._enableActions ? "action " : "") + "keyword";
let actionURL = makeActionURL("keyword", { url: escapedURL,
input: this._originalSearchString });
let value = this._enableActions ? actionURL : escapedURL;
// The title will end up being "host: queryString"
let comment = entry.url.host;
this._addMatch({ value, comment, style, frecency: FRECENCY_DEFAULT });
return true;
},
_matchSearchEngineUrl: function* () {
if (!Prefs.autofillSearchEngines)
return false;
@ -922,7 +933,7 @@ Search.prototype = {
icon: match.iconUrl,
style: "priority-search",
finalCompleteValue: match.url,
frecency: FRECENCY_SEARCHENGINES_DEFAULT
frecency: FRECENCY_DEFAULT
});
return true;
},
@ -969,7 +980,7 @@ Search.prototype = {
comment: match.engineName,
icon: match.iconUrl,
style: "action searchengine",
frecency: FRECENCY_SEARCHENGINES_DEFAULT,
frecency: FRECENCY_DEFAULT,
});
},
@ -1052,7 +1063,6 @@ Search.prototype = {
match = this._processUrlRow(row);
break;
case QUERYTYPE_FILTERED:
case QUERYTYPE_KEYWORD:
match = this._processRow(row);
break;
}
@ -1236,17 +1246,6 @@ Search.prototype = {
// Always prefer the bookmark title unless it is empty
let title = bookmarkTitle || historyTitle;
if (queryType == QUERYTYPE_KEYWORD) {
match.style = "keyword";
if (this._enableActions) {
url = makeActionURL("keyword", {
url: escapedURL,
input: this._originalSearchString,
});
action = "keyword";
}
}
// We will always prefer to show tags if we have them.
let showTags = !!tags;
@ -1352,37 +1351,6 @@ Search.prototype = {
];
},
/**
* Obtains the query to search for keywords.
*
* @return an array consisting of the correctly optimized query to search the
* database with and an object containing the params to bound.
*/
get _keywordQuery() {
// The keyword is the first word in the search string, with the parameters
// following it.
let searchString = this._trimmedOriginalSearchString;
let queryString = "";
let queryIndex = searchString.indexOf(" ");
if (queryIndex != -1) {
queryString = searchString.substring(queryIndex + 1);
}
// We need to escape the parameters as if they were the query in a URL
queryString = encodeURIComponent(queryString).replace(/%20/g, "+");
// The first word could be a keyword, so that's what we'll search.
let keyword = this._searchTokens[0];
return [
SQL_KEYWORD_QUERY,
{
keyword: keyword,
query_string: queryString,
query_type: QUERYTYPE_KEYWORD
}
];
},
/**
* Obtains the query to search for switch-to-tab entries.
*

Просмотреть файл

@ -12,6 +12,8 @@ XPCOMUtils.defineLazyModuleGetter(this, "TelemetryStopwatch",
"resource://gre/modules/TelemetryStopwatch.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Task",
"resource://gre/modules/Task.jsm");
////////////////////////////////////////////////////////////////////////////////
//// Constants
@ -1168,16 +1170,8 @@ nsPlacesAutoComplete.prototype = {
let style;
if (aRow.getResultByIndex(kQueryIndexQueryType) == kQueryTypeKeyword) {
// If we do not have a title, then we must have a keyword, so let the UI
// know it is a keyword. Otherwise, we found an exact page match, so just
// show the page like a regular result. Because the page title is likely
// going to be more specific than the bookmark title (keyword title).
if (!entryTitle) {
style = "keyword";
}
else {
title = entryTitle;
}
style = "keyword";
title = NetUtil.newURI(escapedEntryURL).host;
}
// We will always prefer to show tags if we have them.
@ -1432,6 +1426,8 @@ urlInlineComplete.prototype = {
this.stopSearch();
}
let pendingSearch = this._pendingSearch = {};
// We want to store the original string with no leading or trailing
// whitespace for case sensitive searches.
this._originalSearchString = aSearchString;
@ -1450,74 +1446,82 @@ urlInlineComplete.prototype = {
this._listener = aListener;
// Don't autoFill if the search term is recognized as a keyword, otherwise
// it will override default keywords behavior. Note that keywords are
// hashed on first use, so while the first query may delay a little bit,
// next ones will just hit the memory hash.
if (this._currentSearchString.length == 0 || !this._db ||
PlacesUtils.bookmarks.getURIForKeyword(this._currentSearchString)) {
this._finishSearch();
return;
}
// Don't try to autofill if the search term includes any whitespace.
// This may confuse completeDefaultIndex cause the AUTOCOMPLETE_MATCH
// tokenizer ends up trimming the search string and returning a value
// that doesn't match it, or is even shorter.
if (/\s/.test(this._currentSearchString)) {
this._finishSearch();
return;
}
// Hosts have no "/" in them.
let lastSlashIndex = this._currentSearchString.lastIndexOf("/");
// Search only URLs if there's a slash in the search string...
if (lastSlashIndex != -1) {
// ...but not if it's exactly at the end of the search string.
if (lastSlashIndex < this._currentSearchString.length - 1)
this._queryURL();
else
Task.spawn(function* () {
// Don't autoFill if the search term is recognized as a keyword, otherwise
// it will override default keywords behavior. Note that keywords are
// hashed on first use, so while the first query may delay a little bit,
// next ones will just hit the memory hash.
let dontAutoFill = this._currentSearchString.length == 0 || !this._db ||
(yield PlacesUtils.keywords.fetch(this._currentSearchString));
if (this._pendingSearch != pendingSearch)
return;
if (dontAutoFill) {
this._finishSearch();
return;
}
// Do a synchronous search on the table of hosts.
let query = this._hostQuery;
query.params.search_string = this._currentSearchString.toLowerCase();
// This is just to measure the delay to reach the UI, not the query time.
TelemetryStopwatch.start(DOMAIN_QUERY_TELEMETRY);
let ac = this;
let wrapper = new AutoCompleteStatementCallbackWrapper(this, {
handleResult: function (aResultSet) {
let row = aResultSet.getNextRow();
let trimmedHost = row.getResultByIndex(0);
let untrimmedHost = row.getResultByIndex(1);
// If the untrimmed value doesn't preserve the user's input just
// ignore it and complete to the found host.
if (untrimmedHost &&
!untrimmedHost.toLowerCase().contains(ac._originalSearchString.toLowerCase())) {
untrimmedHost = null;
}
ac._result.appendMatch(ac._strippedPrefix + trimmedHost, "", "", "", untrimmedHost);
// handleCompletion() will cause the result listener to be called, and
// will display the result in the UI.
},
handleError: function (aError) {
Components.utils.reportError(
"URL Inline Complete: An async statement encountered an " +
"error: " + aError.result + ", '" + aError.message + "'");
},
handleCompletion: function (aReason) {
TelemetryStopwatch.finish(DOMAIN_QUERY_TELEMETRY);
ac._finishSearch();
return;
}
}, this._db);
this._pendingQuery = wrapper.executeAsync([query]);
// Don't try to autofill if the search term includes any whitespace.
// This may confuse completeDefaultIndex cause the AUTOCOMPLETE_MATCH
// tokenizer ends up trimming the search string and returning a value
// that doesn't match it, or is even shorter.
if (/\s/.test(this._currentSearchString)) {
this._finishSearch();
return;
}
// Hosts have no "/" in them.
let lastSlashIndex = this._currentSearchString.lastIndexOf("/");
// Search only URLs if there's a slash in the search string...
if (lastSlashIndex != -1) {
// ...but not if it's exactly at the end of the search string.
if (lastSlashIndex < this._currentSearchString.length - 1)
this._queryURL();
else
this._finishSearch();
return;
}
// Do a synchronous search on the table of hosts.
let query = this._hostQuery;
query.params.search_string = this._currentSearchString.toLowerCase();
// This is just to measure the delay to reach the UI, not the query time.
TelemetryStopwatch.start(DOMAIN_QUERY_TELEMETRY);
let wrapper = new AutoCompleteStatementCallbackWrapper(this, {
handleResult: aResultSet => {
if (this._pendingSearch != pendingSearch)
return;
let row = aResultSet.getNextRow();
let trimmedHost = row.getResultByIndex(0);
let untrimmedHost = row.getResultByIndex(1);
// If the untrimmed value doesn't preserve the user's input just
// ignore it and complete to the found host.
if (untrimmedHost &&
!untrimmedHost.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
untrimmedHost = null;
}
this._result.appendMatch(this._strippedPrefix + trimmedHost, "", "", "", untrimmedHost);
// handleCompletion() will cause the result listener to be called, and
// will display the result in the UI.
},
handleError: aError => {
Components.utils.reportError(
"URL Inline Complete: An async statement encountered an " +
"error: " + aError.result + ", '" + aError.message + "'");
},
handleCompletion: aReason => {
if (this._pendingSearch != pendingSearch)
return;
TelemetryStopwatch.finish(DOMAIN_QUERY_TELEMETRY);
this._finishSearch();
}
}, this._db);
this._pendingQuery = wrapper.executeAsync([query]);
}.bind(this));
},
/**
@ -1546,9 +1550,8 @@ urlInlineComplete.prototype = {
params.searchString = this._currentSearchString;
// Execute the query.
let ac = this;
let wrapper = new AutoCompleteStatementCallbackWrapper(this, {
handleResult: function(aResultSet) {
handleResult: aResultSet => {
let row = aResultSet.getNextRow();
let value = row.getResultByIndex(0);
let url = fixupSearchText(value);
@ -1556,10 +1559,10 @@ urlInlineComplete.prototype = {
let prefix = value.slice(0, value.length - stripPrefix(value).length);
// We must complete the URL up to the next separator (which is /, ? or #).
let separatorIndex = url.slice(ac._currentSearchString.length)
let separatorIndex = url.slice(this._currentSearchString.length)
.search(/[\/\?\#]/);
if (separatorIndex != -1) {
separatorIndex += ac._currentSearchString.length;
separatorIndex += this._currentSearchString.length;
if (url[separatorIndex] == "/") {
separatorIndex++; // Include the "/" separator
}
@ -1571,24 +1574,24 @@ urlInlineComplete.prototype = {
// ignore it and complete to the found url.
let untrimmedURL = prefix + url;
if (untrimmedURL &&
!untrimmedURL.toLowerCase().contains(ac._originalSearchString.toLowerCase())) {
!untrimmedURL.toLowerCase().contains(this._originalSearchString.toLowerCase())) {
untrimmedURL = null;
}
ac._result.appendMatch(ac._strippedPrefix + url, "", "", "", untrimmedURL);
this._result.appendMatch(this._strippedPrefix + url, "", "", "", untrimmedURL);
// handleCompletion() will cause the result listener to be called, and
// will display the result in the UI.
},
handleError: function(aError) {
handleError: aError => {
Components.utils.reportError(
"URL Inline Complete: An async statement encountered an " +
"error: " + aError.result + ", '" + aError.message + "'");
},
handleCompletion: function(aReason) {
ac._finishSearch();
handleCompletion: aReason => {
this._finishSearch();
}
}, this._db);
this._pendingQuery = wrapper.executeAsync([query]);
@ -1600,6 +1603,7 @@ urlInlineComplete.prototype = {
delete this._currentSearchString;
delete this._result;
delete this._listener;
delete this._pendingSearch;
if (this._pendingQuery) {
this._pendingQuery.cancel();

Просмотреть файл

@ -38,18 +38,20 @@ let kURIs = [
let kTitles = [
"Generic page title",
"Keyword title",
"abc",
"xyz"
];
// Add the keyword bookmark
addPageBook(0, 0, 1, [], keyKey);
// Add in the "fake pages" for keyword searches
gPages[1] = [1,0];
gPages[2] = [2,0];
gPages[3] = [3,0];
gPages[4] = [4,0];
gPages[1] = [1,2];
gPages[2] = [2,2];
gPages[3] = [3,2];
gPages[4] = [4,2];
// Add a page into history
addPageBook(5, 0);
gPages[6] = [6,0];
addPageBook(5, 2);
gPages[6] = [6,2];
// Provide for each test: description; search terms; array of gPages indices of
// pages that should match; optional function to be run before the test

Просмотреть файл

@ -122,26 +122,33 @@ function ensure_results(aSearchString, aExpectedValue) {
do_check_eq(numSearchesStarted, 1);
};
input.onSearchComplete = function() {
// We should be running only one query.
do_check_eq(numSearchesStarted, 1);
// Check the autoFilled result.
do_check_eq(input.textValue, autoFilledValue);
let promise = new Promise(resolve => {
input.onSearchComplete = function() {
// We should be running only one query.
do_check_eq(numSearchesStarted, 1);
if (completedValue) {
// Now force completion and check correct casing of the result.
// This ensures the controller is able to do its magic case-preserving
// stuff and correct replacement of the user's casing with result's one.
controller.handleEnter(false);
do_check_eq(input.textValue, completedValue);
}
// Check the autoFilled result.
do_check_eq(input.textValue, autoFilledValue);
waitForCleanup(run_next_test);
};
if (completedValue) {
// Now force completion and check correct casing of the result.
// This ensures the controller is able to do its magic case-preserving
// stuff and correct replacement of the user's casing with result's one.
controller.handleEnter(false);
do_check_eq(input.textValue, completedValue);
}
// Cleanup.
remove_all_bookmarks();
PlacesTestUtils.clearHistory().then(resolve);
};
});
do_print("Searching for: '" + aSearchString + "'");
controller.startSearch(aSearchString);
return promise;
}
function run_test() {
@ -153,22 +160,22 @@ function run_test() {
gAutoCompleteTests.forEach(function (testData) {
let [description, searchString, expectedValue, setupFunc] = testData;
add_test(function () {
add_task(function* () {
do_print(description);
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", true);
Services.prefs.setBoolPref("browser.urlbar.autoFill", true);
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
if (setupFunc) {
setupFunc();
yield setupFunc();
}
// At this point frecency could still be updating due to latest pages
// updates.
// This is not a problem in real life, but autocomplete tests should
// return reliable resultsets, thus we have to wait.
PlacesTestUtils.promiseAsyncUpdates()
.then(() => ensure_results(searchString, expectedValue));
yield PlacesTestUtils.promiseAsyncUpdates();
yield ensure_results(searchString, expectedValue);
})
}, this);
@ -180,21 +187,13 @@ function add_autocomplete_test(aTestData) {
gAutoCompleteTests.push(aTestData);
}
function waitForCleanup(aCallback) {
remove_all_bookmarks();
PlacesTestUtils.clearHistory().then(aCallback);
}
function addBookmark(aBookmarkObj) {
function* addBookmark(aBookmarkObj) {
do_check_true(!!aBookmarkObj.url);
let parentId = aBookmarkObj.parentId ? aBookmarkObj.parentId
: PlacesUtils.unfiledBookmarksFolderId;
let itemId = PlacesUtils.bookmarks
.insertBookmark(parentId,
NetUtil.newURI(aBookmarkObj.url),
PlacesUtils.bookmarks.DEFAULT_INDEX,
"A bookmark");
yield PlacesUtils.bookmarks
.insert({ parentGuid: PlacesUtils.bookmarks.unfiledGuid,
url: aBookmarkObj.url });
if (aBookmarkObj.keyword) {
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, aBookmarkObj.keyword);
yield PlacesUtils.keywords.insert({ keyword: aBookmarkObj.keyword,
url: aBookmarkObj.url });
}
}

Просмотреть файл

@ -8,10 +8,9 @@ add_autocomplete_test([
"Check disabling autocomplete disables autofill",
"vis",
"vis",
function ()
{
function* () {
Services.prefs.setBoolPref("browser.urlbar.autocomplete.enabled", false);
PlacesTestUtils.addVisits({
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://visit.mozilla.org"),
transition: TRANSITION_TYPED
});
@ -22,10 +21,9 @@ add_autocomplete_test([
"Check disabling autofill disables autofill",
"vis",
"vis",
function ()
{
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill", false);
PlacesTestUtils.addVisits({
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://visit.mozilla.org"),
transition: TRANSITION_TYPED
});
@ -36,12 +34,11 @@ add_autocomplete_test([
"Add urls, check for correct order",
"vis",
"visit2.mozilla.org/",
function ()
{
function* () {
let places = [{ uri: NetUtil.newURI("http://visit1.mozilla.org") },
{ uri: NetUtil.newURI("http://visit2.mozilla.org"),
transition: TRANSITION_TYPED }];
PlacesTestUtils.addVisits(places);
yield PlacesTestUtils.addVisits(places);
}
]);
@ -49,9 +46,8 @@ add_autocomplete_test([
"Add urls, make sure www and http are ignored",
"visit1",
"visit1.mozilla.org/",
function ()
{
PlacesTestUtils.addVisits(NetUtil.newURI("http://www.visit1.mozilla.org"));
function* () {
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://www.visit1.mozilla.org"));
}
]);
@ -59,9 +55,8 @@ add_autocomplete_test([
"Autocompleting after an existing host completes to the url",
"visit3.mozilla.org/",
"visit3.mozilla.org/",
function ()
{
PlacesTestUtils.addVisits(NetUtil.newURI("http://www.visit3.mozilla.org"));
function* () {
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://www.visit3.mozilla.org"));
}
]);
@ -69,9 +64,8 @@ add_autocomplete_test([
"Searching for www.me should yield www.me.mozilla.org/",
"www.me",
"www.me.mozilla.org/",
function ()
{
PlacesTestUtils.addVisits(NetUtil.newURI("http://www.me.mozilla.org"));
function* () {
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://www.me.mozilla.org"));
}
]);
@ -79,10 +73,9 @@ add_autocomplete_test([
"With a bookmark and history, the query result should be the bookmark",
"bookmark",
"bookmark1.mozilla.org/",
function ()
{
addBookmark({ url: "http://bookmark1.mozilla.org/", });
PlacesTestUtils.addVisits(NetUtil.newURI("http://bookmark1.mozilla.org/foo"));
function* () {
yield addBookmark({ url: "http://bookmark1.mozilla.org/", });
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://bookmark1.mozilla.org/foo"));
}
]);
@ -90,12 +83,10 @@ add_autocomplete_test([
"Check to make sure we get the proper results with full paths",
"smokey",
"smokey.mozilla.org/",
function ()
{
function* () {
let places = [{ uri: NetUtil.newURI("http://smokey.mozilla.org/foo/bar/baz?bacon=delicious") },
{ uri: NetUtil.newURI("http://smokey.mozilla.org/foo/bar/baz?bacon=smokey") }];
PlacesTestUtils.addVisits(places);
yield PlacesTestUtils.addVisits(places);
}
]);
@ -103,12 +94,10 @@ add_autocomplete_test([
"Check to make sure we autocomplete to the following '/'",
"smokey.mozilla.org/fo",
"smokey.mozilla.org/foo/",
function ()
{
function* () {
let places = [{ uri: NetUtil.newURI("http://smokey.mozilla.org/foo/bar/baz?bacon=delicious") },
{ uri: NetUtil.newURI("http://smokey.mozilla.org/foo/bar/baz?bacon=smokey") }];
PlacesTestUtils.addVisits(places);
yield PlacesTestUtils.addVisits(places);
}
]);
@ -116,9 +105,8 @@ add_autocomplete_test([
"Check to make sure we autocomplete after ?",
"smokey.mozilla.org/foo?",
"smokey.mozilla.org/foo?bacon=delicious",
function ()
{
PlacesTestUtils.addVisits(NetUtil.newURI("http://smokey.mozilla.org/foo?bacon=delicious"));
function* () {
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://smokey.mozilla.org/foo?bacon=delicious"));
}
]);
@ -126,8 +114,7 @@ add_autocomplete_test([
"Check to make sure we autocomplete after #",
"smokey.mozilla.org/foo?bacon=delicious#bar",
"smokey.mozilla.org/foo?bacon=delicious#bar",
function ()
{
PlacesTestUtils.addVisits(NetUtil.newURI("http://smokey.mozilla.org/foo?bacon=delicious#bar"));
function* () {
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://smokey.mozilla.org/foo?bacon=delicious#bar"));
}
]);

Просмотреть файл

@ -6,8 +6,8 @@ add_autocomplete_test([
"Searching for cased entry 1",
"MOZ",
{ autoFilled: "MOZilla.org/", completed: "mozilla.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/test/") });
}
]);
@ -15,8 +15,8 @@ add_autocomplete_test([
"Searching for cased entry 2",
"mozilla.org/T",
{ autoFilled: "mozilla.org/T", completed: "mozilla.org/T" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/test/") });
}
]);
@ -24,8 +24,8 @@ add_autocomplete_test([
"Searching for cased entry 3",
"mozilla.org/T",
{ autoFilled: "mozilla.org/Test/", completed: "http://mozilla.org/Test/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
}
]);
@ -33,8 +33,8 @@ add_autocomplete_test([
"Searching for cased entry 4",
"mOzilla.org/t",
{ autoFilled: "mOzilla.org/t", completed: "mOzilla.org/t" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
},
]);
@ -42,8 +42,8 @@ add_autocomplete_test([
"Searching for cased entry 5",
"mOzilla.org/T",
{ autoFilled: "mOzilla.org/Test/", completed: "http://mozilla.org/Test/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
},
]);
@ -51,8 +51,8 @@ add_autocomplete_test([
"Searching for untrimmed cased entry",
"http://mOz",
{ autoFilled: "http://mOzilla.org/", completed: "http://mozilla.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
},
]);
@ -60,8 +60,8 @@ add_autocomplete_test([
"Searching for untrimmed cased entry with www",
"http://www.mOz",
{ autoFilled: "http://www.mOzilla.org/", completed: "http://www.mozilla.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.mozilla.org/Test/") });
},
]);
@ -69,8 +69,8 @@ add_autocomplete_test([
"Searching for untrimmed cased entry with path",
"http://mOzilla.org/t",
{ autoFilled: "http://mOzilla.org/t", completed: "http://mOzilla.org/t" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
},
]);
@ -78,8 +78,8 @@ add_autocomplete_test([
"Searching for untrimmed cased entry with path 2",
"http://mOzilla.org/T",
{ autoFilled: "http://mOzilla.org/Test/", completed: "http://mozilla.org/Test/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/Test/") });
},
]);
@ -87,8 +87,8 @@ add_autocomplete_test([
"Searching for untrimmed cased entry with www and path",
"http://www.mOzilla.org/t",
{ autoFilled: "http://www.mOzilla.org/t", completed: "http://www.mOzilla.org/t" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.mozilla.org/Test/") });
},
]);
@ -96,7 +96,7 @@ add_autocomplete_test([
"Searching for untrimmed cased entry with www and path 2",
"http://www.mOzilla.org/T",
{ autoFilled: "http://www.mOzilla.org/Test/", completed: "http://www.mozilla.org/Test/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.mozilla.org/Test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.mozilla.org/Test/") });
},
]);

Просмотреть файл

@ -9,8 +9,8 @@ add_autocomplete_test([
"Do not autofill whitespaced entry 1",
"mozilla.org ",
"mozilla.org ",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED
});
@ -21,8 +21,8 @@ add_autocomplete_test([
"Do not autofill whitespaced entry 2",
"mozilla.org/ ",
"mozilla.org/ ",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED
});
@ -33,8 +33,8 @@ add_autocomplete_test([
"Do not autofill whitespaced entry 3",
"mozilla.org/link ",
"mozilla.org/link ",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED
});
@ -45,8 +45,8 @@ add_autocomplete_test([
"Do not autofill whitespaced entry 4",
"mozilla.org/link/ ",
"mozilla.org/link/ ",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED
});
@ -58,8 +58,8 @@ add_autocomplete_test([
"Do not autofill whitespaced entry 5",
"moz illa ",
"moz illa ",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED
});
@ -70,8 +70,8 @@ add_autocomplete_test([
"Do not autofill whitespaced entry 6",
" mozilla",
" mozilla",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED
});

Просмотреть файл

@ -6,8 +6,8 @@ add_autocomplete_test([
"Searching for non-keyworded entry should autoFill it",
"moz",
"mozilla.org/",
function () {
addBookmark({ url: "http://mozilla.org/test/" });
function* () {
yield addBookmark({ url: "http://mozilla.org/test/" });
}
]);
@ -15,8 +15,8 @@ add_autocomplete_test([
"Searching for keyworded entry should not autoFill it",
"moz",
"moz",
function () {
addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
function* () {
yield addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
}
]);
@ -24,8 +24,8 @@ add_autocomplete_test([
"Searching for more than keyworded entry should autoFill it",
"mozi",
"mozilla.org/",
function () {
addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
function* () {
yield addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
}
]);
@ -33,8 +33,8 @@ add_autocomplete_test([
"Searching for less than keyworded entry should autoFill it",
"mo",
"mozilla.org/",
function () {
addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
function* () {
yield addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
}
]);
@ -42,7 +42,7 @@ add_autocomplete_test([
"Searching for keyworded entry is case-insensitive",
"MoZ",
"MoZ",
function () {
addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
function* () {
yield addBookmark({ url: "http://mozilla.org/test/", keyword: "moz" });
}
]);

Просмотреть файл

@ -6,8 +6,8 @@ add_autocomplete_test([
"Searching for host match without slash should match host",
"file",
"file.org/",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://file.org/test/"),
transition: TRANSITION_TYPED
}, {
@ -21,8 +21,8 @@ add_autocomplete_test([
"Searching match with slash at the end should do nothing",
"file.org/",
"file.org/",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://file.org/test/"),
transition: TRANSITION_TYPED
}, {
@ -36,8 +36,8 @@ add_autocomplete_test([
"Searching match with slash in the middle should match url",
"file.org/t",
"file.org/test/",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://file.org/test/"),
transition: TRANSITION_TYPED
}, {
@ -51,8 +51,8 @@ add_autocomplete_test([
"Searching for non-host match without slash should not match url",
"file",
"file",
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("file:///c:/test.html"),
transition: TRANSITION_TYPED
});

Просмотреть файл

@ -6,8 +6,8 @@ add_autocomplete_test([
"Searching for untrimmed https://www entry",
"mo",
{ autoFilled: "mozilla.org/", completed: "https://www.mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -18,8 +18,8 @@ add_autocomplete_test([
"Searching for untrimmed https://www entry with path",
"mozilla.org/t",
{ autoFilled: "mozilla.org/test/", completed: "https://www.mozilla.org/test/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -30,8 +30,8 @@ add_autocomplete_test([
"Searching for untrimmed https:// entry",
"mo",
{ autoFilled: "mozilla.org/", completed: "https://mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -42,8 +42,8 @@ add_autocomplete_test([
"Searching for untrimmed https:// entry with path",
"mozilla.org/t",
{ autoFilled: "mozilla.org/test/", completed: "https://mozilla.org/test/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -54,8 +54,8 @@ add_autocomplete_test([
"Searching for untrimmed http://www entry",
"mo",
{ autoFilled: "mozilla.org/", completed: "www.mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -66,8 +66,8 @@ add_autocomplete_test([
"Searching for untrimmed http://www entry with path",
"mozilla.org/t",
{ autoFilled: "mozilla.org/test/", completed: "http://www.mozilla.org/test/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -78,8 +78,8 @@ add_autocomplete_test([
"Searching for untrimmed ftp:// entry",
"mo",
{ autoFilled: "mozilla.org/", completed: "ftp://mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -90,8 +90,8 @@ add_autocomplete_test([
"Searching for untrimmed ftp:// entry with path",
"mozilla.org/t",
{ autoFilled: "mozilla.org/test/", completed: "ftp://mozilla.org/test/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
@ -102,27 +102,24 @@ add_autocomplete_test([
"Ensuring correct priority 1",
"mo",
{ autoFilled: "mozilla.org/", completed: "mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
function* () {
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("https://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("https://mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -130,23 +127,21 @@ add_autocomplete_test([
"Ensuring correct priority 2",
"mo",
{ autoFilled: "mozilla.org/", completed: "mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
function* () {
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("https://mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -154,19 +149,18 @@ add_autocomplete_test([
"Ensuring correct priority 3",
"mo",
{ autoFilled: "mozilla.org/", completed: "mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
function* () {
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -174,15 +168,15 @@ add_autocomplete_test([
"Ensuring correct priority 4",
"mo",
{ autoFilled: "mozilla.org/", completed: "mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
function* () {
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("http://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://mozilla.org/test/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -190,15 +184,15 @@ add_autocomplete_test([
"Ensuring correct priority 5",
"mo",
{ autoFilled: "mozilla.org/", completed: "ftp://mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("ftp://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
});
function* () {
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("ftp://mozilla.org/test/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("ftp://www.mozilla.org/test/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -206,15 +200,15 @@ add_autocomplete_test([
"Ensuring correct priority 6",
"mo",
{ autoFilled: "mozilla.org/", completed: "www.mozilla.org/" },
function () {
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test1/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://www.mozilla.org/test2/"),
transition: TRANSITION_TYPED
});
function* () {
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("http://www.mozilla.org/test1/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://www.mozilla.org/test2/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -222,21 +216,20 @@ add_autocomplete_test([
"Ensuring longer domain can't match",
"mo",
{ autoFilled: "mozilla.co/", completed: "mozilla.co/" },
function () {
function* () {
// The .co should be preferred, but should not get the https from the .com.
// The .co domain must be added later to activate the trigger bug.
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://mozilla.com/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.co/"),
transition: TRANSITION_TYPED
});
PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.co/"),
transition: TRANSITION_TYPED
});
yield PlacesTestUtils.addVisits([
{ uri: NetUtil.newURI("https://mozilla.com/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://mozilla.co/"),
transition: TRANSITION_TYPED
},
{ uri: NetUtil.newURI("http://mozilla.co/"),
transition: TRANSITION_TYPED
}
]);
},
]);
@ -244,8 +237,8 @@ add_autocomplete_test([
"Searching for URL with characters that are normally escaped",
"https://www.mozilla.org/啊-test",
{ autoFilled: "https://www.mozilla.org/啊-test", completed: "https://www.mozilla.org/啊-test" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("https://www.mozilla.org/啊-test"),
transition: TRANSITION_TYPED
});
@ -256,8 +249,8 @@ add_autocomplete_test([
"Don't return unsecure URL when searching for secure ones",
"https://test.moz.org/t",
{ autoFilled: "https://test.moz.org/test/", completed: "https://test.moz.org/test/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://test.moz.org/test/"),
transition: TRANSITION_TYPED
});
@ -268,8 +261,8 @@ add_autocomplete_test([
"Don't return unsecure domain when searching for secure ones",
"https://test.moz",
{ autoFilled: "https://test.moz.org/", completed: "https://test.moz.org/" },
function () {
PlacesTestUtils.addVisits({
function* () {
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://test.moz.org/test/"),
transition: TRANSITION_TYPED
});
@ -280,8 +273,8 @@ add_autocomplete_test([
"Untyped is not accounted for www",
"mo",
{ autoFilled: "moz.org/", completed: "moz.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.moz.org/test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://www.moz.org/test/") });
},
]);
@ -289,8 +282,8 @@ add_autocomplete_test([
"Untyped is not accounted for ftp",
"mo",
{ autoFilled: "moz.org/", completed: "moz.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("ftp://moz.org/test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("ftp://moz.org/test/") });
},
]);
@ -298,8 +291,8 @@ add_autocomplete_test([
"Untyped is not accounted for https",
"mo",
{ autoFilled: "moz.org/", completed: "moz.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("https://moz.org/test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("https://moz.org/test/") });
},
]);
@ -307,7 +300,7 @@ add_autocomplete_test([
"Untyped is not accounted for https://www",
"mo",
{ autoFilled: "moz.org/", completed: "moz.org/" },
function () {
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("https://www.moz.org/test/") });
function* () {
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("https://www.moz.org/test/") });
},
]);

Просмотреть файл

@ -9,9 +9,9 @@ add_autocomplete_test([
"Searching for domain should autoFill it",
"moz",
"mozilla.org/",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
}
]);
@ -19,9 +19,9 @@ add_autocomplete_test([
"Searching for url should autoFill it",
"mozilla.org/li",
"mozilla.org/link/",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
}
]);
@ -31,9 +31,9 @@ add_autocomplete_test([
"Searching for non-typed domain should not autoFill it",
"moz",
"moz",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", true);
PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
}
]);
@ -41,10 +41,10 @@ add_autocomplete_test([
"Searching for typed domain should autoFill it",
"moz",
"mozilla.org/",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", true);
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/typed/"),
transition: TRANSITION_TYPED });
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/typed/"),
transition: TRANSITION_TYPED });
}
]);
@ -52,9 +52,9 @@ add_autocomplete_test([
"Searching for non-typed url should not autoFill it",
"mozilla.org/li",
"mozilla.org/li",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", true);
PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
yield PlacesTestUtils.addVisits(NetUtil.newURI("http://mozilla.org/link/"));
}
]);
@ -62,9 +62,9 @@ add_autocomplete_test([
"Searching for typed url should autoFill it",
"mozilla.org/li",
"mozilla.org/link/",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", true);
PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED });
yield PlacesTestUtils.addVisits({ uri: NetUtil.newURI("http://mozilla.org/link/"),
transition: TRANSITION_TYPED });
}
]);

Просмотреть файл

@ -8,9 +8,9 @@ add_autocomplete_test([
"Searching for zero frecency domain should not autoFill it",
"moz",
"moz",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
PlacesTestUtils.addVisits({
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/framed_link/"),
transition: TRANSITION_FRAMED_LINK
});
@ -21,9 +21,9 @@ add_autocomplete_test([
"Searching for zero frecency url should not autoFill it",
"mozilla.org/f",
"mozilla.org/f",
function () {
function* () {
Services.prefs.setBoolPref("browser.urlbar.autoFill.typed", false);
PlacesTestUtils.addVisits({
yield PlacesTestUtils.addVisits({
uri: NetUtil.newURI("http://mozilla.org/framed_link/"),
transition: TRANSITION_FRAMED_LINK
});

Просмотреть файл

@ -226,7 +226,8 @@ let addBookmark = Task.async(function* (aBookmarkObj) {
let itemId = yield PlacesUtils.promiseItemId(bm.guid);
if (aBookmarkObj.keyword) {
PlacesUtils.bookmarks.setKeywordForBookmark(itemId, aBookmarkObj.keyword);
yield PlacesUtils.keywords.insert({ keyword: aBookmarkObj.keyword,
url: aBookmarkObj.uri.spec });
}
if (aBookmarkObj.tags) {

Просмотреть файл

@ -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: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search=term"), title: "abc", style: ["keyword"] } ]
});
do_print("Multi-word keyword query");
yield check_autocomplete({
search: "key multi word",
matches: [ { uri: NetUtil.newURI("http://abc/?search=multi+word"), title: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search=multi+word"), title: "abc", style: ["keyword"] } ]
});
do_print("Keyword query with +");
yield check_autocomplete({
search: "key blocking+",
matches: [ { uri: NetUtil.newURI("http://abc/?search=blocking%2B"), title: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search=blocking%2B"), title: "abc", style: ["keyword"] } ]
});
do_print("Unescaped term in query");
yield check_autocomplete({
search: "key ユニコード",
matches: [ { uri: NetUtil.newURI("http://abc/?search=ユニコード"), title: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search=ユニコード"), title: "abc", style: ["keyword"] } ]
});
do_print("Keyword that happens to match a page");
yield check_autocomplete({
search: "key ThisPageIsInHistory",
matches: [ { uri: NetUtil.newURI("http://abc/?search=ThisPageIsInHistory"), title: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search=ThisPageIsInHistory"), title: "abc", style: ["keyword"] } ]
});
do_print("Keyword without query (without space)");
yield check_autocomplete({
search: "key",
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "abc", style: ["keyword"] } ]
});
do_print("Keyword without query (with space)");
yield check_autocomplete({
search: "key ",
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "Generic page title", style: ["keyword"] } ]
matches: [ { uri: NetUtil.newURI("http://abc/?search="), title: "abc", style: ["keyword"] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=term", input: "key term"}), title: "abc", style: [ "action", "keyword" ] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=multi+word", input: "key multi word"}), title: "abc", style: [ "action", "keyword" ] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=blocking%2B", input: "key blocking+"}), title: "abc", style: [ "action", "keyword" ] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=ユニコード", input: "key ユニコード"}), title: "abc", style: [ "action", "keyword" ] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=ThisPageIsInHistory", input: "key ThisPageIsInHistory"}), title: "abc", style: [ "action", "keyword" ] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=", input: "key"}), title: "abc", style: [ "action", "keyword" ] } ]
});
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: "Generic page title", style: [ "action", "keyword" ] } ]
matches: [ { uri: makeActionURI("keyword", {url: "http://abc/?search=", input: "key "}), title: "abc", style: [ "action", "keyword" ] } ]
});
yield cleanup();