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

Remove layout blockers before invoking arbitrary content callbacks #34482

Closed
wants to merge 1 commit into from

Conversation

jdm
Copy link
Member

@jdm jdm commented Dec 5, 2024

When manipulating the DOM tree we always want web content to only see stable states after any mutations are applied. We introduced script/layout blockers in 14b0de3 to catch cases where an unstable DOM could be exposed to web content. These restrictions were too strict, however; the spec mandates that steps like the children changed should be invoked synchronously (eg. step 9 of https://dom.spec.whatwg.org/#concept-node-insert), and it's possible to trigger web content from those steps in various ways (see the new test). Since we're careful to invoke such callbacks at times when the DOM is stable, this means that we need to remove the script/layout blockers right before invoking those callbacks, rather than after they have executed.


…backs.

Signed-off-by: Josh Matthews <josh@joshmatthews.net>
@jdm jdm requested a review from gterzian as a code owner December 5, 2024 04:52
Copy link
Member

@gterzian gterzian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,

But I'm wondering if we should not file an issue to review this setup in the light of the spec.

It seems we're dealing here with the intricacies of the script element processing model, as highlighted in the example at https://html.spec.whatwg.org/#script-processing-model:children-changed-steps and I don't see this reflected in our implementation(if only through the absence of any links to these concepts).

I think the current approach will lead to continuously moving the remove_script_and_layout_blockers call to fix crashes(see for example step 7.7.1 of dom insert which runs the insertion steps and which could lead to new crashes when implementing the shadow dom), without addressing the underlying issue of spec compliance.

@jdm
Copy link
Member Author

jdm commented Dec 5, 2024

Yeah, I think it's worth having a closer look at it. I'll file that.

@jdm jdm added this pull request to the merge queue Dec 5, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 5, 2024
@jdm
Copy link
Member Author

jdm commented Dec 6, 2024

Closing in favour of #34505.

@jdm jdm closed this Dec 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants