NEW 175802
RTCPeerConnection addEventListener handler context changed (a new this?)
https://bugs.webkit.org/show_bug.cgi?id=175802
Summary RTCPeerConnection addEventListener handler context changed (a new this?)
Jia Li
Reported 2017-08-21 17:48:46 PDT
The reproduce code is below. <html> <head> <script> window.onload = function () { console.log('Create RTCPeerConnection') const pc = new RTCPeerConnection() console.log('Add "track" event listener') pc.addEventListener('track', function(_event) { console.log('this === pc', this === pc); console.log('track event', _event); }); console.log('Dispatch "track" event') pc.dispatchEvent(new Event('track')) } </script> </head> </html> the output will be ------------------------ this === pc, false in the eventhandler of `track`, the context `this` is different with `pc`. In Firefox and Chrome, this is the same with pc.
Attachments
Mark Roberts
Comment 1 2017-08-21 19:11:23 PDT
I can confirm this happens for apparently any event dispatched to RTCPeerConnection (all WebRTC-related events and even arbitrary events like "foo").
Radar WebKit Bug Importer
Comment 2 2017-08-23 09:12:07 PDT
Note You need to log in before you can comment on or make changes to this bug.