fune/testing/web-platform/tests/loading/early-hints/modulepreload-in-early-hints.h2.window.js
Em Zhan b6b6fe577b Bug 1798319 - Implement modulepreload in early hints r=manuel,smaug,necko-reviewers,kershaw
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
2023-06-26 10:49:53 +00:00

20 lines
914 B
JavaScript

// 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));
});