diff --git a/lib/browser/websocket.ts b/lib/browser/websocket.ts index f653a3a59..7cfa16179 100644 --- a/lib/browser/websocket.ts +++ b/lib/browser/websocket.ts @@ -30,5 +30,5 @@ export function apply(_global: any) { return proxySocket; }; - (global).WebSocket.prototype = Object.create(WS.prototype, {constructor:{value: WebSocket}}); + for (var prop in WS) { _global.WebSocket[prop] = WS[prop]; } } diff --git a/test/browser/WebSocket.spec.ts b/test/browser/WebSocket.spec.ts index 02a651b3d..ca0c99cf8 100644 --- a/test/browser/WebSocket.spec.ts +++ b/test/browser/WebSocket.spec.ts @@ -118,5 +118,12 @@ if (!window['soucelabs']) { done(); }, 100); }, TIMEOUT); + + it('should have constants', function () { + expect(Object.keys(WebSocket)).toContain('CONNECTING'); + expect(Object.keys(WebSocket)).toContain('OPEN'); + expect(Object.keys(WebSocket)).toContain('CLOSING'); + expect(Object.keys(WebSocket)).toContain('CLOSED'); + }); })); } \ No newline at end of file