catch uvHook failure, use window.websocket

This commit is contained in:
David Reed 2022-11-20 01:48:43 -05:00
parent 4c6c652fe2
commit 1b35d03f6c
No known key found for this signature in database
GPG key ID: 2211691D8A1EE72F

View file

@ -703,7 +703,10 @@ function __uvHook(window, config = {}, bare = '/bare/') {
win.__uv$bareData = __uv.bareData;
win.__uv$cookies = __uv.cookieStr;
if (!win.__uv) __uvHook(win, config, bare);
} catch (e) {}
} catch (e) {
console.error('catastrophic failure');
console.error(e);
}
}
client.element.hookProperty(HTMLIFrameElement, 'contentWindow', {
@ -1155,7 +1158,7 @@ function __uvHook(window, config = {}, bare = '/bare/') {
'binaryType',
]) {
const officialDesc = Object.getOwnPropertyDescriptor(
WebSocket.prototype,
window.WebSocket.prototype,
hook
);
const customDesc = Object.getOwnPropertyDescriptor(
@ -1170,10 +1173,14 @@ function __uvHook(window, config = {}, bare = '/bare/') {
client.emit('wrap', customDesc.get, officialDesc.get);
}
client.emit('wrap', WebSocket.prototype.send, MockWebSocket.prototype.send);
client.emit(
'wrap',
WebSocket.prototype.close,
window.WebSocket.prototype.send,
MockWebSocket.prototype.send
);
client.emit(
'wrap',
window.WebSocket.prototype.close,
MockWebSocket.prototype.close
);