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

Test document.currentScript when script is moved during evaluation #20775

Conversation

hiroshige-g
Copy link
Contributor

@hiroshige-g hiroshige-g commented Dec 13, 2019

In the spec before whatwg/html#5154,

script element's node document is re-evaluated after script evaluation,
and thus if a script is moved to another Document during its own evaluation,
currentScript of the new document could be updated.

After #5154, currentScript is always set/reset on the same Document,
which is expected, and tested so here.

Browser implementations already follow the new spec behavior (as expected).

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

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

Wow, good spot. I will update the commit message to note that this is a fix, not editorial.

domenic added a commit to whatwg/html that referenced this pull request Dec 13, 2019
One normative fix: by saving the script element's node document before
evaluation, this properly changes that document's currentScript back
after evaluation. As previously written, a script that moved during
evaluation would cause its new node document's currentScript to update.

Tests: web-platform-tests/wpt#20775

Editorial cleanups:

* Use a named argument, scriptElement
* Use the saved document variable throughout
* Cleanup source formatting
* Remove <!-- SCRIPT EXEC --> comments
domenic added a commit to whatwg/html that referenced this pull request Jan 9, 2020
One normative fix: by saving the script element's node document before
evaluation, this properly changes that document's currentScript back
after evaluation. As previously written, a script that moved during
evaluation would cause its new node document's currentScript to update.

Tests: web-platform-tests/wpt#20775

Editorial cleanups:

* Use a named argument, scriptElement
* Use the saved document variable throughout
* Cleanup source formatting
* Remove <!-- SCRIPT EXEC --> comments
@foolip
Copy link
Member

foolip commented Jan 16, 2020

@hiroshige-g there were Taskcluster troubles. If you try rebasing this PR it'll probably be fine now.

@domenic
Copy link
Member

domenic commented Mar 10, 2021

Trying to reboot CI so we can get this merged.

@domenic domenic closed this Mar 10, 2021
@domenic domenic reopened this Mar 10, 2021
In the spec before whatwg/html#5154,
`script element's node document` is re-evaluated after script evaluation,
and thus if a script is moved to another Document during its own evaluation,
`currentScript` of the *new* document could be updated.

After web-platform-tests#5154, `currentScript` is always set/reset on the same Document,
which is expected, and tested so here.
@domenic domenic force-pushed the scripts-between-documents-during-evaluation branch from 1deb1fb to 304daa9 Compare March 10, 2021 18:54
@domenic domenic merged commit 4725b23 into web-platform-tests:master Mar 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants