bug 501772 - Port Bug 500978 |Download Manager treats search terms as regular expressions| to SeaMonkey, r=Neil

This commit is contained in:
Jens Hatlak 2009-07-22 18:32:49 +02:00
Родитель 928444d0ee
Коммит 1232ba134d
2 изменённых файлов: 19 добавлений и 6 удалений

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

@ -104,7 +104,7 @@ function test()
.getService(Components.interfaces.nsIObserverService);
const DLMGR_UI_DONE = "download-manager-ui-done";
var testPhase = 0;
var testPhase = -1;
var testObs = {
observe: function(aSubject, aTopic, aData) {
if (aTopic != DLMGR_UI_DONE)
@ -119,8 +119,13 @@ function test()
searchbox.doCommand();
};
let testResults = function(aExpected) {
is(downloadView.rowCount, aExpected,
"Phase " + testPhase + ": search matched " + aExpected + " download(s)");
};
// The list must have built, so figure out what test to do
switch (testPhase++) {
switch (++testPhase) {
case 0:
// Search for multiple words in any order in all places
search("download super pimped multiWord");
@ -128,15 +133,23 @@ function test()
break;
case 1:
// Done populating the two items
ok(downloadView.rowCount == 2, "Search matched both downloads");
testResults(2);
// Do partial word matches including the site
search("agadak downl pimp multi");
search("Agadak.net downl pimp multi");
break;
case 2:
// Done populating the one result
ok(downloadView.rowCount == 1, "Found the single download");
testResults(1);
// The search term shouldn't be treated like a regular expression,
// e.g. "D.wnload" shouldn't match "Download".
search("D.wnload");
break;
case 3:
testResults(0);
// We're done!
win.close();

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

@ -440,7 +440,7 @@ DownloadTreeView.prototype = {
if (!attrs.isActive)
for each (let term in this._searchTerms)
if (combinedSearch.search(term) == -1)
if (combinedSearch.indexOf(term) == -1)
matchSearch = false;
}