WebSocket patch on Android causes infinite recursion #233
Description
It looks like when canPatchViaPropertyDescriptor()
is false, WebSocket's addEventListener is patched again: property-descriptor.ts#L29, websocket.ts#L6 after already being patched as part of browser.ts#L27.
Setting any of the WebSocket event handlers then causes infinite recursion as the "original" handler that gets called by the second patch is the already patched one from when the EventTarget handlers were patched: utils.ts#L86
You can reproduce minimally on desktop Chrome by breaking on property-descriptor.ts#L14 and having it return false: http://plnkr.co/edit/XF2mZMA6XBHuApVz6BJ4?p=preview (line 736 for me).
We had reports of this happening on Android 4.4 and 5.1, but I've only been able to reproduce on device with 4.4, though in theory it would happen for any devices where patching via property descriptors is unavailable.
Happy to submit a PR, but there is a lot going on between various different browsers and I'm not entirely sure what the best solution that wouldn't break other things is.