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: Separate checks Created April 16, 2018, 4:35 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,39 +157,33 @@
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:
// * 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
+ );
+
+ // 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)
+ return;
if (checkWhitelisted(page, frame, originUrl))
return;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld