diff --git a/source b/source index 736eb813282..cbb74d3480b 100644 --- a/source +++ b/source @@ -92911,43 +92911,53 @@ document.querySelector("button").addEventListener("click", bound);
The algorithms below can be customized by optionally supplying a custom perform the fetch
- hook, which takes a request, an is top-level flag, and a processCustomFetchResponse
- algorithm. The perform the fetch algorithm
- must run processCustomFetchResponse with a
- response (which may be a network
- error), either synchronously (when using fetch a classic worker-imported
- script) or asynchronously (otherwise). The is
- top-level flag will be set for all classic script fetches, and for the initial
- fetch when fetching an external module script
- graph, fetching a module worker script
- graph, or fetching an import() module
- script graph, but not for the fetches resulting from import
- statements encountered throughout the graph.
Several of the below algorithms can be customized with a perform the fetch + hook algorithm, in one of the following forms:
-By default, not supplying the perform the - fetch will cause the below algorithms to simply fetch - the given request, with algorithm-specific customizations - to the request and validations of the resulting response.
- -To layer your own customizations on top of these algorithm-specific ones, supply a perform the fetch hook that modifies the given - request, fetches it, - and then performs specific validations of the resulting response (completing with a network error if the - validations fail).
- -The hook can also be used to perform more subtle customizations, such as keeping a cache of - responses and avoiding performing a fetch at all.
-It takes a request, a boolean isTopLevel, and a processCustomFetchResponse + algorithm. It runs processCustomFetchResponse with a + response (which may be a network + error).
It takes a request and a boolean isTopLevel, and returns a response (which may be a network error).
In both cases, isTopLevel will be true for all classic
+ script fetches, and for the initial fetch when fetching an external module script graph, fetching a module worker script graph, or fetching an import() module script graph, but false for the fetches
+ resulting from import statements encountered throughout the graph.
By default, not supplying a perform the fetch + hook will cause the below algorithms to simply fetch + the given request, with algorithm-specific customizations + to the request and validations of the resulting response.
+ +To layer your own customizations on top of these algorithm-specific ones, supply a perform the fetch hook that modifies the given + request, fetches it, + and then performs specific validations of the resulting response (completing with a network error if the + validations fail).
+ +The hook can also be used to perform more subtle customizations, such as keeping a cache of + responses and avoiding performing a fetch at all.
Service Workers is an example of a specification that runs these algorithms with its own options for the hook.
@@ -92975,75 +92985,69 @@ document.querySelector("button").addEventListener("click", bound);If the caller specified custom steps to perform - the fetch, perform them on request, with the is top-level flag set. Return from this algorithm, - and run the remaining steps as part of the perform - the fetch's processCustomFetchResponse given response response.
- -Otherwise, fetch request. Return from this - algorithm, and run the remaining steps as part of the fetch's processResponseConsumeBody given response response.
+Fetch request with + the following processResponseConsumeBody steps given + response response:
response can be either CORS-same-origin or CORS-cross-origin. This only affects how error reporting happens.
-Finalize and report timing with response, settings
- object's global object, and "script".
Finalize and report timing with response, settings
+ object's global object, and "script".
Set response to response's unsafe response.
Set response to response's unsafe response.
If response's type is "error", or response's status is not an ok status, then
- run onComplete given null, and return.
If response's type is "error", or response's status is not an ok status, then
+ run onComplete given null, and abort these steps.
For historical reasons, this algorithm does not include MIME type checking, - unlike the other script-fetching algorithms in this section.
-For historical reasons, this algorithm does not include MIME type checking, + unlike the other script-fetching algorithms in this section.
+ -Let potentialMIMETypeForEncoding be the result of extracting a MIME type given response's header list.
Let potentialMIMETypeForEncoding be the result of extracting a MIME type given response's header list.
Set character encoding to the result of legacy extracting an encoding given potentialMIMETypeForEncoding and - character encoding.
+Set character encoding to the result of legacy extracting an encoding given potentialMIMETypeForEncoding + and character encoding.
-This intentionally ignores the MIME type essence.
-This intentionally ignores the MIME type essence.
+ -Let source text be the result of decoding - response's body to Unicode, using - character encoding as the fallback encoding.
+Let source text be the result of decoding + response's body to Unicode, using + character encoding as the fallback encoding.
-The decode algorithm overrides character encoding if - the file contains a BOM.
-The decode algorithm overrides character encoding if + the file contains a BOM.
+ -Let muted errors be true if response was - CORS-cross-origin, and false otherwise.
Let muted errors be true if response was + CORS-cross-origin, and false otherwise.
Let script be the result of creating a classic script given - source text, settings object, response's url, options, and muted - errors.
Let script be the result of creating a classic script given + source text, settings object, response's URL, options, and muted + errors.
To fetch a classic worker script given a url, a fetch client - settings object, a destination, a script settings object, and an - onComplete algorithm, run these steps. onComplete must be an algorithm - accepting null (on failure) or a classic script (on success).
+ settings object, a destination, a script settings object, an + onComplete algorithm, and an optional asynchronous perform the fetch hook + performFetch, run these steps. onComplete must be an algorithm accepting + null (on failure) or a classic script (on success).Let request be a new request whose
If the caller specified custom steps to perform
- the fetch, perform them on request, with the is top-level flag set. Return from this algorithm,
- and run the remaining steps as part of the perform
- the fetch's processCustomFetchResponse given response response. If performFetch was given, run performFetch with request,
+ true, and with processResponse as defined below. Otherwise, fetch request. Return from this
- algorithm, and run the remaining steps as part of the fetch's processResponseConsumeBody given response response.
- Otherwise, fetch request with processResponseConsumeBody set to
+ processResponse as defined below. Finalize and report timing with response, fetch client
- settings object's global object, and
- " In both cases, let processResponse given response response be the following algorithm: Set response to response's unsafe response. Finalize and report timing with response, fetch client
+ settings object's global object, and
+ " If either of the following conditions are met: Set response to response's unsafe response. response's type is " If either of the following conditions are met: response's status is not an
- ok status, response's type is " then run onComplete given null, and return.other".
+
other".
-
+ error"; or
+
error"; or
If both of the following conditions are met:
+response's status is not an + ok status,
response's url's scheme is an HTTP(S) scheme; and
then run onComplete given null, and abort these steps.
+ -the result of extracting a MIME type from - response's header list is not a - JavaScript MIME type,
-If both of the following conditions are met:
-then run onComplete given null, and return.
+response's URL's scheme is an HTTP(S) scheme; and
Other fetch schemes are exempted from MIME - type checking for historical web-compatibility reasons. We might be able to tighten this in the - future; see issue #3255.
-the result of extracting a MIME type from + response's header list is not + a JavaScript MIME type,
+ -Let source text be the result of UTF-8 - decoding response's body.
then run onComplete given null, and abort these steps.
-Let script be the result of creating a classic script using - source text, script settings object, response's url, and the default classic script fetch - options.
Other fetch schemes are exempted from MIME + type checking for historical web-compatibility reasons. We might be able to tighten this in + the future; see issue #3255.
+ + +Let source text be the result of UTF-8 + decoding response's body.
Run onComplete given script.
Let script be the result of creating a classic script using + source text, script settings object, response's URL, and the default classic script fetch + options.
Run onComplete given script.
To fetch a classic worker-imported script given a url and a - settings object, run these steps. The algorithm will synchronously complete with a +
To fetch a classic worker-imported script given a url, a + settings object, and an optional synchronous perform the fetch hook + performFetch, run these steps. The algorithm will synchronously complete with a classic script on success, or throw an exception on failure.
Let response be null.
If the caller specified custom steps to perform - the fetch, perform them on request, with the is top-level flag set, and with the following processCustomFetchResponse steps given - response customFetchResponse:
+If performFetch was given, let response be the result of running + performFetch given request and true.
-Set response to customFetchResponse.
Otherwise, fetch request, and set - response to the result.
+Otherwise, let response be the result of fetching request.
Unlike other algorithms in this section, the fetching process is synchronous - here. Thus any perform the fetch steps will - also run processCustomFetchResponse - synchronously, and response will have been set when this step completes.
+ here.Finalize and report timing with response, settings
@@ -93188,7 +93183,7 @@ document.querySelector("button").addEventListener("click", bound);
Let script be the result of creating a classic script given
source text, settings object, response's url, the default classic script fetch options,
+ data-x="concept-response-url">URL, the default classic script fetch options,
and muted errors. Return script. Fetch a single module script given url, settings
- object, " Fetch a single module script given url, settings object,
+ " If result is null, run onComplete given null, and return. If result is null, run onComplete given null, and abort these
+ steps. Let visited set be « (url, "
script", options, settings object,
- "client", with the top-level module fetch flag set, and with
- the following steps given result:script", options, settings object, "client", true, and with the following steps given result:
-
javascript")
».script", visited set, and onComplete.
If the caller of this algorithm specified custom perform the fetch steps, pass those along as - well.
+To fetch an import() module script graph given a moduleRequest, a @@ -93249,11 +93241,12 @@ document.querySelector("button").addEventListener("click", bound);
Fetch a single module script given url, settings
object, "script", options, settings object,
- "client", moduleRequest, with the top-level module fetch
- flag set, and with the following steps given result:
client", moduleRequest, true, and with the following steps
+ given result:
If result is null, run onComplete with null, and return.
If result is null, run onComplete with null, and abort these + steps.
Let visited set be « (url, moduleType) ».
If the caller of this algorithm specified custom perform the fetch steps, pass those along as - well.
@@ -93277,7 +93266,7 @@ document.querySelector("button").addEventListener("click", bound);Fetch a single module script given url, settings
object, destination, options, settings object, "client", with the top-level module fetch flag set, and with the
+ data-x="">client", true, and with the
following steps given result:
Let requestURL be request's To fetch a worklet/module worker script graph given a url, a fetch client settings object, a destination, a credentials mode, a - module map settings object, and an onComplete algorithm, run these steps. + module map settings object, an onComplete algorithm, and an optional + asynchronous perform the fetch hook performFetch, run these steps. onComplete must be an algorithm accepting null (on failure) or a module script (on success).
@@ -93508,11 +93498,14 @@ document.querySelector("button").addEventListener("click", bound);Fetch a single module script given url, fetch client settings
object, destination, options, module map settings object,
- "client", with the top-level module fetch flag set, and with
- the following steps given result:
client", true, and onSingleFetchComplete as defined below. If
+ performFetch was given, pass it along as well.
+
+ onSingleFetchComplete given result is the following algorithm:
If result is null, run onComplete given null, and return.
If result is null, run onComplete given null, and abort these + steps.
Let visited set be « (url, "javascript")
».
Fetch the descendants of and link result given fetch client settings object, destination, visited set, and - onComplete.
If the caller of this algorithm specified custom perform the fetch steps, pass those along as - well.
To fetch the descendants of and link a module script module script, given a fetch client settings object, a destination, a - visited set, and an onComplete algorithm, run these steps. + visited set, an onComplete algorithm, and an optional asynchronous + perform the fetch hook performFetch, run these steps. onComplete must be an algorithm accepting null (on failure) or a module script (on success).
@@ -93539,12 +93529,15 @@ document.querySelector("button").addEventListener("click", bound);Fetch the descendants of module script, given fetch client settings object, destination, - visited set, and with the following steps given result:
+ visited set, and onFetchDescendantsComplete as defined below. If + performFetch was given, pass it along as well. + +onFetchDescendantsComplete given result is the following algorithm:
If result is null, then run onComplete given result, and - return.
+ abort these steps.In this case, there was an error fetching one or more of the descendants. We will not attempt to link.
@@ -93581,9 +93574,10 @@ document.querySelector("button").addEventListener("click", bound);To fetch the descendants of a module script module script, given a - fetch client settings object, a destination, a visited set, and - an onComplete algorithm, run these steps. onComplete must be an algorithm - accepting null (on failure) or a module script (on success).
+ fetch client settings object, a destination, a visited set, an + onComplete algorithm, and an optional asynchronous perform the fetch hook + performFetch, run these steps. onComplete must be an algorithm accepting + null (on failure) or a module script (on success).If module script's record is null, @@ -93650,8 +93644,10 @@ document.querySelector("button").addEventListener("click", bound); procedure given moduleRequest, fetch client settings object, destination, options, module script's settings object, visited set, module script's base URL, and the following steps given - result:
+ data-x="concept-script-base-url">base URL, and onInternalFetchingComplete as + defined below. If performFetch was given, pass it along as well. + +onInternalFetchingComplete given result is the following algorithm:
If failed is true, then abort these steps.
If the caller of this algorithm specified custom perform the fetch steps, pass those along while - performing the internal module script graph fetching procedure.
-The fetches performed by the internal module script graph fetching procedure are performed in parallel to each other.
To perform the internal module script graph fetching procedure given a moduleRequest, a fetch client settings object, a destination, some options, a module map settings object, a visited set, a - referrer, and an onComplete algorithm, run these steps. + referrer, an onComplete algorithm, and an optional asynchronous + perform the fetch hook performFetch, run these steps. onComplete must be an algorithm accepting null (on failure) or a module script (on success).
@@ -93702,29 +93695,32 @@ document.querySelector("button").addEventListener("click", bound);Fetch a single module script given url, fetch client settings object, destination, options, module map settings object, - referrer, moduleRequest, with the top-level module fetch flag - unset, and with the following steps given result:
+ referrer, moduleRequest, false, and onSingleFetchComplete as + defined below. If performFetch was given, pass it along as well. + +onSingleFetchComplete given result is the following algorithm:
If result is null, run onComplete with null, and return.
If result is null, run onComplete with null, and abort these + steps.
Fetch the descendants of result given fetch client settings object, destination, - visited set, and with onComplete.
If the caller of this algorithm specified custom perform the fetch steps, pass those along as - well.
+To fetch a single module script, given a url, a fetch client settings object, a destination, some options, a module map - settings object, a referrer, an optional moduleRequest, a - top-level module fetch flag, and an onComplete algorithm, run these steps. - onComplete must be an algorithm accepting null (on failure) or a module - script (on success).
+ settings object, a referrer, an optional moduleRequest, a boolean + isTopLevel, an onComplete + algorithm, and an optional asynchronous perform the fetch hook + performFetch, run these steps. onComplete must be an algorithm accepting + null (on failure) or a module script (on success).Let moduleType be "javascript".
If the caller specified custom steps to perform - the fetch, perform them on request, setting the is top-level flag if the top-level module - fetch flag is set. Return from this algorithm, and run the remaining steps as part of the - perform the fetch's processCustomFetchResponse given response response.
+If performFetch was given, run performFetch with request, + isTopLevel, and with processResponse as defined below.
-Otherwise, fetch request. Return from this - algorithm, and run the remaining steps as part of the fetch's processResponseConsumeBody given response response.
+Otherwise, fetch request with + processResponse as processResponseConsumeBody.
-response is always CORS-same-origin.
-In both cases, let processResponse given response response be the following algorithm:
-Finalize and report timing with response, fetch client
- settings object's global object, and
- "other".
response is always CORS-same-origin.
-If either of the following conditions are met:
+Finalize and report timing with response, fetch client
+ settings object's global object, and
+ "other".
response's type is "error"; or
If either of the following conditions are met:
-response's status is not an - ok status.
response's type is "error"; or
then set moduleMap[(url, - moduleType)] to null, run onComplete given null, and return.
-response's status is not an + ok status.
Let source text be the result of UTF-8 - decoding response's body.
then set moduleMap[(url, + moduleType)] to null, run onComplete given null, and abort these + steps.
+ -Let MIME type be the result of extracting a - MIME type from response's header - list.
Let source text be the result of UTF-8 + decoding response's body.
Let module script be null.
Let MIME type be the result of extracting + a MIME type from response's header list.
If MIME type is a JavaScript MIME type and moduleType
- is "javascript", then set module script to the result of
- creating a JavaScript module script given source text, module map
- settings object, response's url, and
- options.
Let module script be null.
If the MIME type essence of MIME type is "text/css"
- and moduleType is "css", then set module script to
- the result of creating a CSS module script given source text and
- module map settings object.
If MIME type is a JavaScript MIME type and moduleType
+ is "javascript", then set module script to the result of
+ creating a JavaScript module script given source text, module map
+ settings object, response's URL,
+ and options.
If MIME type essence is a JSON MIME type and moduleType
- is "json", then set module script to the result of
- creating a JSON module script given source text and module map
- settings object.
If the MIME type essence of MIME type is "text/css"
+ and moduleType is "css", then set module script to
+ the result of creating a CSS module script given source text and
+ module map settings object.
Set moduleMap[(url, - moduleType)] to module script, and run onComplete given - module script.
+If MIME type essence is a JSON MIME type and
+ moduleType is "json", then set module script to
+ the result of creating a JSON module script given source text and
+ module map settings object.
It is intentional that the module map is keyed by the request URL, whereas the base URL for the module script is - set to the response URL. The former is used to - deduplicate fetches, while the latter is used for URL resolution.
+Set moduleMap[(url, + moduleType)] to module script, and run onComplete given + module script.
+ +It is intentional that the module map is keyed by the request URL, whereas the base URL for the module script is + set to the response URL. The former is used to + deduplicate fetches, while the latter is used for URL resolution.
+classic"module"credentials
- member of options, inside settings, and with onComplete as
- defined below.In both cases, to perform the fetch - given request, is top-level and In both cases, let performFetch be the following asynchronous perform the + fetch hook given request, is + top-level and processCustomFetchResponse:
If is top-level is not set, fetch +
If isTopLevel is false, fetch request with processCustomFetchResponse as processResponseConsumeBody and return.
To import scripts into worker global scope, given a
- WorkerGlobalScope object worker global scope and a sequence<DOMString> urls, run these steps. The algorithm may
- optionally be customized by supplying custom perform
- the fetch hooks, which if provided will be used when invoking fetch a classic
- worker-imported script.
WorkerGlobalScope object worker global scope, a list of
+ scalar value strings urls, and an optional
+ synchronous perform the fetch hook performFetch:
If worker global scope's SharedWorker : EventTarget {
For each url in the resulting URL
- records, run these substeps:
Fetch a classic worker-imported script given url and - settings object, passing along any custom perform the fetch steps provided. If this + settings object, passing along performFetch if provided. If this succeeds, let script be the result. Otherwise, rethrow the exception.
Service Workers is an example of a specification that runs this - algorithm with its own options for the perform the - fetch hook.
+ algorithm with its own synchronous perform the fetch hook.