-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Handle module resolution when there is no active script #4181
Conversation
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.
Thanks again for taking this! This looks good to me. Regarding changing the name of "default classic script fetch options" => "default script fetch options" after this PR (which was briefly discussed in the original issue), I am indifferent.
Can start looking at tests for this, but with finals coming up no guarantees on a timeline.
same two arguments.</p></li> | ||
specifier">resolving a module specifier</span> must have been previously successful with these | ||
same two arguments (either <a href="#validate-requested-module-specifiers">while creating the | ||
corresponding module script</a>, or in <span>HostImportModuleDynamically</span>).</p></li> | ||
|
||
<li><p>Let <var>resolved module script</var> be <var>moduleMap</var>[<var>url</var>]. (This entry | ||
must <span data-x="map exists">exist</span> for us to have gotten to this point.)</p></li> |
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.
Not related to the changes here, and entirely optional, but I kind of like the idea of asserting that moduleMap[url]
exists, instead of having this off to the side.
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.
I initially had some nits on using less spaces in variable names, but the mixture in this algorithm was already present. It might be nice to cleanup.
One other thought I had was that perhaps an abstraction is in order, but perhaps that gets too messy with the fetch options?
I don't think we guarantee that? e.g., in Blink (with |
@annevk yeah, the abstraction isn't worth it, I think. @gsnedders that is what I was afraid of. I guess then I should file a WPT bug asking for test infra for clicks which behave the same way as actual user clicks? In the meantime, should we merge this without tests, as it's probably untestable? |
I guess I could write manual tests... |
I wrote https://t3.glitch.me yesterday as a start for some Chrome debugging...with a little more work some of these might pass as manual tests, however I prefer:
|
Yeah. Do you know if there's any way to do this in Blink's LayoutTests today, FWIW? |
I don't know offhand, but I'll probably poke around at least a bit and report back, before filing a request. (Including verifying that the code you linked me to doesn't do something unexpectedly good, like queuing a task.) |
5355e33
to
1ac8d01
Compare
Closes #3295. This also fixes a related inaccurate assert in EnqueueJob, putting in guards for a null active script there as well and adding examples explaining the various scenarios.
1ac8d01
to
49423b9
Compare
This is ready for (and needs) re-review, as I've now incorporated some of the job-related stuff that was also discussed in #3295. |
Manual-for-now tests at web-platform-tests/wpt#14158; discussion on how to automate at web-platform-tests/wpt#14158. |
is a built-in function that does not originate from any particular <span | ||
data-x="concept-script">script</span>.</p> | ||
|
||
<p>With this step in place, the active script is propagated from the above code into the job, |
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.
Wasn't the plan to remove jobs completely and have JavaScript instead queue things to the host? That would also resolve this, no?
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.
That is the current setup, just done via money patch. It's not a "removal" though; the things JavaScript posts are still called "jobs", which we convert to microtasks.
<p>In this case, the JavaScript function for the <span data-x="event handlers">event | ||
handler</span> will be created by the <span data-x="getting the current value of the event | ||
handler">get the current value of the event handler</span> algorithm as a direct result of user | ||
action, with no script on the stack (i.e. no <span>active script</span>). Thus, when the |
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.
i.e.,
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.
Seems fine, but please address the nit (maybe at some point we should do those programmatically). I also noticed some lack of "If ..., then ..." but we're not consistent so...
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.
Makes sense & lgtm
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157
Closes #4267. Related to previous work in #4181. Tests: web-platform-tests/wpt#15251
Closes whatwg#4267. Related to previous work in whatwg#4181. Tests: web-platform-tests/wpt#15251
Closes whatwg#4267. Related to previous work in whatwg#4181. Tests: web-platform-tests/wpt#15251
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157 UltraBlame original commit: a1cc7364d13d9e2d8561042a2e204792ac344496
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157 UltraBlame original commit: 8b5324f6bd04819422f05d72d7d72219ef2b1b2b
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157 UltraBlame original commit: a1cc7364d13d9e2d8561042a2e204792ac344496
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157 UltraBlame original commit: 8b5324f6bd04819422f05d72d7d72219ef2b1b2b
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157 UltraBlame original commit: a1cc7364d13d9e2d8561042a2e204792ac344496
…(), a=testonly Automatic update from web-platform-testsAdd tests for no active script in import() (#14157) Follows whatwg/html#4181. -- wpt-commits: 5241a3fe2c638f9fadcc040f39f3e6a71a2be2e1 wpt-pr: 14157 UltraBlame original commit: 8b5324f6bd04819422f05d72d7d72219ef2b1b2b
Closes #3295.
Thanks @jonco3 for the prompt on fixing this.
Tests: I believe this is technically not tested yet, although there are a lot of adjacent tests, e.g. https://github.com/web-platform-tests/wpt/blob/fca3dc941825b298617f8bf6c9ce7c196b4de6f5/html/semantics/scripting-1/the-script-element/module/dynamic-import/string-compilation-base-url-inline-module.html#L29-L32 . But those don't test the specific scenario here, because when you call the
.onclick
getter, there is an active script.Instead we need a test that uses the fancy new testdriver thingies to actually click the div (instead of having JS call
div.onclick()
as the existing tests do).Even that might not really work; @gsnedders do you know if the JS engine has script "on the stack" when testdriver clicks a div? (The answer we want is "no", just like when a user clicks the div.)
Ideally those tests should actually have a different document base URL than script base URL, e.g. by using an external script.
It would be really appreciated if someone else were up for writing those tests; I would be happy to review.