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

Unified Diff: lib/requestBlocker.js

Issue 29753574: Issue 6565 - Ignore requests sent by Chrome's new tab page (Closed)
Patch Set: Created April 16, 2018, 1:03 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 | « no previous file | 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
@@ -157,41 +157,32 @@
let originUrl = details.originUrl ? new URL(details.originUrl) :
details.initiator ? new URL(details.initiator) : null;
- // Ignore requests sent by extensions or by the browser itself:
+ // Ignore requests sent by extensions or by Firefox itself:
kzar 2018/04/16 15:53:38 I feel it's kind of confusing how we both make the
Sebastian Noack 2018/04/16 16:42:21 Well, the logic is generic (and covers more than j
// * Firefox intercepts requests sent by any extensions, indicated with
// an "originURL" starting with "moz-extension:".
// * Chromium intercepts requests sent by this extension only, indicated
// on Chromium >=63 with an "initiator" starting with "chrome-extension:".
// * On Firefox, requests that don't relate to any document or extension are
// indicated with an "originUrl" starting with "chrome:".
- // * On Chromium >=63, requests that don't relate to any document or extension
- // have no "initiator". But since on older Chromium versions, no request
- // has an "initiator", we have to check for the tabId as well.
- if (originUrl)
- {
- if (originUrl.protocol == extensionProtocol ||
- originUrl.protocol == "chrome:")
- return;
- }
- else if (details.tabId == -1)
+ if (originUrl && (originUrl.protocol == extensionProtocol ||
+ originUrl.protocol == "chrome:"))
return;
- let page = null;
- let frame = null;
- if (details.tabId != -1)
- {
- page = new ext.Page({id: details.tabId});
- frame = ext.getFrame(
- details.tabId,
- // We are looking for the frame that contains the element which
- // has triggered this request. For most requests (e.g. images) we
- // can just use the request's frame ID, but for subdocument requests
- // (e.g. iframes) we must instead use the request's parent frame ID.
- details.type == "sub_frame" ? details.parentFrameId : details.frameId
- );
- }
+ let page = new ext.Page({id: details.tabId});
+ let frame = ext.getFrame(
+ details.tabId,
+ // We are looking for the frame that contains the element which
+ // has triggered this request. For most requests (e.g. images) we
+ // can just use the request's frame ID, but for subdocument requests
+ // (e.g. iframes) we must instead use the request's parent frame ID.
+ details.type == "sub_frame" ? details.parentFrameId : details.frameId
+ );
- if (checkWhitelisted(page, frame, originUrl))
+ // On Chromium >= 63, if both the frame is unknown and we haven't get
+ // an "initator", this implies a request sent by the browser itself
+ // (on older versions of Chromium, due to the lack of "initator",
+ // this can also indicate a request sent by a Shared/Service Worker).
+ if ((!frame && !originUrl) || checkWhitelisted(page, frame, originUrl))
kzar 2018/04/16 15:53:38 I'd rather not mix new check with the whitelisting
Sebastian Noack 2018/04/16 16:42:21 Done.
return;
let type = resourceTypes.get(details.type) || "OTHER";
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld