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

Unified Diff: lib/child/cssProperties.js

Issue 29345639: Issue 3969 - Hits are not counted for custom CSS property rules (Closed)
Patch Set: Created June 8, 2016, 1:42 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 | « chrome/content/ui/sidebar.js ('k') | lib/cssProperties.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/child/cssProperties.js
===================================================================
--- a/lib/child/cssProperties.js
+++ b/lib/child/cssProperties.js
@@ -17,17 +17,18 @@
"use strict";
(function()
{
let {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
let {port} = require("messaging");
- let {getFrames} = require("child/utils");
+ let {getFrames, isPrivate} = require("child/utils");
+ let {RequestNotifier} = require("child/requestNotifier");
function getFilters(window, callback)
{
let message = {
frames: getFrames(window),
payload: {
type: "filters.get",
what: "cssproperties"
@@ -55,24 +56,52 @@
{
if (!(subject instanceof Ci.nsIDOMWindow))
return;
let onReady = event =>
{
subject.removeEventListener("load", onReady);
let handler = new scope.CSSPropertyFilters(
- subject, getFilters.bind(null, subject), selectors =>
+ subject, getFilters.bind(null, subject), (selectors, filters) =>
{
if (selectors.length == 0)
return;
addUserCSS(subject, selectors.map(
selector => selector + "{display: none !important;}"
).join("\n"));
+
+ if (!isPrivate(subject))
+ port.emit("addHits", filters);
+
+ let docDomain = null;
+ try
+ {
+ // We are calling getFrames() here because it will consider
+ // "inheritance" for about:blank and data: frames.
+ docDomain = new URL(getFrames(subject)[0].location).hostname;
+ }
+ catch (e)
+ {
+ // Invalid URL?
saroyanm 2016/06/10 08:55:11 Detail: I'm not sure if this comment provides any
Wladimir Palant 2016/06/10 14:59:54 Well, eslint objects to empty catch clauses. In fa
+ }
+
+ for (let filter of filters)
+ {
+ RequestNotifier.addNodeData(subject.document, subject.top, {
+ contentType: "ELEMHIDE",
+ docDomain: docDomain,
+ thirdParty: false,
+ // TODO: Show the actual matching selector here?
saroyanm 2016/06/10 08:55:11 Detail: Feels like you forgot "TODO" Smth, or mayb
Wladimir Palant 2016/06/10 14:59:54 No, I meant to have this TODO comment here. Addres
saroyanm 2016/06/10 17:00:24 Acknowledged.
+ location: filter.replace(/^.*?##/, ""),
saroyanm 2016/06/10 08:55:12 Why do we remove the URL part from the filter to a
Wladimir Palant 2016/06/10 14:59:54 hit.location is normally the address that the filt
saroyanm 2016/06/10 17:00:24 Acknowledged.
+ filter: filter,
+ filterType: "cssproperty"
+ });
+ }
}
);
handler.load(() => handler.apply());
};
subject.addEventListener("load", onReady);
};
« no previous file with comments | « chrome/content/ui/sidebar.js ('k') | lib/cssProperties.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld