-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Use DOM's post-connection steps for <script>
elements
#10188
Conversation
Given the old Chromium change that introduced this behavior: - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed ... the old discussion in: - whatwg/dom#732 (review) - whatwg/html#4354 (comment) ... and the much newer discussion in: - whatwg/dom#1261 - whatwg/html#10188 This CL upstreams an old test ensuring that removal of a child node from a script node that has not "already started" [1], does not trigger script execution. Only the *insertion* of child nodes (to a non-already-started script node) should trigger that script's execution. [1]: https://html.spec.whatwg.org/C#already-started [email protected] Bug: 40150299 Change-Id: I750ccee0a2be834360c557042e975547c8ddd32c
Given the old Chromium change that introduced this behavior: - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed ... the old discussion in: - whatwg/dom#732 (review) - whatwg/html#4354 (comment) ... and the much newer discussion in: - whatwg/dom#1261 - whatwg/html#10188 This CL upstreams an old test ensuring that removal of a child node from a script node that has not "already started" [1], does not trigger script execution. Only the *insertion* of child nodes (to a non-already-started script node) should trigger that script's execution. [1]: https://html.spec.whatwg.org/C#already-started [email protected] Bug: 40150299 Change-Id: I750ccee0a2be834360c557042e975547c8ddd32c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367238 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272330}
Given the old Chromium change that introduced this behavior: - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed ... the old discussion in: - whatwg/dom#732 (review) - whatwg/html#4354 (comment) ... and the much newer discussion in: - whatwg/dom#1261 - whatwg/html#10188 This CL upstreams an old test ensuring that removal of a child node from a script node that has not "already started" [1], does not trigger script execution. Only the *insertion* of child nodes (to a non-already-started script node) should trigger that script's execution. [1]: https://html.spec.whatwg.org/C#already-started [email protected] Bug: 40150299 Change-Id: I750ccee0a2be834360c557042e975547c8ddd32c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367238 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272330}
This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7
This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7
This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367667 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272720}
This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367667 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272720}
…er execution, a=testonly Automatic update from web-platform-tests WPT: Script child removal does not trigger execution Given the old Chromium change that introduced this behavior: - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed ... the old discussion in: - whatwg/dom#732 (review) - whatwg/html#4354 (comment) ... and the much newer discussion in: - whatwg/dom#1261 - whatwg/html#10188 This CL upstreams an old test ensuring that removal of a child node from a script node that has not "already started" [1], does not trigger script execution. Only the *insertion* of child nodes (to a non-already-started script node) should trigger that script's execution. [1]: https://html.spec.whatwg.org/C#already-started [email protected] Bug: 40150299 Change-Id: I750ccee0a2be834360c557042e975547c8ddd32c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367238 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272330} -- wpt-commits: cc99c62762135f7e193941e32c3f738960c256be wpt-pr: 45085
…e WPT expectations, a=testonly Automatic update from web-platform-tests DOM: Correct script-in-script atomic move WPT expectations This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367667 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272720} -- wpt-commits: e25a0c84dac911c78265c142ab9e178e3936fee2 wpt-pr: 45094
…er execution, a=testonly Automatic update from web-platform-tests WPT: Script child removal does not trigger execution Given the old Chromium change that introduced this behavior: - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed ... the old discussion in: - whatwg/dom#732 (review) - whatwg/html#4354 (comment) ... and the much newer discussion in: - whatwg/dom#1261 - whatwg/html#10188 This CL upstreams an old test ensuring that removal of a child node from a script node that has not "already started" [1], does not trigger script execution. Only the *insertion* of child nodes (to a non-already-started script node) should trigger that script's execution. [1]: https://html.spec.whatwg.org/C#already-started [email protected] Bug: 40150299 Change-Id: I750ccee0a2be834360c557042e975547c8ddd32c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367238 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272330} -- wpt-commits: cc99c62762135f7e193941e32c3f738960c256be wpt-pr: 45085
…e WPT expectations, a=testonly Automatic update from web-platform-tests DOM: Correct script-in-script atomic move WPT expectations This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367667 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272720} -- wpt-commits: e25a0c84dac911c78265c142ab9e178e3936fee2 wpt-pr: 45094
Given the old Chromium change that introduced this behavior: - https://source.chromium.org/chromium/chromium/src/+/604e798ec6ee30f44d57a5c4a44ce3dab3a871ed ... the old discussion in: - whatwg/dom#732 (review) - whatwg/html#4354 (comment) ... and the much newer discussion in: - whatwg/dom#1261 - whatwg/html#10188 This CL upstreams an old test ensuring that removal of a child node from a script node that has not "already started" [1], does not trigger script execution. Only the *insertion* of child nodes (to a non-already-started script node) should trigger that script's execution. [1]: https://html.spec.whatwg.org/C#already-started [email protected] Bug: 40150299 Change-Id: I750ccee0a2be834360c557042e975547c8ddd32c Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367238 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272330}
This CL corrects the script-in-script insertion test, to assert that when an "outer" script element (that has not yet been prepared/executed) gets an "inner" script element inserted into it, the outer script runs before the inner one. This is a break in what the HTML Standard previously required, before whatwg/html#10188. [email protected] Bug: 40150299 Change-Id: If8cdce18a13678ac0646d81bc14850b2f26b6eb7 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5367667 Reviewed-by: Noam Rosenthal <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1272720}
@annevk @smaug---- could you take a look please? |
<script>
elements<script>
elements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good modulo a question about the src attribute change steps. @smaug---- please review now if you still want to review. @domenic do you want to have a look as well since this touches script
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huge improvement! But yeah, let's clean up the src attribute change handling, since everything else is so nice.
See this HTML Standard PR thread: whatwg/html#10188 (comment). R=domenic Bug: N/A Change-Id: I31065f76e324f71d2b4ae52813b3b37d3b4467c0
See this HTML Standard PR thread: whatwg/html#10188 (comment). R=domenic Bug: N/A Change-Id: I31065f76e324f71d2b4ae52813b3b37d3b4467c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5809759 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1346661}
See this HTML Standard PR thread: whatwg/html#10188 (comment). R=domenic Bug: N/A Change-Id: I31065f76e324f71d2b4ae52813b3b37d3b4467c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5809759 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1346661}
…ger preparation, a=testonly Automatic update from web-platform-tests WPT: Ensure `src` attribute changes trigger preparation See this HTML Standard PR thread: whatwg/html#10188 (comment). R=domenic Bug: N/A Change-Id: I31065f76e324f71d2b4ae52813b3b37d3b4467c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5809759 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1346661} -- wpt-commits: cab88353d0991229e6d81f8fb6b0862fe9495de8 wpt-pr: 47782
…ger preparation, a=testonly Automatic update from web-platform-tests WPT: Ensure `src` attribute changes trigger preparation See this HTML Standard PR thread: whatwg/html#10188 (comment). R=domenic Bug: N/A Change-Id: I31065f76e324f71d2b4ae52813b3b37d3b4467c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5809759 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1346661} -- wpt-commits: cab88353d0991229e6d81f8fb6b0862fe9495de8 wpt-pr: 47782
…ger preparation, a=testonly Automatic update from web-platform-tests WPT: Ensure `src` attribute changes trigger preparation See this HTML Standard PR thread: whatwg/html#10188 (comment). R=domenic Bug: N/A Change-Id: I31065f76e324f71d2b4ae52813b3b37d3b4467c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5809759 Reviewed-by: Domenic Denicola <[email protected]> Commit-Queue: Dominic Farolino <[email protected]> Cr-Commit-Position: refs/heads/main@{#1346661} -- wpt-commits: cab88353d0991229e6d81f8fb6b0862fe9495de8 wpt-pr: 47782
This PR (part 1 of probably 2) uses the newly-introduced DOM Standard "post-connection steps" (see whatwg/dom#1261), which are run for all nodes in a batch of freshly-inserted nodes, after all DOM insertions take place. The purpose of these steps is to provide an opportunity for script executing side effects to take place during the insertion flow, but after after all DOM mutations are completed atomically. This PR effectively supersedes a portion of #4354.
Before this PR, the HTML standard executed scripts during the
<script>
HTML element insertion steps. This means that when a batch of script elements were "atomically" inserted, each script would run synchronously after its DOM insertion and before the next DOM insertion took place.After this PR, to make progress on whatwg/dom#808 and move to a more "atomic" model where script execution only takes place after all pending DOM tree insertions happen, script execution moves to a model that more closely resembles that of Chromium and Firefox. We push script execution back to the post-connection steps, which run after all DOM insertions are complete. This gives two notable observables differences from the old spec:
script.append(new Text("..."), new Text("..."), ...)
would "prepare" and "execute" thescript
synchronously after the first text node was inserted, because HTML says that whenever a child element is inserted to a connected script element, that's when the script gets prepared. All subsequent text nodes that are appended as children would come after the script has already started, so they would not execute. What I think the standard really means though, is to count on the script's "children changed steps" that DOM offers. After this PR, the execution ofscript
is run after the entire batch of children get inserted, because the execution is tied to the "children changed steps", which run after all nodes are inserted. Therefore, execution would include all text that was atomically added to the script. This is tested here; Safari is the odd one out (I guess because it's not using the "children changed steps" properly?)<script>
elements inserted as children to a parent<script>
element will run (as a result of its "post-connection steps") after the parent script gets a chance at running (as a result of its "children changed steps", which run before any post-connection steps). See this concrete example I added in the spec. This has a WPT too, but it assumes a blend of the old a new models (which forced nested script execution before parent script execution). I'm updating it to match this spec, in DOM: Correct script-in-script atomic move WPT expectations web-platform-tests/wpt#45094.(See WHATWG Working Mode: Changes for more details.)
/infrastructure.html ( diff )
/scripting.html ( diff )