Index: include.preload.js |
=================================================================== |
--- a/include.preload.js |
+++ b/include.preload.js |
@@ -379,6 +379,7 @@ |
// As far as possible we must track everything we use that could be |
// sabotaged by the website later in order to circumvent us. |
var RealWebSocket = WebSocket; |
+ var bindWebSocket = Function.prototype.bind.apply.bind(Function.prototype.bind, RealWebSocket); |
var closeWebSocket = Function.prototype.call.bind(RealWebSocket.prototype.close); |
var addEventListener = document.addEventListener.bind(document); |
var removeEventListener = document.removeEventListener.bind(document); |
@@ -400,13 +401,14 @@ |
})); |
} |
- WebSocket = function WrappedWebSocket(url, protocols) |
+ WebSocket = function WrappedWebSocket() |
{ |
- // Throw correct exceptions if the constructor is used improperly. |
- if (!(this instanceof WrappedWebSocket)) return RealWebSocket(); |
- if (arguments.length < 1) return new RealWebSocket(); |
+ var args = [this]; |
+ for (var i = 0; i < arguments.length; i++) |
+ args.push(arguments[i]); |
- var websocket = new RealWebSocket(url, protocols); |
+ var ctor = bindWebSocket(args); |
+ var websocket = this instanceof WrappedWebSocket ? new ctor : ctor(); |
checkRequest(websocket.url, function(blocked) |
{ |