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

Unified Diff: lib/devtools.js

Issue 29404613: Issue 5117 - Identify ElemHideEmulationFilters based on the filter text in the devtools panel (Closed)
Patch Set: Created April 6, 2017, 2:53 p.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 | « include.preload.js ('k') | no next file » | 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
@@ -19,9 +19,7 @@
const {RegExpFilter,
WhitelistFilter,
- ElemHideFilter,
- ElemHideEmulationFilter} = require("filterClasses");
-
+ ElemHideFilter} = require("filterClasses");
const {SpecialSubscription} = require("subscriptionClasses");
const {FilterStorage} = require("filterStorage");
const {defaultMatcher} = require("matcher");
@@ -150,10 +148,11 @@
* Logs active element hiding filters to the devtools panel.
*
* @param {Page} page The page the elements were hidden on
- * @param {string[]} selectors The CSS selectors of active elemhide filters
+ * @param {string[]} selectors The selectors of applied ElemHideFilters
+ * @param {string[]} filters The text of applied ElemHideEmulationFilters
* @param {string} docDomain The IDN-decoded hostname of the document
*/
-function logHiddenElements(page, selectors, docDomain)
+function logHiddenElements(page, selectors, filters, docDomain)
{
let panel = getActivePanel(page);
if (panel)
@@ -165,15 +164,16 @@
for (let filter of subscription.filters)
{
- if (!(filter instanceof ElemHideFilter) &&
- !(filter instanceof ElemHideEmulationFilter))
- continue;
- if (selectors.indexOf(filter.selector) == -1)
- continue;
- if (!filter.isActiveOnDomain(docDomain))
- continue;
+ // We only know the exact filter in case of element hiding emulation.
+ // For regular element hiding filters, the content script only knows
+ // the selector, so we have to find a filter that has an identical
+ // selector and is active on the domain the match was reported from.
+ let isActiveElemHideFilter = filter instanceof ElemHideFilter &&
+ selectors.includes(filter.selector) &&
+ filter.isActiveOnDomain(docDomain);
- addRecord(panel, {type: "ELEMHIDE", docDomain}, filter);
+ if (isActiveElemHideFilter || filters.includes(filter.text))
+ addRecord(panel, {type: "ELEMHIDE", docDomain}, filter);
}
}
}
@@ -380,7 +380,7 @@
port.on("devtools.traceElemHide", (message, sender) =>
{
logHiddenElements(
- sender.page, message.selectors,
+ sender.page, message.selectors, message.filters,
extractHostFromFrame(sender.frame)
);
});
« no previous file with comments | « include.preload.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld