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: Created April 20, 2017, 9:43 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
« 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
@@ -20,17 +20,18 @@
"use strict";
const {Filter, RegExpFilter, BlockingFilter} = require("filterClasses");
const {Subscription} = require("subscriptionClasses");
const {defaultMatcher} = require("matcher");
const {FilterNotifier} = require("filterNotifier");
const {Prefs} = require("prefs");
const {checkWhitelisted, getKey} = require("whitelisting");
-const {stringifyURL, extractHostFromFrame, isThirdParty} = require("url");
+const {stringifyURL, getDecodedHostname,
+ extractHostFromFrame, isThirdParty} = require("url");
const {port} = require("messaging");
const devtools = require("devtools");
// Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests.
RegExpFilter.typeMap.OBJECT_SUBREQUEST = RegExpFilter.typeMap.OBJECT;
function onBeforeRequestAsync(page, url, type, docDomain,
thirdParty, sitekey,
@@ -46,23 +47,28 @@
thirdParty, sitekey,
specificOnly, filter
);
}
}
ext.webRequest.onBeforeRequest.addListener((url, type, page, frame) =>
{
- if (checkWhitelisted(page, frame))
- return true;
+ let docDomain = getDecodedHostname(url);
Sebastian Noack 2017/04/21 08:39:53 Is there a reason you derive the parent document's
Jon Sonesen 2017/04/24 08:40:56 I see, I misunderstood what I was doing here. I ju
+ let sitekey = null;
+ if (frame && page)
+ {
+ if (checkWhitelisted(page, frame))
+ return true;
+ docDomain = extractHostFromFrame(frame);
+ sitekey = getKey(page, frame);
+ }
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
);
let filter = defaultMatcher.matchesAny(
urlString, RegExpFilter.typeMap[type],
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