Created
December 11, 2016 08:58
-
-
Save bakkot/c93d319ea727260562131765e548fe8d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let frame = document.body.appendChild(document.createElement('iframe')); | |
frame.addEventListener('load', ()=>{ | |
let w = frame.contentWindow; | |
let evt; | |
w.addEventListener('error', e=>{evt = e;}); | |
let scr = w.document.createElement('script'); | |
scr.text = 'throw 42;'; | |
w.document.body.appendChild(scr); // this line executes synchronously and triggers w's new 'error' event handler synchronously? | |
console.log(evt); // so that by the time this line is hit, 'evt' will have been assigned? | |
}); | |
frame.src=''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment