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

Unified Diff: lib/requestBlocker.js

Issue 29739603: Issue 6544 - Prevent requests sent by Chrome or Adblock Plus from being blocked (Closed)
Patch Set: Created April 2, 2018, 3:03 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 | « 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
@@ -29,6 +29,8 @@
const {port} = require("messaging");
const devtools = require("devtools");
+const extensionProtocol = new URL(browser.extension.getURL("")).protocol;
+
// Chrome can't distinguish between OBJECT_SUBREQUEST and OBJECT requests.
if (!browser.webRequest.ResourceType ||
!("OBJECT_SUBREQUEST" in browser.webRequest.ResourceType))
@@ -139,23 +141,18 @@
url.protocol != "ws:" && url.protocol != "wss:")
return;
- let originUrl = null;
kzar 2018/04/03 12:06:45 This diff doesn't seem right, I don't see this stu
kzar 2018/04/03 12:45:50 Oh I see, it's based on these changes https://code
- if (details.originUrl)
- {
- originUrl = new URL(details.originUrl);
+ // Firefox provides us with the full origin URL, while Chromium (>=63)
+ // provides only the protocol + host of the (top-level) document which
+ // the request originates from through the "initiator" property.
+ let originUrl = details.originUrl ? new URL(details.originUrl) :
+ details.initiator ? new URL(details.initiator) : null;
- // Firefox (only) allows to intercept requests sent by the browser
- // and other extensions. We don't want to block these.
- if (originUrl.protocol == "chrome:" ||
- originUrl.protocol == "moz-extension:")
- return;
- }
- // Fallback to "initiator" on Chrome >=63. It doesn't include the
- // path (unlike "originUrl" on Firefox), but is still good enough
- // (in case the tab/frame is unknown) for the $domain filter option
- // and most document exception rules which only match the domain part.
- else if (details.initiator)
- originUrl = new URL(details.initiator);
+ // Firefox allows to intercept requests sent by all extensions or
+ // the browser (i.e. chrome://), while Chromium only allows to interecept
kzar 2018/04/03 12:06:45 Do you mean chrome:// for Firefox? Also how come t
Sebastian Noack 2018/04/03 23:36:28 Yes, "chrome:" is the protocol for content that is
kzar 2018/04/04 17:38:44 Acknowledged.
Sebastian Noack 2018/04/05 00:23:24 I changed the scope of this change, now also ignor
+ // requests sent by this extension. We don't want to block any of these.
+ if (originUrl && (originUrl.protocol == extensionProtocol ||
+ originUrl.protocol == "chrome:"))
+ return;
let page = null;
let frame = null;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld