Bug 1222583 - Negative url filtering for network monitor. r=vporof

This commit is contained in:
Tim Nguyen 2015-11-08 13:13:00 +01:00
Родитель 44facd7aa4
Коммит 8c0ccea59a
2 изменённых файлов: 15 добавлений и 2 удалений

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

@ -1166,8 +1166,15 @@ RequestsMenuView.prototype = Heritage.extend(WidgetMethods, {
isFreetextMatch: function({ attachment: { url } }, text) {
let lowerCaseUrl = url.toLowerCase();
let lowerCaseText = text.toLowerCase();
//no text is a positive match
return !text || lowerCaseUrl.includes(lowerCaseText);
let textLength = text.length;
// Support negative filtering
if (text.startsWith("-") && textLength > 1) {
lowerCaseText = lowerCaseText.substring(1, textLength);
return !lowerCaseUrl.includes(lowerCaseText);
} else {
//no text is a positive match
return !text || lowerCaseUrl.includes(lowerCaseText);
}
},
/**

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

@ -123,6 +123,12 @@ function test() {
setFreetextFilter("SAMPLE");
return testContents([1, 1, 1, 0, 0, 0, 0, 0]);
})
.then(() => {
// Test negative filtering (only show unmatched items)
EventUtils.sendMouseEvent({ type: "click" }, $("#requests-menu-filter-all-button"));
setFreetextFilter("-sample");
return testContents([0, 0, 0, 1, 1, 1, 1, 1]);
})
// ...then combine multiple filters together.
.then(() => {
// Enable filtering for html and css; should show request of both type.