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

Propagate fetch referrer in dynamic imports #9407

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

nicolo-ribaudo
Copy link
Contributor

@nicolo-ribaudo nicolo-ribaudo commented Jun 9, 2023

This change removes the explicit non-propagation of the referrer for dynamic import() calls, and fixes #3744. By doing so, it aligns fetching static and dynamic imports.

Note that the spec doesn't include the explicit exception for import() because it has been explicitly wanted, but because this distinction happened accidentally when static and dynamic imports had two separate paths and I had to add it explicitly when unifying them in #8253.

Firefox currently implements the new behavior, while Webkit and Chroimum implement the old behavior.



/webappapis.html ( diff )

@domenic
Copy link
Member

domenic commented Jun 12, 2023

@hiroshige-g and/or @domfarolino do you think Chrome would be willing to change this?

@domfarolino
Copy link
Member

I'm just getting back from vacation, so I'll try and take a look this week.

@domfarolino
Copy link
Member

I'm willing to implement this in Chromium, so I guess we should get signals from WebKit/Gecko now.

@nicolo-ribaudo
Copy link
Contributor Author

cc @jonco3 since you originally found this

@jonco3
Copy link

jonco3 commented Jun 29, 2023

Yes, Mozilla support this change.

@domenic domenic merged commit d134086 into whatwg:main Jul 4, 2023
2 checks passed
domenic pushed a commit to web-platform-tests/wpt that referenced this pull request Jul 4, 2023
@domenic
Copy link
Member

domenic commented Jul 4, 2023

Thanks for your work here @nicolo-ribaudo! Can you file Chromium and WebKit bugs, and edit the OP to link to them?

@nicolo-ribaudo nicolo-ribaudo deleted the dyn-imp-referrer branch July 4, 2023 05:35
@nicolo-ribaudo
Copy link
Contributor Author

Done 👍

moz-v2v-gh pushed a commit to mozilla/gecko-dev that referenced this pull request Jul 12, 2023
… a=testonly

Automatic update from web-platform-tests
Add test for referrer in module imports

Follows whatwg/html#9407.
--

wpt-commits: 66166fa9af2d53656da3f04a0f5e114e740a00c7
wpt-pr: 40474
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified-and-comments-removed that referenced this pull request Jul 16, 2023
… a=testonly

Automatic update from web-platform-tests
Add test for referrer in module imports

Follows whatwg/html#9407.
--

wpt-commits: 66166fa9af2d53656da3f04a0f5e114e740a00c7
wpt-pr: 40474

UltraBlame original commit: 2b00c3c10894b1c7b804678961e67f9bb0c007f7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-comments-removed that referenced this pull request Jul 16, 2023
… a=testonly

Automatic update from web-platform-tests
Add test for referrer in module imports

Follows whatwg/html#9407.
--

wpt-commits: 66166fa9af2d53656da3f04a0f5e114e740a00c7
wpt-pr: 40474

UltraBlame original commit: 2b00c3c10894b1c7b804678961e67f9bb0c007f7
gecko-dev-updater pushed a commit to marco-c/gecko-dev-wordified that referenced this pull request Jul 16, 2023
… a=testonly

Automatic update from web-platform-tests
Add test for referrer in module imports

Follows whatwg/html#9407.
--

wpt-commits: 66166fa9af2d53656da3f04a0f5e114e740a00c7
wpt-pr: 40474

UltraBlame original commit: 2b00c3c10894b1c7b804678961e67f9bb0c007f7
ErichDonGubler pushed a commit to ErichDonGubler/firefox that referenced this pull request Jul 16, 2023
… a=testonly

Automatic update from web-platform-tests
Add test for referrer in module imports

Follows whatwg/html#9407.
--

wpt-commits: 66166fa9af2d53656da3f04a0f5e114e740a00c7
wpt-pr: 40474
aarongable pushed a commit to chromium/chromium that referenced this pull request Jul 19, 2023
This CL implements whatwg/html#9407, which makes
the request referrer for dynamic import() requests equal to the
referring script's base URL. This already was the case for static
imports, but now we do the same for dynamic imports.

The implementation is more complicated than the spec change because in
the spec, "fetch a single module script" takes in a referrer for use
in fetching, whereas in our implementation, we don't compute the
referrer until later in the process, and by this time we already have
lost access to the `ReferrerScriptInfo` that we have for dynamic
imports. So the way this CL works is that inside
`DynamicModuleResolver::ResolveDynamically()`, we capture the referrer
script's base URL (for use as the referrer in the import
request) — and pass it through as a new optional parameter, simulating the spec's already-existing `referrer` parameter to "fetch a single module script" — to the following methods:

Modulator::FetchTree
  ModuleTreeLinkerRegistry::Fetch
    ModuleTreeLinker::FetchRoot
      * use the new optional `referrer` argument to create the module
        script request, as "fetch a single module script" does with its
        `referrer` parameter in the spec [1]

[1]: https://html.spec.whatwg.org/multipage/webappapis.html#fetching-scripts:fetch-a-single-module-script-4

R=hiroshige@chromium.org

Bug: 1461987
Change-Id: I538a087acfb0113cdf5efa9f69947c605b2c0593
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4678043
Commit-Queue: Dominic Farolino <dom@chromium.org>
Reviewed-by: Hiroshige Hayashizaki <hiroshige@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1172405}
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.

import() should use referring script's base URL as the referrer
4 participants