Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Browsers synchronously fire pagehide & unload, while the standard doesn't #10194

Open
domfarolino opened this issue Mar 12, 2024 · 1 comment
Labels
removal/deprecation Removing or deprecating a feature

Comments

@domfarolino
Copy link
Member

What is the issue with the HTML Standard?

This isn't as much an issue with the HTML Standard, as it is a compat discussion about whether we should move it forward in an undesirable way to match what all implementations do, vs get implementations to commit to match the standard.

Per HTML, the iframe removing steps should not synchronously invoke any script in the event loop that triggered the removal. This is not only clear in the algorithms called in the removal process, but made extra clear by the note just below this dfn: https://html.spec.whatwg.org/C#the-iframe-element:html-element-removing-steps

This happens without any unload events firing (the element's content document is destroyed, not unloaded).

Unfortunately, all browsers seem to synchronously fire the pagehide event during same-origin iframe removal, and depending on the status of their unload interventions, that event too: https://wpt.fyi/results/dom/nodes/insertion-removing-steps/insertion-removing-steps-iframe.window.html?label=experimental&label=master&aligned.

I mentioned this in whatwg/dom#808 when exploring all of the opportunities that spec and implementations have to synchronously fire script in the node insertion & removal process.

Chrome is interested in experimenting (cc: @noamr @mfreed7) with the suppression of these events in at least the frame removal case, but since this carries possibly-significant compatibility risk, and since all browsers are currently aligned, we wanted to start some discussion with other vendors and editors before proceeding. I'll loop in @smaug---- and @rniwa (and @annevk since he's been involved in whatwg/dom#808), but please feel free to loop others in with more context or opinions on this. It'd be unfortunate if we had to keep this instance of synchronous script execution around forever, but I'd love to get more thoughts on how difficult it would be to remove it.

@domfarolino domfarolino added the removal/deprecation Removing or deprecating a feature label Mar 12, 2024
@annevk
Copy link
Member

annevk commented Mar 13, 2024

In principle I think not firing events for the iframe element removal case is reasonable as the primary purpose for these events is navigation and history traversal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
removal/deprecation Removing or deprecating a feature
Development

No branches or pull requests

2 participants