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

Unified Diff: lib/requestBlocker.js

Issue 29394585: Issue 5027 - Use updated webRequest API for WebSocket blocking (Closed)
Patch Set: change commit message, add chrome version to include.preload.js comments Created March 29, 2017, 12:04 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 | « lib/csp.js ('k') | metadata.chrome » ('j') | 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
@@ -147,17 +147,24 @@
FilterNotifier.on("subscription.removed", onFilterChange);
FilterNotifier.on("subscription.updated", onFilterChange);
FilterNotifier.on("subscription.disabled", arg => onFilterChange(arg, true));
FilterNotifier.on("filter.added", onFilterChange);
FilterNotifier.on("filter.removed", onFilterChange);
FilterNotifier.on("filter.disabled", arg => onFilterChange(arg, true));
FilterNotifier.on("load", onFilterChange);
-port.on("request.websocket", (msg, sender) =>
+// Before Chrome 58, the webRequest API didn't intercept WebSocket connections,
+// (see https://crbug.com/129353). Hence we patched the WebSocket object as a
+// workaround. WebSocket connections detected by this workaround are handled
+// below.
+if (!("WEBSOCKET" in chrome.webRequest.ResourceType))
{
- return ext.webRequest.onBeforeRequest._dispatch(
- new URL(msg.url),
- "WEBSOCKET",
- sender.page,
- sender.frame
- ).indexOf(false) != -1;
-});
+ port.on("request.websocket", (msg, sender) =>
+ {
+ return ext.webRequest.onBeforeRequest._dispatch(
+ new URL(msg.url),
+ "WEBSOCKET",
+ sender.page,
+ sender.frame
+ ).indexOf(false) != -1;
+ });
+}
« no previous file with comments | « lib/csp.js ('k') | metadata.chrome » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld