-
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
Propagate fetch referrer in dynamic imports #9407
Conversation
@hiroshige-g and/or @domfarolino do you think Chrome would be willing to change this? |
I'm just getting back from vacation, so I'll try and take a look this week. |
I'm willing to implement this in Chromium, so I guess we should get signals from WebKit/Gecko now. |
cc @jonco3 since you originally found this |
Yes, Mozilla support this change. |
Thanks for your work here @nicolo-ribaudo! Can you file Chromium and WebKit bugs, and edit the OP to link to them? |
Done 👍 |
… 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
… 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
… 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
… 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
… 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
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 [email protected] Bug: 1461987 Change-Id: I538a087acfb0113cdf5efa9f69947c605b2c0593 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4678043 Commit-Queue: Dominic Farolino <[email protected]> Reviewed-by: Hiroshige Hayashizaki <[email protected]> Cr-Commit-Position: refs/heads/main@{#1172405}
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.
DenoDeno only passes theAccept
,Accept-Encoding
,Host
andUser-Agent
headersNode.jsNode.js only passes theAccept
,Connection
andHost
headers/webappapis.html ( diff )