Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/devtools.js

Issue 29907589: Issue 7054 - Update the adblockpluscore dependency to 5cb695da5a40, adblockplusui to f86abf2efdfd (Closed)
Patch Set: Address PS12 Comment Created Jan. 8, 2019, 1:02 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « dependencies ('k') | lib/filterComposer.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 => 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 (!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;
« no previous file with comments | « dependencies ('k') | lib/filterComposer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld