whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.06k stars 2.65k forks source link

"destroy a child navigable" does not destroy a document #10242

Open kalenikaliaksandr opened 6 months ago

kalenikaliaksandr commented 6 months ago

What is the issue with the HTML Standard?

Steps to reproduce:

  1. "destroy a child navigable" does "Set container's content navigable to null." on step 3.
  2. At this point navigable's active document is not fully active because container's navigable has been set to null on the previous step.
  3. Non of the tasks scheduled on step 5 "Destroy a document and its descendants given navigable's active document." will be executed because document is no longer fully active.

    Bug was introduced in https://github.com/whatwg/html/commit/4ca6ec020803cbdfd05f90475b6e3a3a0d5b2424 cc @domenic

domenic commented 6 months ago

Again, it would be really helpful if you had any fix suggestions with these bug reports :)

kalenikaliaksandr commented 6 months ago

sure, to fix this one, steps need to be rearranged to keep document fully active until all tasks scheduled by destroy a document and its descendants are completed.

probably the most obvious way to implement this is by adding destroyed flag to each navigable and change steps of destroy a child navigable to do:

  1. Let navigable be container's content navigable.

  2. If navigable is null, then return.

  3. if navigable.destroyed is true then return.

  4. navigable.destroyed = true.

  5. Set container's content navigable to null.

  6. Inform the navigation API about child navigable destruction given navigable.

  7. Destroy a document and its descendants given navigable's active document. and afterAllDestruction steps set to do following:

    1. Set container's content navigable to null.
  8. the rest of existing steps