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: fix whitespace, add comment abut null page, remove redundancies Created June 2, 2017, 5:01 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 | « 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,34 @@
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)
+ {
+ if (checkWhitelisted(page, frame))
+ return true;
+
+ docDomain = extractHostFromFrame(frame);
+ sitekey = getKey(page, frame);
+ thirdParty = isThirdParty(url, docDomain);
+ specificOnly = !!checkWhitelisted(page, frame,
+ RegExpFilter.typeMap.GENERICBLOCK);
+ }
let mappedType = resourceTypes.get(type) || "OTHER";
let filter = defaultMatcher.matchesAny(
urlString, RegExpFilter.typeMap[mappedType],
docDomain, thirdParty, sitekey, specificOnly
);
« no previous file with comments | « lib/devtools.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld