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

Handle module resolution when there is no active script #4181

Merged
merged 2 commits into from
Nov 22, 2018

Conversation

domenic
Copy link
Member

@domenic domenic commented Nov 19, 2018

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.

@domenic domenic added needs tests Moving the issue forward requires someone to write tests topic: script labels Nov 19, 2018
Copy link
Member

@domfarolino domfarolino left a 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>
Copy link
Member

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.

Copy link
Member

@annevk annevk left a 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?

@gsnedders
Copy link
Member

gsnedders commented Nov 20, 2018

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.)

I don't think we guarantee that? e.g., in Blink (with run-webkit-tests) it becomes this.

@domenic
Copy link
Member Author

domenic commented Nov 20, 2018

@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?

@domenic
Copy link
Member Author

domenic commented Nov 20, 2018

I guess I could write manual tests...

@domfarolino
Copy link
Member

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:

  1. Seeing what browsers need bugs
  2. Merging this
  3. Opening an issue on WPT to see if it might be possible to get user-simulated clicks in the infra
  4. And if that is possible, filing an issue similar to Remaining module credential tests to write web-platform-tests/wpt#13426 for tracking
  5. Otherwise, we port some manual tests over :(

@gsnedders
Copy link
Member

@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?

Yeah. Do you know if there's any way to do this in Blink's LayoutTests today, FWIW?

@domenic
Copy link
Member Author

domenic commented Nov 20, 2018

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.)

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.
@domenic domenic force-pushed the dynamic-import-event-handlers branch from 1ac8d01 to 49423b9 Compare November 20, 2018 21:12
@domenic
Copy link
Member Author

domenic commented Nov 20, 2018

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.

@domenic
Copy link
Member Author

domenic commented Nov 20, 2018

Manual-for-now tests at web-platform-tests/wpt#14158; discussion on how to automate at web-platform-tests/wpt#14158.

@domenic domenic removed the needs tests Moving the issue forward requires someone to write tests label Nov 20, 2018
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,
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

Choose a reason for hiding this comment

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

i.e.,

Copy link
Member

@annevk annevk left a 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...

Copy link
Member

@domfarolino domfarolino left a comment

Choose a reason for hiding this comment

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

Makes sense & lgtm

@domenic domenic merged commit 3e48877 into master Nov 22, 2018
@domenic domenic deleted the dynamic-import-event-handlers branch November 22, 2018 00:34
foolip pushed a commit to web-platform-tests/wpt that referenced this pull request Nov 22, 2018
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 11, 2018
…(), 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
xeonchen pushed a commit to xeonchen/gecko that referenced this pull request Dec 11, 2018
…(), 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
moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Dec 11, 2018
…(), 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
mykmelez pushed a commit to mykmelez/gecko that referenced this pull request Dec 12, 2018
…(), 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
domenic added a commit that referenced this pull request Jan 17, 2019
domenic added a commit that referenced this pull request Feb 8, 2019
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
mustaqahmed pushed a commit to mustaqahmed/html that referenced this pull request Feb 15, 2019
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…(), 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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Oct 3, 2019
…(), 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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…(), 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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Oct 3, 2019
…(), 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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…(), 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
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Oct 3, 2019
…(), 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

There is no active script when a user triggers an inline event handler
4 participants