Hi,
I'm a WebRTC developer, and I noticed an issue with addEventListener in Safari using Zone.js. I doubt this issue is specific to WebRTC—I just happened to notice it when using the RTCPeerConnection APIs. Try for example, the following in the console for Chrome, Firefox, and Safari (11.0 or greater). They should all yield the same result.
Example without Zone.js
(async () => {
console.log('Create RTCPeerConnection')
const pc = new RTCPeerConnection()
console.log('Add "track" event listener')
let event
pc.addEventListener('track', _event => event = _event)
console.log('Dispatch "track" event')
pc.dispatchEvent(new Event('track'))
if (event) {
console.log('Success!')
} else {
console.error('Failure!')
}
})().catch(console.error)
Results
Create RTCPeerConnection
Add "track" event listener
Dispatch "track" event
Success!
Now, try loading Zone.js first and re-running the code sample.
Example with Zone.js
(async () => {
console.log('Load Zone.js')
const script = document.createElement('script')
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/zone.js/0.8.16/zone.js'
document.body.appendChild(script)
await new Promise(resolve => script.onload = resolve)
console.log('Create RTCPeerConnection')
const pc = new RTCPeerConnection()
console.log('Add "track" event listener')
let event
pc.addEventListener('track', _event => event = _event)
console.log('Dispatch "track" event')
pc.dispatchEvent(new Event('track'))
if (event) {
console.log('Success!')
} else {
console.error('Failure!')
}
})().catch(console.error)
Expected Results
Load Zone.js
Create RTCPeerConnection
Add "track" event listener
Dispatch "track" event
Success!
Actual Results (Chrome, Firefox)
Chrome and Firefox work fine.
Load Zone.js
Create RTCPeerConnection
Add "track" event listener
Dispatch "track" event
Success!
Actual Results (Safari 11.0, Safari 11.1)
Safari 11.0 and Safari 11.1 do not.
Load Zone.js
Create RTCPeerConnection
Add "track" event listener
Dispatch "track" event
Failure!
If you re-run the tests, changing out the version of Zone.js used, 0.8.12 is the last version of Zone.js that worked without error in Safari. Zone.js 0.8.13 introduced the error.
Hi,
I'm a WebRTC developer, and I noticed an issue with
addEventListenerin Safari using Zone.js. I doubt this issue is specific to WebRTC—I just happened to notice it when using the RTCPeerConnection APIs. Try for example, the following in the console for Chrome, Firefox, and Safari (11.0 or greater). They should all yield the same result.Example without Zone.js
Results
Now, try loading Zone.js first and re-running the code sample.
Example with Zone.js
Expected Results
Actual Results (Chrome, Firefox)
Chrome and Firefox work fine.
Actual Results (Safari 11.0, Safari 11.1)
Safari 11.0 and Safari 11.1 do not.
If you re-run the tests, changing out the version of Zone.js used, 0.8.12 is the last version of Zone.js that worked without error in Safari. Zone.js 0.8.13 introduced the error.