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

Unified Diff: include.preload.js

Issue 29349816: Fixes 4331, 4332 - WebSocket.length and instanceof WebSocket (Closed)
Patch Set: Created Aug. 15, 2016, 7:22 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 | lib/requestBlocker.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: include.preload.js
diff --git a/include.preload.js b/include.preload.js
index 1ea213d7479fed931b8dc3985746cc162fc6dc77..b41deea4931c823cf7e6b650badf6bd7c998f56c 100644
--- a/include.preload.js
+++ b/include.preload.js
@@ -362,7 +362,7 @@ function wrapWebSocket(document)
document.addEventListener(eventName, function(event)
{
ext.backgroundPage.sendMessage({
- type: "websocket-request",
+ type: "request.websocket",
url: event.detail.url
}, function (block)
{
@@ -398,7 +398,7 @@ function wrapWebSocket(document)
}));
}
- WebSocket = function WrappedWebSocket(url, protocols)
+ function WrappedWebSocket(url)
kzar 2016/08/15 19:29:00 For some reason if I did this in one step I no lon
{
// Throw correct exceptions if the constructor is used improperly.
if (!(this instanceof WrappedWebSocket)) return RealWebSocket();
@@ -408,7 +408,7 @@ function wrapWebSocket(document)
if (arguments.length == 1)
websocket = new RealWebSocket(url);
else
- websocket = new RealWebSocket(url, protocols);
+ websocket = new RealWebSocket(url, arguments[1]);
checkRequest(websocket.url, function(blocked)
{
@@ -417,8 +417,10 @@ function wrapWebSocket(document)
});
return websocket;
- }.bind();
-
+ }
+ Object.defineProperty(WrappedWebSocket, "prototype",
+ {value: RealWebSocket.prototype});
kzar 2016/08/15 19:29:00 We have to define the prototype here so that `...
Wladimir Palant 2016/08/15 20:20:35 Since the website cannot access WrappedWebSocket,
kzar 2016/08/15 20:36:21 Done.
+ WebSocket = WrappedWebSocket.bind();
Object.defineProperties(WebSocket, {
CONNECTING: {value: RealWebSocket.CONNECTING, enumerable: true},
OPEN: {value: RealWebSocket.OPEN, enumerable: true},
« no previous file with comments | « no previous file | lib/requestBlocker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld