Index: ext/background.js |
=================================================================== |
--- a/ext/background.js |
+++ b/ext/background.js |
@@ -558,16 +558,26 @@ |
} |
} |
}); |
}); |
}); |
chrome.webRequest.onBeforeRequest.addListener(details => |
{ |
+ // Filter out requests from non web protocols. Ideally, we'd explicitly |
+ // specify the protocols we are interested in (i.e. http://, https://, |
+ // ws:// and wss://) with the url patterns, given below, when adding this |
+ // listener. But unfortunately, Chrome <=57 doesn't support the WebSocket |
+ // protocol and is causing an error if it is given. |
+ let url = new URL(details.url); |
Sebastian Noack
2017/04/20 19:59:48
Perhaps move this after the check below, so that w
Jon Sonesen
2017/04/20 20:04:48
Done.
|
+ if (url.protocol != "http:" && url.protocol != "https:" && |
+ url.protocol != "ws:" && url.protocol != "wss:") |
+ return; |
+ |
// The high-level code isn't interested in requests that aren't |
// related to a tab or requests loading a top-level document, |
// those should never be blocked. |
if (details.tabId == -1 || details.type == "main_frame") |
return; |
// We are looking for the frame that contains the element which |
// has triggered this request. For most requests (e.g. images) we |
@@ -579,26 +589,26 @@ |
frameId = details.parentFrameId; |
type = "SUBDOCUMENT"; |
} |
let frame = ext.getFrame(details.tabId, frameId); |
if (frame) |
{ |
let results = ext.webRequest.onBeforeRequest._dispatch( |
- new URL(details.url), |
+ url, |
Sebastian Noack
2017/04/20 19:59:48
Nit: Wrapping after each argument, while most argu
Jon Sonesen
2017/04/20 20:04:48
Done.
|
type.toUpperCase(), |
new Page({id: details.tabId}), |
frame |
); |
if (results.indexOf(false) != -1) |
return {cancel: true}; |
} |
- }, {urls: ["https://*/*", "http://*/*", "ws://*/*", "wss://*/*"]}, ["blocking"]); |
+ }, {urls: ["<all_urls>"]}, ["blocking"]); |
/* Message passing */ |
chrome.runtime.onMessage.addListener((message, rawSender, sendResponse) => |
{ |
let sender = {}; |