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

Unified Diff: lib/requestBlocker.js

Issue 29418679: Issue 5042 - Adds handling for requests which are not associated with browser tab (Closed)
Patch Set: addresses comments, nits, redundancies, white space Created May 31, 2017, 8:43 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
« lib/devtools.js ('K') | « lib/devtools.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/requestBlocker.js
===================================================================
--- a/lib/requestBlocker.js
+++ b/lib/requestBlocker.js
@@ -64,27 +64,35 @@
thirdParty, sitekey,
specificOnly, filter
);
}
}
ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) =>
{
- if (checkWhitelisted(page, frame))
- return true;
-
+ let docDomain = null;
+ let sitekey = null;
+ let specificOnly = false;
+ let thirdParty = false;
let urlString = stringifyURL(url);
- let docDomain = extractHostFromFrame(frame);
- let thirdParty = isThirdParty(url, docDomain);
- let sitekey = getKey(page, frame);
- let specificOnly = !!checkWhitelisted(
- page, frame, RegExpFilter.typeMap.GENERICBLOCK
- );
+ if (frame && page)
Sebastian Noack 2017/06/01 17:32:21 Nit: As mentioned before, I'd add a blank line abo
Jon Sonesen 2017/06/02 05:02:58 Acknowledged.
+ {
+ if (checkWhitelisted(page, frame))
+ return true;
+
+ docDomain = extractHostFromFrame(frame);
+ sitekey = getKey(page, frame);
+ thirdParty = isThirdParty(url, docDomain);
+ specificOnly = !!checkWhitelisted(page, frame,
+ RegExpFilter.typeMap.GENERICBLOCK);
+ }
+
Sebastian Noack 2017/06/01 17:32:21 Nit: One blank line is sufficient here.
Jon Sonesen 2017/06/02 05:02:58 Acknowledged.
+
let mappedType = resourceTypes.get(type) || "OTHER";
let filter = defaultMatcher.matchesAny(
urlString, RegExpFilter.typeMap[mappedType],
docDomain, thirdParty, sitekey, specificOnly
);
« lib/devtools.js ('K') | « lib/devtools.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld