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

Is that correct to destroy a document before unloading all descendants? #10288

Open
kalenikaliaksandr opened this issue Apr 19, 2024 · 0 comments

Comments

@kalenikaliaksandr
Copy link

What is the issue with the HTML Standard?

Let's says there is a document with one iframe (has attribute name="test").
This document has unload event handler that executes following code window['test']

If we try to execute unload a document and its descendants algorithm on this document:

  1. There is one child navigable corresponding to the iframe, so recursive call on step 4.2 results in queuing a task to unload this iframe.
  2. Queue a task to unload the document (iframe's parent) on step 6.
  3. Execute a task that unloads iframe's document.
    3.1. Iframe's document is destroyed on step 20 while unloading.
  4. Execute a task that unloads iframe's parent document.
    4.1. Dispatching "unload" event results in executing window['test']
    4.2. Window property access triggers execution of "document-tree child navigable target name property set" where access to iframe's active document fails because iframe's document was destroyed while unloading.

Shouldn't we try to maintain invariant that all content navigables present in the DOM tree also need to have an active document until dispatching of unload events is completed?

In Ladybird's implementation I made an attempt to fix that by changing unloading order to:

  1. Unload documents of all inclusive descendant navigables without destroying them
  2. Destroy documents of all inclusive descendant navigables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant