Bug 557943 - Searching for addons can result in wrong results. r=dtownsend

This commit is contained in:
Blair McBride 2010-08-06 09:36:29 -07:00
Родитель 1e67f24638
Коммит 686434ba16
3 изменённых файлов: 80 добавлений и 2 удалений

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

@ -1218,8 +1218,8 @@ var gSearchView = {
return score;
aStr = aStr.trim().toLocaleLowerCase();
var haystack = aStr.split(/\W+/);
var needles = aQuery.split(/\W+/);
var haystack = aStr.split(/\s+/);
var needles = aQuery.split(/\s+/);
for (let n = 0; n < needles.length; n++) {
for (let h = 0; h < haystack.length; h++) {

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

@ -47,6 +47,7 @@ include $(DEPTH)/config/autoconf.mk
_TEST_FILES = \
head.js \
browser_bug557943.js \
browser_bug562890.js \
browser_bug562899.js \
browser_bug562992.js \

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

@ -0,0 +1,77 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/
*/
// Bug 557943 - Searching for addons can result in wrong results
var gManagerWindow;
function test() {
waitForExplicitFinish();
gProvider = new MockProvider();
gProvider.createAddons([{
id: "addon1@tests.mozilla.org",
name: "Microsoft .NET Framework Assistant",
description: "",
version: "6.66"
}, {
id: "addon2@tests.mozilla.org",
name: "AwesomeNet Addon",
description: ""
}, {
id: "addon3@tests.mozilla.org",
name: "Dictionnaire MySpell en Francais (réforme 1990)",
description: ""
}]);
open_manager(null, function(aWindow) {
gManagerWindow = aWindow;
run_next_test();
});
}
function end_test() {
close_manager(gManagerWindow, function() {
finish();
});
}
function perform_search(aQuery, aCallback) {
var searchBox = gManagerWindow.document.getElementById("header-search");
searchBox.value = aQuery;
EventUtils.synthesizeMouse(searchBox, 2, 2, { }, gManagerWindow);
EventUtils.synthesizeKey("VK_RETURN", { }, gManagerWindow);
wait_for_view_load(gManagerWindow, function() {
var list = gManagerWindow.document.getElementById("search-list");
var rows = list.getElementsByTagName("richlistitem");
aCallback(rows);
});
}
add_test(function() {
perform_search(".net", function(aRows) {
is(aRows.length, 1, "Should only get one result");
is(aRows[0].mAddon.id, "addon1@tests.mozilla.org", "Should get expected addon as only result");
run_next_test();
});
});
add_test(function() {
perform_search("réf", function(aRows) {
is(aRows.length, 1, "Should only get one result");
is(aRows[0].mAddon.id, "addon3@tests.mozilla.org", "Should get expected addon as only result");
run_next_test();
});
});
add_test(function() {
perform_search("javascript:void()", function(aRows) {
is(aRows.length, 0, "Should not get any results");
run_next_test();
});
});