Index: lib/devtools.js |
=================================================================== |
--- a/lib/devtools.js |
+++ b/lib/devtools.js |
@@ -17,17 +17,17 @@ |
"use strict"; |
const {RegExpFilter, |
WhitelistFilter, |
ElemHideFilter} = require("../adblockpluscore/lib/filterClasses"); |
const {SpecialSubscription} = |
require("../adblockpluscore/lib/subscriptionClasses"); |
-const {FilterStorage} = require("../adblockpluscore/lib/filterStorage"); |
+const {filterStorage} = require("../adblockpluscore/lib/filterStorage"); |
const {defaultMatcher} = require("../adblockpluscore/lib/matcher"); |
const {filterNotifier} = require("../adblockpluscore/lib/filterNotifier"); |
const {extractHostFromFrame} = require("./url"); |
const {port} = require("./messaging"); |
const {HitLogger, nonRequestTypes} = require("./hitLogger"); |
let panels = new Map(); |
@@ -152,18 +152,22 @@ |
{ |
browser.tabs.reload(tabId, {bypassCache: true}); |
panel.reload = false; |
panel.reloading = true; |
} |
} |
-function updateFilters(filters, added) |
+function updateFilters(subscription, filters, added) |
{ |
+ let includes = subscription ? |
+ filter => subscription.searchfilter(filter) != -1 : |
+ filters.includes.bind(filters); |
+ |
for (let panel of panels.values()) |
{ |
for (let i = 0; i < panel.records.length; i++) |
{ |
let record = panel.records[i]; |
// If an added filter matches a request shown in the devtools panel, |
// update that record to show the new filter. Ignore filters that aren't |
@@ -171,30 +175,31 @@ |
// if they don't already match. In particular, in case of element hiding |
// filters, we also wouldn't know if any new element matches. |
if (added) |
{ |
if (nonRequestTypes.includes(record.request.type)) |
continue; |
let filter = matchRequest(record.request); |
- if (!filters.includes(filter)) |
+ |
+ if (!filter || !includes(filter)) |
continue; |
record.filter = filter; |
} |
// If a filter shown in the devtools panel got removed, update that |
// record to show the filter that matches now, or none, instead. |
// For filters that aren't associated with any sub-resource request, |
// just remove the record. We wouldn't know whether another filter |
// matches instead until the page is reloaded. |
else |
{ |
- if (!filters.includes(record.filter)) |
+ if (!includes(record.filter)) |
continue; |
if (nonRequestTypes.includes(record.request.type)) |
{ |
panel.port.postMessage({ |
type: "remove-record", |
index: i |
}); |
@@ -212,28 +217,28 @@ |
filter: getFilterInfo(record.filter) |
}); |
} |
} |
} |
function onFilterAdded(filter) |
{ |
- updateFilters([filter], true); |
+ updateFilters(null, [filter], true); |
} |
function onFilterRemoved(filter) |
{ |
- updateFilters([filter], false); |
+ updateFilters(null, [filter], false); |
} |
function onSubscriptionAdded(subscription) |
{ |
if (subscription instanceof SpecialSubscription) |
- updateFilters(subscription.filters, true); |
+ updateFilters(subscription, null, true); |
} |
browser.runtime.onConnect.addListener(newPort => |
{ |
let match = newPort.name.match(/^devtools-(\d+)$/); |
if (!match) |
return; |