forked from web-platform-tests/wpt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement modulepreload in early hints
The aEarlyHintPreloaderId parameter for StartLoad/StartLoadInternal is changed to be a member variable of ScriptLoadRequest instead so that an initiator type of early hints can be set for module requests. Before, ModuleLoader would always pass in a zero value for the id since ModuleLoaderBase has no concept of early hints when it calls StartFetch. As a prerequisite for early hints support, this commit also implements modulepreload in link headers (Bug 1773056). Differential Revision: https://phabricator.services.mozilla.com/D180020 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1798319 gecko-commit: 5cafcb0a03c862dea23b88faae77b0e79693fcc6 gecko-reviewers: manuel, smaug, necko-reviewers, kershaw
- Loading branch information
1 parent
92189cb
commit 5bbe09d
Showing
6 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
loading/early-hints/modulepreload-as-worker-cross-origin.h2.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// META: script=/common/utils.js | ||
// META: script=resources/early-hints-helpers.sub.js | ||
|
||
// see modulepreload-in-early-hints.h2.window.js for params explanation | ||
test(() => { | ||
const params = new URLSearchParams(); | ||
params.set("description", | ||
'Modulepreload should not load with as="worker" from cross-origin url'); | ||
params.set("resource-url", | ||
CROSS_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); | ||
params.set("as", "worker"); | ||
params.set("should-preload", false); | ||
const test_url = "resources/modulepreload-in-early-hints.h2.py?" + params.toString(); | ||
window.location.replace(new URL(test_url, window.location)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// META: script=/common/utils.js | ||
// META: script=resources/early-hints-helpers.sub.js | ||
|
||
// see modulepreload-in-early-hints.h2.window.js for params explanation | ||
test(() => { | ||
const params = new URLSearchParams(); | ||
params.set("description", | ||
'Modulepreload should load with as="worker" from same-origin url'); | ||
params.set("resource-url", | ||
SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); | ||
params.set("as", "worker"); | ||
params.set("should-preload", true); | ||
const test_url = "resources/modulepreload-in-early-hints.h2.py?" + params.toString(); | ||
window.location.replace(new URL(test_url, window.location)); | ||
}); |
13 changes: 13 additions & 0 deletions
13
loading/early-hints/modulepreload-cross-origin.h2.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// META: script=/common/utils.js | ||
// META: script=resources/early-hints-helpers.sub.js | ||
|
||
// see modulepreload-in-early-hints.h2.window.js for params explanation | ||
test(() => { | ||
const params = new URLSearchParams(); | ||
params.set("description", "Modulepreload works in early hints from cross-origin url"); | ||
params.set("resource-url", | ||
CROSS_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); | ||
params.set("should-preload", true); | ||
const test_url = "resources/modulepreload-in-early-hints.h2.py?" + params.toString(); | ||
window.location.replace(new URL(test_url, window.location)); | ||
}); |
10 changes: 10 additions & 0 deletions
10
loading/early-hints/modulepreload-in-early-hints.h2.window.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
// META: script=/common/utils.js | ||
// META: script=resources/early-hints-helpers.sub.js | ||
|
||
// params are sent to a Python handler[1] that returns a 103 Early Hints | ||
// response based the values of "resource-url" and "as", and then that response | ||
// is validated by a window test[2] according to the value of "should-preload" | ||
// | ||
// see: https://web-platform-tests.org/writing-tests/h2tests.html | ||
// | ||
// [1]: resources/modulepreload-in-early-hints.h2.py | ||
// [2]: resources/modulepreload-in-early-hints.h2.html | ||
test(() => { | ||
const params = new URLSearchParams(); | ||
params.set("description", "Modulepreload works in early hints"); | ||
params.set("resource-url", | ||
SAME_ORIGIN_RESOURCES_URL + "/empty.js?" + token()); | ||
params.set("should-preload", true); | ||
const test_url = "resources/modulepreload-in-early-hints.h2.py?" + params.toString(); | ||
window.location.replace(new URL(test_url, window.location)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters