-
Notifications
You must be signed in to change notification settings - Fork 3k
Description
Consider this testcase:
<iframe></iframe>
<script>
frames[0].onunload = () => console.log("removed");
document.querySelector("iframe").remove();
</script>
Should anything get logged? Per spec, no, because:
When an iframe element is removed from a document, the user agent must discard the element's nested browsing context, if it is not null, and then set the element's nested browsing context to null.
followed by a note that
This happens without any unload events firing (the nested browsing context and its Document are discarded, not unloaded).
But Firefox, Chrome, and Safari all fire an unload event in this situation.
Of particular interest, that means that in those browsers https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-open-steps step 11 can re-enter document.open, as far as I can tell. It's not clear to me how that's supposed to work. There's a web platform test at html/browsers/browsing-the-web/unloading-documents/004.html
that sort of ends up exercising this, but it has various issues (like html/browsers/browsing-the-web/unloading-documents/support/004b.html
opening parent.document
but then writing and closing document
which mean that no one passes it right now...