Backed out changeset 54f37e45c70b (bug 1125117) for bc1 orange CLOSED TREE

This commit is contained in:
Wes Kocher 2015-03-26 14:23:55 -07:00
Родитель 95e6c5d809
Коммит 298f693d17
27 изменённых файлов: 521 добавлений и 494 удалений

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

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

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

@ -1,19 +1,19 @@
add_task(function*() { add_task(function*() {
// This test is only relevant if UnifiedComplete is enabled. // This test is only relevant if UnifiedComplete is enabled.
let ucpref = Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete"); if (!Services.prefs.getBoolPref("browser.urlbar.unifiedcomplete")) {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", true); 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");
registerCleanupFunction(() => { registerCleanupFunction(() => {
Services.prefs.setBoolPref("browser.urlbar.unifiedcomplete", ucpref); PlacesUtils.bookmarks.removeItem(itemId);
});
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"); yield promiseAutocompleteResultPopup("keyword search");
@ -21,12 +21,12 @@ add_task(function*() {
info("Before override"); info("Before override");
is_element_hidden(result._url, "URL element should be hidden"); is_element_hidden(result._url, "URL element should be hidden");
is_element_visible(result._extraBox, "Extra element should be visible"); is_element_visible(result._extra, "Extra element should be visible");
info("During override"); info("During override");
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keydown" }); EventUtils.synthesizeKey("VK_SHIFT" , { type: "keydown" });
is_element_hidden(result._url, "URL element should be hidden"); is_element_hidden(result._url, "URL element should be hidden");
is_element_visible(result._extraBox, "Extra element should be visible"); is_element_visible(result._extra, "Extra element should be visible");
EventUtils.synthesizeKey("VK_SHIFT" , { type: "keyup" }); EventUtils.synthesizeKey("VK_SHIFT" , { type: "keyup" });

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

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

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

@ -4,12 +4,7 @@
**/ **/
add_task(function* () { 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); 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"; let iconURI = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABGklEQVQoz2NgGB6AnZ1dUlJSXl4eSDIyMhLW4Ovr%2B%2Fr168uXL69Zs4YoG%2BLi4i5dusTExMTGxsbNzd3f37937976%2BnpmZmagbHR09J49e5YvX66kpATVEBYW9ubNm2nTphkbG7e2tp44cQLIuHfvXm5urpaWFlDKysqqu7v73LlzECMYIiIiHj58mJCQoKKicvXq1bS0NKBgW1vbjh074uPjgeqAXE1NzSdPnvDz84M0AEUvXLgAsW379u1z5swBen3jxo2zZ892cHB4%2BvQp0KlAfwI1cHJyghQFBwfv2rULokFXV%2FfixYu7d%2B8GGqGgoMDKyrpu3br9%2B%2FcDuXl5eVA%2FAEWBfoWHAdAYoNuAYQ0XAeoUERFhGDYAAPoUaT2dfWJuAAAAAElFTkSuQmCC";
Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET", Services.search.addEngineWithDetails("MozSearch", iconURI, "moz", "", "GET",
@ -25,6 +20,7 @@ add_task(function* () {
Services.search.currentEngine = originalEngine; Services.search.currentEngine = originalEngine;
let engine = Services.search.getEngineByName("MozSearch"); let engine = Services.search.getEngineByName("MozSearch");
Services.search.removeEngine(engine); Services.search.removeEngine(engine);
Services.prefs.clearUserPref("browser.urlbar.unifiedcomplete");
try { try {
gBrowser.removeTab(tab); gBrowser.removeTab(tab);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -46,10 +46,11 @@ const MATCH_BEGINNING_CASE_SENSITIVE = Ci.mozIPlacesAutoComplete.MATCH_BEGINNING
// AutoComplete query type constants. // AutoComplete query type constants.
// Describes the various types of queries that we can process rows for. // Describes the various types of queries that we can process rows for.
const QUERYTYPE_FILTERED = 0; const QUERYTYPE_KEYWORD = 0;
const QUERYTYPE_AUTOFILL_HOST = 1; const QUERYTYPE_FILTERED = 1;
const QUERYTYPE_AUTOFILL_URL = 2; const QUERYTYPE_AUTOFILL_HOST = 2;
const QUERYTYPE_AUTOFILL_PREDICTURL = 3; const QUERYTYPE_AUTOFILL_URL = 3;
const QUERYTYPE_AUTOFILL_PREDICTURL = 4;
// This separator is used as an RTL-friendly way to split the title and tags. // 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 // It can also be used by an nsIAutoCompleteResult consumer to re-split the
@ -63,7 +64,7 @@ const TITLE_SEARCH_ENGINE_SEPARATOR = " \u00B7\u2013\u00B7 ";
const TELEMETRY_1ST_RESULT = "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS"; const TELEMETRY_1ST_RESULT = "PLACES_AUTOCOMPLETE_1ST_RESULT_TIME_MS";
const TELEMETRY_6_FIRST_RESULTS = "PLACES_AUTOCOMPLETE_6_FIRST_RESULTS_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. // The default frecency value used when inserting matches with unknown frecency.
const FRECENCY_DEFAULT = 1000; const FRECENCY_SEARCHENGINES_DEFAULT = 1000;
// Sqlite result row index constants. // Sqlite result row index constants.
const QUERYINDEX_QUERYTYPE = 0; const QUERYINDEX_QUERYTYPE = 0;
@ -148,6 +149,23 @@ const SQL_ADAPTIVE_QUERY =
:matchBehavior, :searchBehavior) :matchBehavior, :searchBehavior)
ORDER BY rank DESC, h.frecency DESC`; 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 = "") { function hostQuery(conditions = "") {
let query = let query =
@ -713,8 +731,6 @@ Search.prototype = {
// Since we call the synchronous parseSubmissionURL function later, we must // Since we call the synchronous parseSubmissionURL function later, we must
// wait for the initialization of PlacesSearchAutocompleteProvider first. // wait for the initialization of PlacesSearchAutocompleteProvider first.
yield PlacesSearchAutocompleteProvider.ensureInitialized(); yield PlacesSearchAutocompleteProvider.ensureInitialized();
if (!this.pending)
return;
// For any given search, we run many queries/heuristics: // For any given search, we run many queries/heuristics:
// 1) by alias (as defined in SearchService) // 1) by alias (as defined in SearchService)
@ -722,7 +738,7 @@ Search.prototype = {
// 3) inline completion for hosts (this._hostQuery) or urls (this._urlQuery) // 3) inline completion for hosts (this._hostQuery) or urls (this._urlQuery)
// 4) directly typed in url (ie, can be navigated to as-is) // 4) directly typed in url (ie, can be navigated to as-is)
// 5) submission for the current search engine // 5) submission for the current search engine
// 6) Places keywords // 6) keywords (this._keywordQuery)
// 7) adaptive learning (this._adaptiveQuery) // 7) adaptive learning (this._adaptiveQuery)
// 8) open pages not supported by history (this._switchToTabQuery) // 8) open pages not supported by history (this._switchToTabQuery)
// 9) query based on match behavior // 9) query based on match behavior
@ -756,13 +772,15 @@ Search.prototype = {
// special results. // special results.
let hasFirstResult = false; let hasFirstResult = false;
if (this._searchTokens.length > 0) { if (this._searchTokens.length > 0 &&
// This may be a Places keyword. PlacesUtils.bookmarks.getURIForKeyword(this._searchTokens[0])) {
hasFirstResult = yield this._matchPlacesKeyword(); // This may be a keyword of a bookmark.
queries.unshift(this._keywordQuery);
hasFirstResult = true;
} }
if (this.pending && this._enableActions && !hasFirstResult) { if (this._enableActions && !hasFirstResult) {
// If it's not a Places keyword, then it may be a search engine // If it's not a bookmarked keyword, then it may be a search engine
// with an alias - which works like a keyword. // with an alias - which works like a keyword.
hasFirstResult = yield this._matchSearchEngineAlias(); hasFirstResult = yield this._matchSearchEngineAlias();
} }
@ -857,35 +875,6 @@ Search.prototype = {
return gotResult; 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* () { _matchSearchEngineUrl: function* () {
if (!Prefs.autofillSearchEngines) if (!Prefs.autofillSearchEngines)
return false; return false;
@ -933,7 +922,7 @@ Search.prototype = {
icon: match.iconUrl, icon: match.iconUrl,
style: "priority-search", style: "priority-search",
finalCompleteValue: match.url, finalCompleteValue: match.url,
frecency: FRECENCY_DEFAULT frecency: FRECENCY_SEARCHENGINES_DEFAULT
}); });
return true; return true;
}, },
@ -980,7 +969,7 @@ Search.prototype = {
comment: match.engineName, comment: match.engineName,
icon: match.iconUrl, icon: match.iconUrl,
style: "action searchengine", style: "action searchengine",
frecency: FRECENCY_DEFAULT, frecency: FRECENCY_SEARCHENGINES_DEFAULT,
}); });
}, },
@ -1063,6 +1052,7 @@ Search.prototype = {
match = this._processUrlRow(row); match = this._processUrlRow(row);
break; break;
case QUERYTYPE_FILTERED: case QUERYTYPE_FILTERED:
case QUERYTYPE_KEYWORD:
match = this._processRow(row); match = this._processRow(row);
break; break;
} }
@ -1246,6 +1236,17 @@ Search.prototype = {
// Always prefer the bookmark title unless it is empty // Always prefer the bookmark title unless it is empty
let title = bookmarkTitle || historyTitle; 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. // We will always prefer to show tags if we have them.
let showTags = !!tags; let showTags = !!tags;
@ -1351,6 +1352,37 @@ 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. * Obtains the query to search for switch-to-tab entries.
* *

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -25,49 +25,49 @@ add_task(function* test_keyword_search() {
yield check_autocomplete({ yield check_autocomplete({
search: "key term", search: "key term",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
do_print("Multi-word keyword query"); do_print("Multi-word keyword query");
yield check_autocomplete({ yield check_autocomplete({
search: "key multi word", search: "key multi word",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
do_print("Keyword query with +"); do_print("Keyword query with +");
yield check_autocomplete({ yield check_autocomplete({
search: "key blocking+", search: "key blocking+",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
do_print("Unescaped term in query"); do_print("Unescaped term in query");
yield check_autocomplete({ yield check_autocomplete({
search: "key ユニコード", search: "key ユニコード",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
do_print("Keyword that happens to match a page"); do_print("Keyword that happens to match a page");
yield check_autocomplete({ yield check_autocomplete({
search: "key ThisPageIsInHistory", search: "key ThisPageIsInHistory",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
do_print("Keyword without query (without space)"); do_print("Keyword without query (without space)");
yield check_autocomplete({ yield check_autocomplete({
search: "key", search: "key",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
do_print("Keyword without query (with space)"); do_print("Keyword without query (with space)");
yield check_autocomplete({ yield check_autocomplete({
search: "key ", search: "key ",
searchParam: "enable-actions", 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: "Generic page title", style: [ "action", "keyword" ] } ]
}); });
yield cleanup(); yield cleanup();