From 531ff434bba0cc08a84a0a8e17386929277955f5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=
Fetch a single module script given url, settings
- object, "script
", options, settings object,
- "client
", and with the top-level module fetch flag set. If the
- caller of this algorithm specified custom perform
- the fetch steps, pass those along as well. Wait until the algorithm asynchronously
- completes with result.
Fetch a single module script given url, settings
+ object, "script
", options, settings object,
+ "client
", with the top-level module fetch flag set, and with
+ onComplete given result being these steps:
If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, asynchronously complete this algorithm with null, and + return.
Let visited set be « (url, "javascript
")
- ».
Let visited set be « (url, "javascript
")
+ ».
Fetch the descendants of
- and link result given settings object, "script
", and visited set. When this asynchronously completes with
- final result, asynchronously complete this algorithm with final
- result.
Fetch the descendants of
+ and link result given settings object, "script
", and visited set. When this asynchronously completes with
+ final result, asynchronously complete this algorithm with final
+ result.
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 @@ -93134,23 +93139,28 @@ document.querySelector("button").addEventListener("click", bound); moduleType and settings object is false, then asynchronously complete this algorithm with null, and return.
-Fetch a single module script given url, settings
- object, "script
", options, settings object,
- "client
", moduleRequest, and with the
- top-level module fetch flag set. If the caller of this algorithm specified custom
- perform the fetch steps, pass those along as
- well. Wait until the algorithm asynchronously completes with result.
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 onComplete given result being these steps:
If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, asynchronously complete this algorithm with null, and + return.
Let visited set be « (url, moduleType) ».
Let visited set be « (url, moduleType) ».
Fetch the - descendants of and link result given settings object, - destination, and visited set. When this asynchronously completes with - final result, asynchronously complete this algorithm with final - result.
Fetch the descendants + of and link result given settings object, destination, + and visited set. When this asynchronously completes with final result, + asynchronously complete this algorithm with final result.
If the caller of this algorithm specified custom perform the fetch steps, pass those along as + well.
+To fetch a modulepreload module script graph given a url, a @@ -93159,31 +93169,35 @@ document.querySelector("button").addEventListener("click", bound); script (on success), although it will perform optional steps even after completing.
Fetch a single module script given url, settings
- object, destination, options, settings object, "client
", and with the top-level module fetch flag set. Wait until
- algorithm asynchronously completes with result.
Asynchronously complete this algorithm with result, but do not - return.
If result is not null, optionally perform the following steps:
+Fetch a single module script given url, settings
+ object, destination, options, settings object, "client
", with the top-level module fetch flag set, and with
+ onComplete given result being these steps:
Let visited set be « (url, "javascript
")
- ».
Asynchronously complete this algorithm with result, but do not + return.
Fetch the - descendants of and link result given settings object, - destination, and visited set.
If result is not null, optionally perform the following steps:
-Generally, performing these steps will be beneficial for performance, as it - allows pre-loading the modules that will invariably be requested later, via algorithms such as - fetch an external module script graph that fetch the entire graph. However, user - agents might wish to skip them in bandwidth-constrained situations, or situations where the - relevant fetches are already in flight.
+Let visited set be « (url, "javascript
")
+ ».
Fetch the + descendants of and link result given settings object, + destination, and visited set.
Generally, performing these steps will be beneficial for performance, as it + allows pre-loading the modules that will invariably be requested later, via algorithms such as + fetch an external module script graph that fetch the entire graph. However, user + agents might wish to skip them in bandwidth-constrained situations, or situations where the + relevant fetches are already in flight.
+Fetch a single module script given url, fetch client settings
- object, destination, options, module map settings object,
- "client
", and with the top-level module fetch flag set. If the
- caller of this algorithm specified custom perform
- the fetch steps, pass those along as well. Wait until the algorithm asynchronously
- completes with result.
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
+ onComplete given result being these steps:
If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, asynchronously complete this algorithm with null, and + return.
Let visited set be « (url, "javascript
")
- ».
Let visited set be « (url, "javascript
")
+ ».
Fetch the - descendants of and link result given fetch client settings - object, destination, and visited set. When this asynchronously - completes with final result, asynchronously complete this algorithm with final - result.
Fetch the + descendants of and link result given fetch client settings + object, destination, and visited set. When this asynchronously + completes with final result, asynchronously complete this algorithm with final + result.
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
@@ -93563,33 +93583,36 @@ document.querySelector("button").addEventListener("click", bound);
Assert: visited set contains
(url, moduleType). Fetch a single module script given url, fetch client settings
- object, destination, options, module map settings object,
- referrer, moduleRequest, and with the
- top-level module fetch flag unset. If the caller of this algorithm specified custom
- perform the fetch steps, pass those along
- while fetching a single module script. 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 onComplete given result being these steps: Return from this algorithm, and run the following steps when fetching a single module script asynchronously completes with
- result: If result is null, asynchronously complete this algorithm with null, and
+ return. If result is null, asynchronously complete this algorithm with null, and
- return. Fetch the descendants of
+ result given fetch client settings object, destination, and
+ visited set. Fetch the descendants of
- result given fetch client settings object, destination, and
- visited set. When the appropriate algorithm asynchronously completes with final result,
+ asynchronously complete this algorithm with final result. When the appropriate algorithm asynchronously completes with final result,
- asynchronously complete this algorithm with final result. 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, and a
- top-level module fetch flag, run these steps. The algorithm will asynchronously
- complete with either null (on failure) or a module script (on success).
+
-
Let moduleType be "javascript
".
If moduleMap[(url, moduleType)] exists, asynchronously complete this algorithm with - moduleMap[url / moduleType], and return.
Set moduleMap[(url,
moduleType)] to "fetching
".
then set moduleMap[(url, - moduleType)] to null, asynchronously complete this algorithm with null, and - return.
+ moduleType)] to null, run onComplete given null, and return.Let source text be the result of UTF-8
@@ -93705,8 +93727,8 @@ document.querySelector("button").addEventListener("click", bound);
Set moduleMap[(url,
- moduleType)] to module script, and asynchronously complete this algorithm
- with module script.
It is intentional that the module map is keyed by the request URL, whereas the
Date: Mon, 5 Sep 2022 19:07:57 +0200
Subject: [PATCH 02/17] fetch the descendants of and link a module script
---
source | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/source b/source
index 7b57b67bdb9..e451fe06474 100644
--- a/source
+++ b/source
@@ -93105,9 +93105,8 @@ document.querySelector("button").addEventListener("click", bound);
Fetch the descendants of
and link result given settings object, "script
", and visited set. When this asynchronously completes with
- final result, asynchronously complete this algorithm with final
- result.
If the caller of this algorithm specified custom Fetch the descendants
of and link result given settings object, destination,
- and visited set. When this asynchronously completes with final result,
- asynchronously complete this algorithm with final result.
If the caller of this algorithm specified custom Fetch the
descendants of and link result given settings object,
- destination, and visited set.
Generally, performing these steps will be beneficial for performance, as it @@ -93218,9 +93218,8 @@ document.querySelector("button").addEventListener("click", bound);
Fetch the
descendants of and link script, given settings object, the
- destination "script
", and visited set. When this asynchronously
- completes with final result, asynchronously complete this algorithm with final
- result.
script
", visited set, and onComplete
+ This should be forwarded from the arguments.
To fetch a module worker script graph @@ -93420,9 +93419,8 @@ document.querySelector("button").addEventListener("click", bound);
Fetch the descendants of and link result given fetch client settings - object, destination, and visited set. When this asynchronously - completes with final result, asynchronously complete this algorithm with final - result.
If the caller of this algorithm specified custom
To fetch the descendants of and link a module script module
- script, given a fetch client settings object, a destination, and a
- visited set, run these steps. The algorithm will asynchronously complete with either
- null (on failure) or with module script (on success).
Fetch the descendants of @@ -93446,8 +93445,8 @@ document.querySelector("button").addEventListener("click", bound); completes with result.
If result is null, then asynchronously complete this algorithm with - result.
+If result is null, then run onComplete given result, and + return.
In this case, there was an error fetching one or more of the descendants. We will not attempt to link.
@@ -93477,7 +93476,7 @@ document.querySelector("button").addEventListener("click", bound);Otherwise, set result's error to rethrow to parse error.
Asynchronously complete this algorithm with result.
Run onComplete given result.
To fetch the descendants of a module script module script, given a
From 8e5c313f59ea2dfcd97b9c6992f4ac820c3df8ee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= To fetch an import() module script graph given a moduleRequest, a
- base URL, a settings object, and some options, run these steps.
- The algorithm will asynchronously complete with either null (on failure) or a module
- script (on success).
Let url be the result of resolving a module specifier given base URL and moduleRequest.[[Specifier]].
If url is failure, then asynchronously complete this algorithm with null, and +
If url is failure, then run onComplete given null, and return.
Assert: moduleRequest.[[Assertions]] does not contain any Record @@ -93135,8 +93135,8 @@ document.querySelector("button").addEventListener("click", bound); request steps given moduleRequest.
If the result of running the module type allowed steps given - moduleType and settings object is false, then asynchronously complete this - algorithm with null, and return.
Fetch a single module script given url, settings @@ -93145,15 +93145,13 @@ document.querySelector("button").addEventListener("click", bound); flag set, and with onComplete given result being these steps:
If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, run onComplete with null, and return.
Let visited set be « (url, moduleType) ».
Fetch the descendants of and link result given settings object, destination, - visited set, and onComplete This should be - forwarded from the arguments.
If the caller of this algorithm specified custom case, referencingScriptOrModule is non-null.
-Fetch an import() module script graph given moduleRequest, - base URL, settings object, and fetch options. Wait until the - algorithm asynchronously completes with result.
Let promise be null. +
Fetch an import() module script graph given moduleRequest, + base URL, settings object, fetch options, and with + onComplete given result being these steps:
-If result is null, then set promise to a promise rejected
- with a new TypeError
.
Let promise be null. -
Otherwise, set promise to the result of running a module script given result and true.
If result is null, then set promise to a promise rejected
+ with a new TypeError
.
Perform FinishDynamicImport(referencingScriptOrModule, - moduleRequest, promiseCapability, promise).
Otherwise, set promise to the result of running a module script given result and true.
Return undefined.
Perform FinishDynamicImport(referencingScriptOrModule, + moduleRequest, promiseCapability, promise).
Let onComplete given result be the following steps:
+ +Mark as ready el given result.
Switch on el's type:
@@ -60362,19 +60370,18 @@ o............A....eclassic
"Fetch a classic script given url, settings object, - options, classic script CORS setting, and encoding.
+ options, classic script CORS setting, and encoding. When it + asynchronously completes with result, run onComplete given + result.module
"Fetch an external module script graph given url, settings - object, and options.
+ object, options, and onComplete.When the chosen algorithm asynchronously completes with result, mark as - ready el given result.
-For performance reasons, user agents may start fetching the classic script or module graph
(as defined above) as soon as the src
attribute is set,
instead, in the hope that el will be inserted into the document (and that the
@@ -93085,9 +93092,9 @@ document.querySelector("button").addEventListener("click", bound);
To fetch an external module script graph - given a url, a settings object, and some options, run these - steps. The algorithm will asynchronously complete with either null (on failure) or a module - script (on success).
+ given a url, a settings object, some options, and an + onComplete algorithm, run these steps. onComplete must be an algorithm + accepting null (on failure) or a module script (on success).If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, run onComplete given null, and return.
Let visited set be « (url, "javascript
")
».
Fetch the descendants of
and link result given settings object, "script
", visited set, and onComplete This should be forwarded from the arguments.
If the caller of this algorithm specified custom
Date: Mon, 5 Sep 2022 19:32:18 +0200
Subject: [PATCH 05/17] fetch a classic script
---
source | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/source b/source
index 804287d8507..27fcd6bfd23 100644
--- a/source
+++ b/source
@@ -60370,9 +60370,8 @@ o............A....e
Fetch a classic script given url, settings object,
- options, classic script CORS setting, and encoding. When it
- asynchronously completes with result, run onComplete given
- result.classic
"
module
"Now for the algorithms themselves.
To fetch a classic script given a url, a settings - object, some options, a CORS setting, and a character - encoding, run these steps. The algorithm will asynchronously complete with either null (on - failure) or a new classic script (on success).
+ object, some options, a CORS setting, a character + encoding, and an onComplete algorithm, run these steps. onComplete + must be an algorithm accepting null (on failure) or a classic script (on + success).Let request be the result of If response's type is "error
", or response's status is not an ok status, then
- asynchronously complete this algorithm with null, and return.
For historical reasons, this algorithm does not include MIME type checking, unlike the other script-fetching algorithms in this section.
@@ -92943,7 +92943,7 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-response-url">url, options, and muted errors.To fetch a classic worker script given a url, a fetch client
From c738957243c35e054f1e53b5a1af2a4cc8829cd4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Set el's delaying the load
event to true. Fetch an inline module script graph, given source text,
- base URL, settings object, and options. When this
- asynchronously completes with result, mark as ready el
- given result. Fetch an inline module script graph, given source text,
+ base URL, settings object, options, and with
+ onComplete given result being these steps: Mark as ready el given result. To fetch an inline module script graph given a source text, base
- URL, settings object, and options, run these steps. The algorithm will
- asynchronously complete with either null (on failure) or a module script (on
- success).
+
+
Let script be the result of creating a JavaScript module script using source text, settings object, base URL, and options.
If script is null, asynchronously complete this algorithm with null, and - return.
If script is null, run onComplete given null, and return.
Let visited set be an empty set.
Fetch the
descendants of and link script, given settings object, the
- destination "script
", visited set, and onComplete
- This should be forwarded from the arguments.
script
", visited set, and
+ onComplete.To fetch a module worker script graph
From 5175eef55f6d5da2e3382a604dfff7314393370b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= To fetch a module worker script graph
given a url, a fetch client settings object, a destination, a
- credentials mode, and a module map settings object, fetch a
- worklet/module worker script graph given url, fetch client settings
- object, destination, credentials mode, and module map settings
- object, asynchronously completing with the asynchronous completion result of that
- algorithm.
To fetch a worklet script graph given a url, a fetch client settings object, a destination, a credentials mode, a module map settings - object, and a module responses map, fetch a worklet/module worker script - graph given url, fetch client settings object, - destination, credentials mode, and module map settings object, - asynchronously completing with the asynchronous completion result of that algorithm. Use the - following custom steps to perform the fetch - given response:
+ object, a module responses map, and an onComplete algorithm, + fetch a worklet/module worker script graph given url, fetch client + settings object, destination, credentials mode, module map + settings object, and onComplete. Use the following custom steps to perform the fetch given response: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, and a
- module map settings object, run these steps. The algorithm will asynchronously complete
- with either null (on failure) or a module script (on success).
Let options be a script fetch options whose onComplete given result being these steps:
If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, run onComplete given null, and return.
Let visited set be « (url, "javascript
")
».
Fetch the descendants of and link result given fetch client settings - object, destination, visited set, and onComplete This should be forwarded from the arguments.
If the caller of this algorithm specified custom
Date: Tue, 6 Sep 2022 11:04:35 +0200
Subject: [PATCH 08/17] Don't name the onComplete argument in call sites
---
source | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/source b/source
index 7c491073f2c..a99fffce6a8 100644
--- a/source
+++ b/source
@@ -60428,8 +60428,8 @@ o............A....e
Fetch an inline module script graph, given source text,
- base URL, settings object, options, and with
- onComplete given result being these steps:
Mark as ready el given result.
Fetch a single module script given url, settings
object, "script
", options, settings object,
"client
", with the top-level module fetch flag set, and with
- onComplete given result being these steps:
If result is null, run onComplete given null, and return.
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 onComplete given result being these steps:
If result is null, run onComplete with null, and return.
Fetch a single module script given url, settings
object, destination, options, settings object, "client
", with the top-level module fetch flag set, and with
- onComplete given result being these steps:
Asynchronously complete this algorithm with result, but do not @@ -93195,8 +93195,7 @@ document.querySelector("button").addEventListener("click", bound);
Fetch the descendants of and link result given settings object, - destination, visited set, and with onComplete being an empty - algorithm.
Generally, performing these steps will be beneficial for performance, as it @@ -93414,7 +93413,7 @@ 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
- onComplete given result being these steps:
If result is null, run onComplete given null, and return.
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 onComplete given result being these steps:
+ unset, and with the following steps given result:If result is null, asynchronously complete this algorithm with null, and @@ -95204,8 +95203,8 @@ import "https://example.com/foo/../module2.mjs";
Fetch an import() module script graph given moduleRequest, - base URL, settings object, fetch options, and with - onComplete given result being these steps:
+ base URL, settings object, fetch options, and with the + following steps given result:Let promise be null.
From 52f2e0a7fbdaa86254c32befd050b2afbd935264 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=
Fetch a modulepreload module script graph given url, - destination, settings object, and options. Wait until the - algorithm asynchronously completes with result.
+Fetch a modulepreload module script graph given url, + destination, settings object, options, and with the following + steps given result:
-If result is null, then fire an event
- named error
at the link
element, and
- return.
If result is null, then fire an
+ event named error
at the link
element,
+ and return.
Fire an event named load
at the link
element.
Fire an event named load
at the link
element.
The process a link header steps for this type of linked resource are to do @@ -93171,9 +93175,9 @@ document.querySelector("button").addEventListener("click", bound);
To fetch a modulepreload module script graph given a url, a - destination, a settings object, and some options, run these - steps. The algorithm will asynchronously complete with either null (on failure) or a module - script (on success), although it will perform optional steps even after completing.
+ destination, a settings object, some options, and an + onComplete algorithm, run these steps. onComplete must be an algorithm + accepting null (on failure) or a module script (on success).Asynchronously complete this algorithm with result, but do not - return.
Run onComplete given result.
If result is not null, optionally perform the following steps:
From 4a08147b6512d749d5f262dc70e9346f205003ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=Let pendingAddedModules be a clone of + worklet's added modules + list.
For each moduleURL of worklet's - added modules list:
+Let runNextAddedModule be the following steps:
Fetch a worklet script graph given moduleURL, - insideSettings, worklet's worklet destination type, what credentials mode?, insideSettings, and worklet's - module responses map. Wait until - the algorithm asynchronously completes with script.
- -This will not actually perform a network request, as it will just reuse responses from worklet's module responses map. The main - purpose of this step is to create a new workletGlobalScope-specific module - script from the response.
+If pendingAddedModules is not empty, then:
+ +Let moduleURL be the result of dequeueing + from pendingAddedModules.
Fetch a worklet script graph given moduleURL, + insideSettings, worklet's worklet destination type, what credentials mode?, insideSettings, worklet's + module responses map, and with + the following steps given script:
+ +This will not actually perform a network request, as it will just reuse + responses from worklet's module responses map. The main + purpose of this step is to create a new workletGlobalScope-specific module + script from the response.
+ +Assert: script is not null, since the fetch succeeded and the source text + was successfully parsed when worklet's module responses map was initially + populated with moduleURL.
Run a module script given script.
Run runNextAddedModule.
Assert: script is not null, since the fetch succeeded and the source text was - successfully parsed when worklet's module responses map was initially - populated with moduleURL.
Append workletGlobalScope to
+ outsideSettings's global
+ object's associated
+ Document
's worklet
+ global scopes.
Append workletGlobalScope to + worklet's global + scopes.
Run a module script given script.
Run the responsible event loop specified by + insideSettings.
Append workletGlobalScope to
- outsideSettings's global object's
- associated Document
's worklet global scopes.
Append workletGlobalScope to - worklet's global scopes.
Run the responsible event loop specified by - insideSettings.
Run runNextAddedModule.
To terminate a worklet global scope given a WorkletGlobalScope
@@ -105387,24 +105409,20 @@ dictionary WorkletOptions {
For each workletGlobalScope of this's global scopes, queue a global task on the networking task source given - workletGlobalScope to perform the following steps:
+ workletGlobalScope to fetch a worklet script graph given + moduleURLRecord, outsideSettings, this's worklet + destination type, options["credentials
"], workletGlobalScope's
+ relevant settings object, this's module responses map, and the following
+ steps given script:
+
+ Only the first of these fetches will actually perform a network request; the
+ ones for other WorkletGlobalScope
s will reuse responses from this's module responses map.
Fetch a worklet script graph given moduleURLRecord,
- outsideSettings, this's worklet destination type,
- options["credentials
"],
- workletGlobalScope's relevant settings object, and
- this's module responses
- map. Wait until the algorithm asynchronously completes with
- script.
Only the first of these fetches will actually perform a network request; the
- ones for other WorkletGlobalScope
s will reuse responses from this's module responses map.
If script is null, then:
From f9593d3456cc810d81ac51144897568a15306ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=To fetch a classic worker script given a url, a fetch client - settings object, a destination, and a script settings object, run - these steps. The algorithm will asynchronously complete with either null (on failure) or a new - classic script (on success).
+ 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).Let request be a new request whose ok status,
then asynchronously complete this algorithm with null, and return.
+then run onComplete given null, and return.
If both of the following conditions are met:
@@ -93017,7 +93017,7 @@ document.querySelector("button").addEventListener("click", bound); JavaScript MIME type, -then asynchronously complete this algorithm with null, and return.
+then run onComplete given null, and return.
Other fetch schemes are exempted from MIME type checking for historical web-compatibility reasons. We might be able to tighten this in the @@ -93032,7 +93032,7 @@ document.querySelector("button").addEventListener("click", bound); data-x="concept-response-url">url, and the default classic script fetch options.
Run onComplete given script.
To fetch a classic worker-imported script given a url and a
@@ -103681,12 +103681,14 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
In both cases, to perform the fetch
@@ -103764,115 +103766,116 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
fetch steps with response.
classic
"module
"credentials
- member of options, and inside settings.
If the algorithm asynchronously completes with null or with a script whose error to rethrow is non-null, then:
+In both cases, let onComplete given script be the following steps:
Queue a global task on the DOM manipulation task source given
- worker's relevant global object to fire an event named error
- at worker.
Run the environment discarding steps - for inside settings.
If script is null or if script's error to rethrow is non-null, then:
-Return.
Queue a global task on the DOM manipulation task source given
+ worker's relevant global object to fire an event named error
+ at worker.
Otherwise, continue the rest of these steps after the algorithm's asynchronous completion, - with script being the asynchronous completion value.
- +Run the environment discarding steps + for inside settings.
Associate worker with worker global scope.
Return.
Let inside port be a new MessagePort
object in
- inside settings's Realm.
Associate worker with worker global scope.
Associate inside port with worker global scope.
Let inside port be a new MessagePort
object in
+ inside settings's Realm.
Entangle outside port and inside port.
Associate inside port with worker global scope.
Create a new WorkerLocation
object and associate it with worker global
- scope.
Entangle outside port and inside port.
Closing orphan workers: Start monitoring the worker such that no sooner than - it stops being a protected worker, and no later than it stops being a - permissible worker, worker global scope's closing flag is set to true.
-Create a new WorkerLocation
object and associate it with worker global
+ scope.
Suspending workers: Start monitoring the worker, such that whenever - worker global scope's closing - flag is false and the worker is a suspendable worker, the user agent suspends - execution of script in that worker until such time as either the closing flag switches to true or the worker stops - being a suspendable worker.
-Closing orphan workers: Start monitoring the worker such that no sooner than + it stops being a protected worker, and no later than it stops being a + permissible worker, worker global scope's closing flag is set to true.
+Set inside settings's execution ready flag.
Suspending workers: Start monitoring the worker, such that whenever + worker global scope's closing + flag is false and the worker is a suspendable worker, the user agent suspends + execution of script in that worker until such time as either the closing flag switches to true or the worker stops + being a suspendable worker.
+If script is a classic script, then run the classic script script. Otherwise, it is a module - script; run the module script - script.
+Set inside settings's execution ready flag.
In addition to the usual possibilities of returning a value or failing due to - an exception, this could be prematurely aborted by - the terminate a worker algorithm defined below.
- +If script is a classic script, then run the classic script script. Otherwise, it is a module + script; run the module script + script.
+ +In addition to the usual possibilities of returning a value or failing due to + an exception, this could be prematurely aborted by + the terminate a worker algorithm defined below.
+Enable outside port's port message queue.
Enable outside port's port message queue.
If is shared is false, enable the port message queue - of the worker's implicit port.
If is shared is false, enable the port message queue + of the worker's implicit port.
If is shared is true, then queue a global task on DOM
- manipulation task source given worker global scope to fire an event named connect
at worker global scope, using
- MessageEvent
, with the data
attribute
- initialized to the empty string, the ports
attribute
- initialized to a new frozen array containing inside port, and the source
attribute initialized to inside
- port.
If is shared is true, then queue a global task on DOM
+ manipulation task source given worker global scope to fire an event named connect
at worker global scope, using
+ MessageEvent
, with the data
attribute
+ initialized to the empty string, the ports
attribute
+ initialized to a new frozen array containing inside port, and the source
attribute initialized to inside
+ port.
Enable the client message queue of the
- ServiceWorkerContainer
object whose associated service worker client is
- worker global scope's relevant settings object.
Enable the client message queue of the
+ ServiceWorkerContainer
object whose associated service worker client is
+ worker global scope's relevant settings object.
Event loop: Run the responsible - event loop specified by inside settings until it is destroyed.
+Event loop: Run the responsible + event loop specified by inside settings until it is destroyed.
-The handling of events or the execution of callbacks by tasks run by the event loop might get prematurely aborted by the terminate a - worker algorithm defined below.
+The handling of events or the execution of callbacks by tasks run by the event loop might get prematurely aborted by the terminate a + worker algorithm defined below.
-The worker processing model remains on this step until the event loop is - destroyed, which happens after the closing - flag is set to true, as described in the event loop processing model.
-The worker processing model remains on this step until the event loop is + destroyed, which happens after the closing + flag is set to true, as described in the event loop processing model.
+ -Clear the worker global scope's - map of active timers.
-Clear the worker global scope's + map of active timers.
+Disentangle all the ports in the list of the worker's ports.
-Disentangle all the ports in the list of the worker's ports.
+Empty worker global scope's owner set.
+Empty worker global scope's owner set.
+Fetch the descendants of - module script, given fetch client settings object, destination, - and visited set.
Return from this algorithm, and run the following steps when fetching the descendants of a module script asynchronously - completes with result.
If result is null, then run onComplete given result, and - return.
+Fetch the descendants of + module script, given fetch client settings object, destination, + visited set, and with the following steps given result:
-In this case, there was an error fetching one or more of the descendants. We - will not attempt to link.
-Let parse error be the result of finding the first parse error - given result.
If result is null, then run onComplete given result, and + return.
-If parse error is null, then:
+In this case, there was an error fetching one or more of the descendants. We + will not attempt to link.
+Let record be result's record.
Let parse error be the result of finding the first parse error + given result.
Perform record.Link().
+If parse error is null, then:
-This step will recursively call Link on all of the module's unlinked dependencies.
+Let record be result's record.
Perform record.Link().
-If this throws an exception, set result's error to rethrow to that exception.
+This step will recursively call Link on all of + the module's unlinked dependencies.
+ +If this throws an exception, set result's error to rethrow to that exception.
+Otherwise, set result's error to - rethrow to parse error.
Otherwise, set result's error + to rethrow to parse error.
Run onComplete given result.
Run onComplete given result.
To fetch the descendants of a module script module script, given a - fetch client settings object, a destination, and a visited set, - run these steps. The algorithm will asynchronously complete with either null (on failure) or - with module script (on success).
+ 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).If module script's record is null, - then asynchronously complete this algorithm with module script and return.
Let record be module script's record.
If record is not a Cyclic Module Record, or if - record.[[RequestedModules]] is empty, - asynchronously complete this algorithm with module script.
Let moduleRequests be a new empty list.
Assert: options is not null, as module script is a JavaScript module script.
Let pendingCount be the length of moduleRequests.
Let failed be false.
For each moduleRequest in moduleRequests, perform the internal module script graph fetching procedure given moduleRequest, fetch client settings object, destination, options, module script's settings - object, visited set, and module script's base URL. If the caller of this - algorithm specified custom perform the - fetch steps, pass those along while performing the internal module script graph - fetching procedure.
+ object, visited set, module script's base URL, and the following steps given + result: -These invocations of the internal module script graph fetching procedure should - be performed in parallel to each other.
+If failed is true, return.
If any of the invocations of the internal module script graph fetching procedure - asynchronously complete with null, asynchronously complete this algorithm with null, and - return.
+If result is null, then set failed to true, run + onComplete with null, and return.
Otherwise, wait until all of the internal module script graph fetching procedure - invocations have asynchronously completed. Asynchronously complete this algorithm with - module script.
+Assert: pendingCount is greater than zero.
Decrement pendingCount by one.
If pendingCount is zero, run onComplete with module + script.
If the caller of this algorithm specified custom perform the fetch steps, pass those along while + performing the internal module script graph fetching procedure.
+ +These invocations of 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, and a - referrer, perform these steps. The algorithm will asynchronously complete with either - null (on failure) or a module script (on success).
+ some options, a module map settings object, a visited set, a + referrer, and an onComplete algorithm, run these steps. + onComplete must be an algorithm accepting null (on failure) or a module + script (on success).Let url be the result of resolving @@ -93596,15 +93610,11 @@ document.querySelector("button").addEventListener("click", bound); unset, and with the following steps given result:
If result is null, asynchronously complete this algorithm with null, and - return.
If result is null, run onComplete with null, and return.
Fetch the descendants of - result given fetch client settings object, destination, and - visited set.
When the appropriate algorithm asynchronously completes with final result, - asynchronously complete this algorithm with final result.
If the caller of this algorithm specified custom
Date: Tue, 13 Sep 2022 23:58:55 +0900
Subject: [PATCH 13/17] Add `processCustomFetchResponse` param to "perform the
fetch"
---
source | 71 +++++++++++++++++++++++++++++++++++-----------------------
1 file changed, 43 insertions(+), 28 deletions(-)
diff --git a/source b/source
index a51aa7ff9ca..6adc19d4fb3 100644
--- a/source
+++ b/source
@@ -92834,9 +92834,14 @@ 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 and an is top-level flag. The algorithm
- must complete with a response (which may be a network
+ 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
@@ -92894,9 +92899,10 @@ 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 when the custom perform the fetch steps
- complete with response response, run the
- remaining steps. Otherwise, fetch request. Return from this
algorithm, and run the remaining steps as part of the fetch's 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 when the custom perform the fetch steps
- complete with response response, run the
- remaining steps.
Otherwise, fetch request. Return from this algorithm, and run the remaining steps as part of the fetch's
If the caller specified custom steps to perform the fetch, perform them on request, with the is top-level flag set. Let response be - the result.
+ data-x="fetching-scripts-is-top-level">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, and let response be the result.
Unlike other algorithms in this section, the fetching process is synchronous here. Thus any perform the fetch steps will - also finish their work synchronously.
+ also run processCustomFetchResponse + synchronously.Finalize and report timing with response, settings @@ -93244,7 +93255,8 @@ document.querySelector("button").addEventListener("click", bound); fetch a worklet/module worker script graph given url, fetch client settings object, destination, credentials mode, module map settings object, and onComplete. Use the following custom steps to perform the fetch given response:
+ data-x="fetching-scripts-perform-fetch">perform the fetch given response and + processCustomFetchResponse:Let requestURL be request's
If moduleResponsesMap[requestURL] exists, then asynchronously complete the perform the fetch steps with - moduleResponsesMap[requestURL].
Set moduleResponsesMap[requestURL] to
"fetching
".
Set moduleResponsesMap[requestURL] to response.
Asynchronously complete the perform the - fetch steps with response.
Run processCustomFetchResponse with response.
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 when the custom perform the fetch steps complete with response response, run the remaining steps.
+ 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.Otherwise, fetch request. Return from this
algorithm, and run the remaining steps as part of the fetch's SharedWorkerGlobalScope : WorkerGlobalScope
In both cases, to perform the fetch
- given request, perform the following steps if the is top-level flag is set:
If is top-level is not set, fetch + request with processCustomFetchResponse as processResponseConsumeBody and return.
Fetch request, and asynchronously wait - to run the remaining steps as part of fetch's process response for the response response.
Fetch request. Return from this + algorithm, and run the remaining steps as part of the fetch's process response for + the response response.
Set worker global scope's url to response's SharedWorkerGlobalScope : WorkerGlobalScope issue #207 for more details.
Asynchronously complete the perform the - fetch steps with response.
Run processCustomFetchResponse with response.
In both cases, let onComplete given script be the following steps:
From 00ffcb2a33d35b41b2a755c11c625d1a272744d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?=Let pendingCount be the length of moduleRequests.
If pendingCount is zero, run onComplete with module + script.
Let failed be false.
If el's href
attribute's value is the
empty string, then return.
Let destination be the current state of the Let destination be the current state of el's as
attribute (a destination), or "script
" if
it is in no state.
If destination is not script-like, then queue an element
- task on the networking task source given the link
element to
- fire an event named error
at the link
element, and return.
error
+ at el, and return.Parse a URL given el's href
- attribute, relative to the element's node document. If that fails, then return.
- Otherwise, let url be the resulting URL record.
Let settings object be the link
element's node
- document's relevant settings object.
Let settings object be el's node document's + relevant settings object.
Let credentials mode be the CORS settings attribute credentials
- mode for the crossorigin
attribute.
crossorigin
+ attribute.
- Let cryptographic nonce be the current value of the element's - [[CryptographicNonce]] internal slot.
Let cryptographic nonce be + el.[[CryptographicNonce]].
Let integrity metadata be the value of the Let integrity metadata be the value of el's integrity
attribute, if it is specified, or the empty string
otherwise.
Let referrer policy be the current state of the element's Let referrer policy be the current state of el's referrerpolicy
attribute.
Let options be a script fetch options whose
If result is null, then fire an
- event named
named error
at the link
element,
+ eventerror
at el,
and return.
Fire an event named load
at the link
element.
Fetch an inline module script graph, given source text, base URL, settings object, options, and with the - following steps given result
+ following steps given result:Mark as ready el given result.
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. Return from this algorithm, - and run the remaining steps as part of the perform - the fetch's processCustomFetchResponse given response response.
+ data-x="fetching-scripts-is-top-level">is top-level flag set, and with the following processCustomFetchResponse steps given + response customFetchResponse: + +Set response to customFetchResponse.
Otherwise, fetch request, and let - response be the result.
+Otherwise, fetch request, and set + response to the result.
Unlike other algorithms in this section, the fetching process is synchronous here. Thus any perform the fetch steps will also run processCustomFetchResponse - synchronously.
+ synchronously. Thus, result has already been set when the step above completes.Finalize and report timing with response, settings @@ -93572,10 +93576,10 @@ document.querySelector("button").addEventListener("click", bound); result:
If failed is true, return.
If failed is true, then abort these steps.
If result is null, then set failed to true, run - onComplete with null, and return.
Assert: pendingCount is greater than zero.
These invocations of the internal module script graph fetching
+ The fetches performed by the internal module script graph fetching
procedure are performed in parallel to each other. Run the environment discarding steps
for inside settings. Return. Abort these steps. Associate worker with worker global scope. Unlike other algorithms in this section, the fetching process is synchronous
here. Thus any perform the fetch steps will
also run processCustomFetchResponse
- synchronously. Thus, result has already been set when the step above completes.
Finalize and report timing with response, settings