Bug 446405 - Do not show the keyword of a quick search as if it was the query string. r=dietrich,mardak

This commit is contained in:
Blair McBride 2009-10-07 10:38:15 +02:00
parent 57d43d2c7e
commit 7dcc1cd83f
3 changed files with 20 additions and 8 deletions

View File

@ -811,7 +811,10 @@ nsPlacesAutoComplete.prototype = {
// The keyword is the first word in the search string, with the parameters
// following it.
let searchString = this._originalSearchString;
let queryString = searchString.substring(searchString.indexOf(" ") + 1);
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");

View File

@ -62,9 +62,10 @@ let kURIs = [
keyBase + "blocking%2B",
keyBase + unescaped,
keyBase + pageInHistory,
keyBase,
otherBase + "%s",
keyBase + "twoKey",
otherBase + "twoKey",
otherBase + "twoKey"
];
let kTitles = [
"Generic page title",
@ -80,6 +81,7 @@ gPages[3] = [3,1];
gPages[4] = [4,1];
// Add a page into history
addPageBook(5, 0);
gPages[6] = [6,1];
// Provide for each test: description; search terms; array of gPages indices of
// pages that should match; optional function to be run before the test
@ -94,14 +96,18 @@ let gTests = [
keyKey + " " + unescaped, [4]],
["4: Keyword that happens to match a page",
keyKey + " " + pageInHistory, [5]],
["5: Keyword without query (without space)",
keyKey, [6]],
["6: Keyword without query (with space)",
keyKey + " ", [6]],
// This adds a second keyword so anything after this will match 2 keywords
["5: Two keywords matched",
keyKey + " twoKey", [7,8],
["7: Two keywords matched",
keyKey + " twoKey", [8,9],
function() {
// Add the keyword search as well as search results
addPageBook(6, 0, 1, [], keyKey);
gPages[7] = [7,1];
addPageBook(7, 0, 1, [], keyKey);
gPages[8] = [8,1];
}],
gPages[9] = [9,1];
}]
];

View File

@ -1411,7 +1411,10 @@
// Put the parameters next to the title if we have any
let search = this.getAttribute("text");
let params = search.substr(search.indexOf(' ') + 1);
let params = "";
let paramsIndex = search.indexOf(' ');
if (paramsIndex != -1)
params = search.substr(paramsIndex + 1);
// Emphasize the keyword parameters
this._setUpDescription(this._extra, params);