From 531ff434bba0cc08a84a0a8e17386929277955f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 5 Sep 2022 18:43:22 +0200 Subject: [PATCH 01/17] Add callbak to "fetch a single module script" --- source | 200 ++++++++++++++++++++++++++++++++------------------------- 1 file changed, 111 insertions(+), 89 deletions(-) diff --git a/source b/source index def07c4451e..7b57b67bdb9 100644 --- a/source +++ b/source @@ -93090,24 +93090,29 @@ document.querySelector("button").addEventListener("click", bound); script (on success).

    -
  1. 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.

  2. +
  3. +

    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:

    -
  4. If result is null, asynchronously complete this algorithm with null, and - return.

  5. +
      +
    1. If result is null, asynchronously complete this algorithm with null, and + return.

    2. -
    3. Let visited set be « (url, "javascript") - ».

    4. +
    5. Let visited set be « (url, "javascript") + ».

    6. -
    7. 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.

    8. +
    9. 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.

    10. +
    + +

    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.

  • +
      +
    1. If result is null, asynchronously complete this algorithm with null, and + return.

    2. -
    3. Let visited set be « (url, moduleType) ».

    4. +
    5. Let visited set be « (url, moduleType) ».

    6. -
    7. 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.

    8. +
    9. 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.

    10. +
    + +

    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.

      -
    1. 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.

    2. - -
    3. Asynchronously complete this algorithm with result, but do not - return.

    4. -
    5. -

      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:

        -
      1. Let visited set be « (url, "javascript") - ».

      2. +
      3. Asynchronously complete this algorithm with result, but do not + return.

      4. -
      5. Fetch the - descendants of and link result given settings object, - destination, and visited set.

      6. -
      +
    6. +

      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.

      +
        +
      1. Let visited set be « (url, "javascript") + ».

      2. + +
      3. Fetch the + descendants of and link result given settings object, + destination, and visited set.

      4. +
      + +

      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.

      +
    7. +
    @@ -93391,24 +93405,30 @@ document.querySelector("button").addEventListener("click", bound); mode, and referrer policy is the empty string.

    -
  • 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.

  • +
      +
    1. If result is null, asynchronously complete this algorithm with null, and + return.

    2. -
    3. Let visited set be « (url, "javascript") - ».

    4. +
    5. Let visited set be « (url, "javascript") + ».

    6. -
    7. 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.

    8. +
    9. 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.

    10. +
    + +

    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:

  • +
      +
    1. If result is null, asynchronously complete this algorithm with null, and + return.

    2. -
    3. If result is null, asynchronously complete this algorithm with null, and - return.

    4. +
    5. Fetch the descendants of + result given fetch client settings object, destination, and + visited set.

    6. -
    7. Fetch the descendants of - result given fetch client settings object, destination, and - visited set.

    8. +
    9. When the appropriate algorithm asynchronously completes with final result, + asynchronously complete this algorithm with final result.

    10. +
    -
  • 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).

    + 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).

    1. Let moduleType be "javascript".

    2. @@ -93614,8 +93637,8 @@ document.querySelector("button").addEventListener("click", bound); with running the following steps.

    3. If moduleMap[(url, moduleType)] exists, asynchronously complete this algorithm with - moduleMap[url / moduleType], and return.

    4. + data-x="map exists">exists, run onComplete given + moduleMap[(url, moduleType)], and return.

    5. Set moduleMap[(url, moduleType)] to "fetching".

    6. @@ -93674,8 +93697,7 @@ document.querySelector("button").addEventListener("click", bound);

      then set moduleMap[(url, - moduleType)] to null, asynchronously complete this algorithm with null, and - return.

      + moduleType)] to null, run onComplete given null, and return.

    7. Let source text be the result of UTF-8 @@ -93705,8 +93727,8 @@ document.querySelector("button").addEventListener("click", bound);

    8. Set moduleMap[(url, - moduleType)] to module script, and asynchronously complete this algorithm - with module script.

      + 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 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);

    9. 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.

    10. + data-x="">script", visited set, and onComplete This should be forwarded from the arguments.

    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.

    + visited set, and onComplete This should be + forwarded from the arguments.

    If the caller of this algorithm specified custom

    Fetch the descendants of and link result given settings object, - destination, and visited set.

    + destination, visited set, and with onComplete being an empty + algorithm.

    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.

  • + destination "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.

  • + object, destination, visited set, and onComplete This should be forwarded from the arguments.

    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).

    + 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).

    1. Fetch the descendants of @@ -93446,8 +93445,8 @@ document.querySelector("button").addEventListener("click", bound); completes with result.

    2. -

      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);
    3. Otherwise, set result's error to rethrow to parse error.

    4. -
    5. Asynchronously complete this algorithm with result.

    6. +
    7. 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?= Date: Mon, 5 Sep 2022 19:15:53 +0200 Subject: [PATCH 03/17] fetch an import() module script graph --- source | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/source b/source index e451fe06474..2c0be10d443 100644 --- a/source +++ b/source @@ -93115,15 +93115,15 @@ document.querySelector("button").addEventListener("click", bound);

    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).

    + base 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).

    1. Let url be the result of resolving a module specifier given base URL and moduleRequest.[[Specifier]].

    2. -
    3. If url is failure, then asynchronously complete this algorithm with null, and +

    4. If url is failure, then run onComplete given null, and return.

    5. Assert: moduleRequest.[[Assertions]] does not contain any Record @@ -93135,8 +93135,8 @@ document.querySelector("button").addEventListener("click", bound); request steps given moduleRequest.

    6. 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.

    7. + moduleType and settings object is false, then run onComplete + given null, and return.

    8. 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:

        -
      1. If result is null, asynchronously complete this algorithm with null, and - return.

      2. +
      3. If result is null, run onComplete with null, and return.

      4. Let visited set be « (url, moduleType) ».

      5. Fetch the descendants of and link result given settings object, destination, - visited set, and onComplete This should be - forwarded from the arguments.

      6. + visited set, and onComplete.

      If the caller of this algorithm specified custom case, referencingScriptOrModule is non-null.

    9. -
    10. Fetch an import() module script graph given moduleRequest, - base URL, settings object, and fetch options. Wait until the - algorithm asynchronously completes with result.

    11. - -
    12. Let promise be null. +

    13. +

      Fetch an import() module script graph given moduleRequest, + base URL, settings object, fetch options, and with + onComplete given result being these steps:

      -
    14. If result is null, then set promise to a promise rejected - with a new TypeError.

    15. +
        +
      1. Let promise be null. -

      2. Otherwise, set promise to the result of running a module script given result and true.

      3. +
      4. If result is null, then set promise to a promise rejected + with a new TypeError.

      5. -
      6. Perform FinishDynamicImport(referencingScriptOrModule, - moduleRequest, promiseCapability, promise).

      7. +
      8. Otherwise, set promise to the result of running a module script given result and true.

      9. -
      10. Return undefined.

      11. +
      12. Perform FinishDynamicImport(referencingScriptOrModule, + moduleRequest, promiseCapability, promise).

      13. +
      +
    HostResolveImportedModule(referencingScriptOrModule, From c27e72fa8166467adfa2091b4e4981ff1ccc721e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Mon, 5 Sep 2022 19:28:36 +0200 Subject: [PATCH 04/17] fetch an external module script graph --- source | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/source b/source index 2c0be10d443..804287d8507 100644 --- a/source +++ b/source @@ -60355,6 +60355,14 @@ o............A....e options's render-blocking to true.

    +
  • +

    Let onComplete given result be the following steps:

    + +
      +
    1. Mark as ready el given result.

    2. +
    +
  • +
  • Switch on el's type:

    @@ -60362,19 +60370,18 @@ o............A....e
    "classic"

    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).

    1. @@ -93097,16 +93104,14 @@ document.querySelector("button").addEventListener("click", bound); onComplete given result being these steps:

        -
      1. If result is null, asynchronously complete this algorithm with null, and - return.

      2. +
      3. If result is null, run onComplete given null, and return.

      4. Let visited set be « (url, "javascript") ».

      5. Fetch the descendants of and link result given settings object, "script", visited set, and onComplete This should be forwarded from the arguments.

      6. + data-x="">script", visited set, and onComplete.

      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

      "classic"

      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.

      + options, classic script CORS setting, encoding, and + onComplete.

      "module"
      @@ -92865,9 +92864,10 @@ document.querySelector("button").addEventListener("click", bound);

      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).

      1. 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.

        + run onComplete given 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.

      2. -
      3. Asynchronously complete this algorithm with script.
      4. +
      5. Run onComplete given script.

      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?= Date: Mon, 5 Sep 2022 19:40:26 +0200 Subject: [PATCH 06/17] fetch an inline module script graph --- source | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/source b/source index 27fcd6bfd23..78f4fdcc725 100644 --- a/source +++ b/source @@ -60426,10 +60426,15 @@ o............A....e

    2. Set el's delaying the load event to true.

    3. -
    4. 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.

    5. +
    6. +

      Fetch an inline module script graph, given source text, + base URL, settings object, options, and with + onComplete given result being these steps:

      + +
        +
      1. Mark as ready el given result.

      2. +
      +
    @@ -93205,24 +93210,23 @@ document.querySelector("button").addEventListener("click", bound);

    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).

    + URL, settings object, options, and an onComplete algorithm, + run these steps. onComplete must be an algorithm accepting null (on failure) or a + module script (on success).

    1. Let script be the result of creating a JavaScript module script using source text, settings object, base URL, and options.

    2. -
    3. If script is null, asynchronously complete this algorithm with null, and - return.

    4. +
    5. If script is null, run onComplete given null, and return.

    6. Let visited set be an empty set.

    7. Fetch the descendants of and link script, given settings object, the - destination "script", visited set, and onComplete - This should be forwarded from the arguments.

    8. + destination "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?= Date: Mon, 5 Sep 2022 19:51:41 +0200 Subject: [PATCH 07/17] fetch a worklet/module worker script graph --- source | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/source b/source index 78f4fdcc725..7c491073f2c 100644 --- a/source +++ b/source @@ -93231,20 +93231,18 @@ document.querySelector("button").addEventListener("click", bound);

    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.

    + credentials mode, a module map settings object, 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.

    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:

    1. 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).

      + client settings object, a destination, a credentials mode, a + module map settings object, and an onComplete algorithm, run these steps. + onComplete must be an algorithm accepting null (on failure) or a module + script (on success).

      1. Let options be a script fetch options whose onComplete given result being these steps:

          -
        1. If result is null, asynchronously complete this algorithm with null, and - return.

        2. +
        3. If result is null, run onComplete given null, and return.

        4. Let visited set be « (url, "javascript") ».

        5. Fetch the descendants of and link result given fetch client settings - object, destination, visited set, and onComplete This should be forwarded from the arguments.

        6. + object, destination, visited set, and + onComplete.

        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

      2. Fetch an inline module script graph, given source text, - base URL, settings object, options, and with - onComplete given result being these steps:

        + base URL, settings object, options, and with the + following steps given result

        1. Mark as ready el given result.

        2. @@ -93106,7 +93106,7 @@ document.querySelector("button").addEventListener("click", bound);

          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:

          + the following steps given result:

          1. If result is null, run onComplete given null, and return.

          2. @@ -93152,7 +93152,7 @@ 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 onComplete given result being these steps:

            + flag set, and with the following steps given result:

            1. If result is null, run onComplete with null, and return.

            2. @@ -93179,8 +93179,8 @@ document.querySelector("button").addEventListener("click", bound);
            3. 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:

              + data-x="">client", with the top-level module fetch flag set, and with the + following steps given result:

              1. Asynchronously complete this algorithm with result, but do not @@ -93195,8 +93195,7 @@ document.querySelector("button").addEventListener("click", bound);

              2. Fetch the descendants of and link result given settings object, - destination, visited set, and with onComplete being an empty - algorithm.

              3. + destination, visited set, and with 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:

              + the following steps given result:

              1. If result is null, run onComplete given null, and return.

              2. @@ -93591,7 +93590,7 @@ 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 onComplete given result being these steps:

                + unset, and with the following steps given result:

                1. If result is null, asynchronously complete this algorithm with null, and @@ -95204,8 +95203,8 @@ import "https://example.com/foo/../module2.mjs";

                2. 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:

                  1. Let promise be null. From 52f2e0a7fbdaa86254c32befd050b2afbd935264 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 6 Sep 2022 11:15:07 +0200 Subject: [PATCH 09/17] Fetch a modulepreload module script graph --- source | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/source b/source index a99fffce6a8..2ae872b2610 100644 --- a/source +++ b/source @@ -25652,16 +25652,20 @@ document.body.appendChild(wbr); mode, and referrer policy is referrer policy.

                  2. -
                  3. Fetch a modulepreload module script graph given url, - destination, settings object, and options. Wait until the - algorithm asynchronously completes with result.

                    +
                  4. +

                    Fetch a modulepreload module script graph given url, + destination, settings object, options, and with the following + steps given result:

                    -
                  5. If result is null, then fire an event - named error at the link element, and - return.

                  6. +
                      +
                    1. If result is null, then fire an + event named error at the link element, + and return.

                    2. -
                    3. Fire an event named load at the link element.

                    4. +
                    5. Fire an event named load at the link element.

                    6. +
                    +

                  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).

                1. @@ -93183,8 +93187,7 @@ document.querySelector("button").addEventListener("click", bound); following steps given result:

                    -
                  1. Asynchronously complete this algorithm with result, but do not - return.

                  2. +
                  3. Run onComplete given result.

                  4. 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?= Date: Tue, 6 Sep 2022 11:59:47 +0200 Subject: [PATCH 10/17] fetch a worklet script graph callers --- source | 106 +++++++++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 44 deletions(-) diff --git a/source b/source index 2ae872b2610..c30919e42e8 100644 --- a/source +++ b/source @@ -105092,44 +105092,66 @@ interface WorkletGlobalScope {}; settings object">setting up a worklet environment settings object given realmExecutionContext and outsideSettings.

                  5. +
                  6. Let pendingAddedModules be a clone of + worklet's added modules + list.

                  7. +
                  8. -

                    For each moduleURL of worklet's - added modules list:

                    +

                    Let runNextAddedModule be the following steps:

                    1. -

                      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:

                      + +
                        +
                      1. Let moduleURL be the result of dequeueing + from pendingAddedModules.

                      2. + +
                      3. +

                        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.

                        + +
                          +
                        1. 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.

                        2. + +
                        3. Run a module script given script.

                        4. + +
                        5. Run runNextAddedModule.

                        6. +
                        +
                      4. + +
                      5. Return.
                      6. +
                    2. -
                    3. 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.

                    4. +
                    5. Append workletGlobalScope to + outsideSettings's global + object's associated + Document's worklet + global scopes.

                    6. + +
                    7. Append workletGlobalScope to + worklet's global + scopes.

                    8. -
                    9. Run a module script given script.

                    10. +
                    11. Run the responsible event loop specified by + insideSettings.

                  9. -
                  10. Append workletGlobalScope to - outsideSettings's global object's - associated Document's worklet global scopes.

                  11. - -
                  12. Append workletGlobalScope to - worklet's global scopes.

                  13. - -
                  14. Run the responsible event loop specified by - insideSettings.

                  15. +
                  16. 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 WorkletGlobalScopes will reuse responses from this's module responses map.

                    -
                  1. -

                    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 WorkletGlobalScopes will reuse responses from this's module responses map.

                    -
                  2. -
                  3. If script is null, then:

                    From f9593d3456cc810d81ac51144897568a15306ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 6 Sep 2022 12:22:11 +0200 Subject: [PATCH 11/17] fetch a classic worker script & fetch a module worker script graph --- source | 189 +++++++++++++++++++++++++++++---------------------------- 1 file changed, 96 insertions(+), 93 deletions(-) diff --git a/source b/source index c30919e42e8..4188cd71619 100644 --- a/source +++ b/source @@ -92956,9 +92956,9 @@ document.querySelector("button").addEventListener("click", bound);

                  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).

                  1. Let request be a new request whose ok status,

                  2. -

                    then asynchronously complete this algorithm with null, and return.

                    +

                    then run onComplete given null, and return.

                  3. 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.

                  4. -
                  5. Asynchronously complete this algorithm with script.
                  6. +
                  7. Run onComplete given script.

                  To fetch a classic worker-imported script given a url and a @@ -103681,12 +103681,14 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope

                  "classic"
                  Fetch a classic worker script given url, outside - settings, destination, and inside settings.
                  + settings, destination, inside settings, and with + onComplete as defined below.
                  "module"
                  Fetch a module worker script graph given url, outside settings, destination, the value of the credentials - member of options, and inside settings.
                  + member of options, inside settings, and with onComplete as + defined below.

                  In both cases, to perform the fetch @@ -103764,115 +103766,116 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope fetch steps with response.

                -

                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:

                  -
                1. Queue a global task on the DOM manipulation task source given - worker's relevant global object to fire an event named error - at worker.

                2. - -
                3. Run the environment discarding steps - for inside settings.

                4. +
                5. If script is null or if script's error to rethrow is non-null, then:

                  -
                6. Return.

                7. -
                +
                  +
                1. Queue a global task on the DOM manipulation task source given + worker's relevant global object to fire an event named error + at worker.

                2. -

                  Otherwise, continue the rest of these steps after the algorithm's asynchronous completion, - with script being the asynchronous completion value.

                  - +
                3. Run the environment discarding steps + for inside settings.

                4. -
                5. Associate worker with worker global scope.

                6. +
                7. Return.

                8. +
                -
              3. Let inside port be a new MessagePort object in - inside settings's Realm.

              4. +
              5. Associate worker with worker global scope.

              6. -
              7. Associate inside port with worker global scope.

              8. +
              9. Let inside port be a new MessagePort object in + inside settings's Realm.

              10. -
              11. Entangle outside port and inside port.

              12. +
              13. Associate inside port with worker global scope.

              14. -
              15. Create a new WorkerLocation object and associate it with worker global - scope.

                +
              16. Entangle outside port and inside port.

              17. -
              18. -

                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.

                -
              19. +
              20. Create a new WorkerLocation object and associate it with worker global + scope.

                -
              21. -

                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.

                -
              22. +
              23. +

                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.

                +
              24. -
              25. Set inside settings's execution ready flag.

              26. +
              27. +

                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.

                +
              28. -
              29. -

                If script is a classic script, then run the classic script script. Otherwise, it is a module - script; run the module script - script.

                +
              30. Set inside settings's execution ready flag.

              31. -

                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.

                - +
              32. +

                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.

                +
              33. -
              34. Enable outside port's port message queue.

              35. +
              36. Enable outside port's port message queue.

              37. -
              38. If is shared is false, enable the port message queue - of the worker's implicit port.

              39. +
              40. If is shared is false, enable the port message queue + of the worker's implicit port.

              41. -
              42. 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.

              43. +
              44. 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.

              45. -
              46. Enable the client message queue of the - ServiceWorkerContainer object whose associated service worker client is - worker global scope's relevant settings object.

              47. +
              48. Enable the client message queue of the + ServiceWorkerContainer object whose associated service worker client is + worker global scope's relevant settings object.

              49. -
              50. -

                Event loop: Run the responsible - event loop specified by inside settings until it is destroyed.

                +
              51. +

                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.

                -
              52. +

                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.

                + -
              53. -

                Clear the worker global scope's - map of active timers.

                -
              54. +
              55. +

                Clear the worker global scope's + map of active timers.

                +
              56. -
              57. -

                Disentangle all the ports in the list of the worker's ports.

                -
              58. +
              59. +

                Disentangle all the ports in the list of the worker's ports.

                +
              60. -
              61. -

                Empty worker global scope's owner set.

                +
              62. +

                Empty worker global scope's owner set.

                +
              63. +
            From 734a1790ea96e8d2887885885bd94ffb550561e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 13 Sep 2022 22:08:23 +0900 Subject: [PATCH 12/17] fetch the descendants of a module script --- source | 128 +++++++++++++++++++++++++++++++-------------------------- 1 file changed, 69 insertions(+), 59 deletions(-) diff --git a/source b/source index 4188cd71619..a51aa7ff9ca 100644 --- a/source +++ b/source @@ -93443,64 +93443,65 @@ document.querySelector("button").addEventListener("click", bound); script (on success).

              -
            1. Fetch the descendants of - module script, given fetch client settings object, destination, - and visited set.

            2. - -
            3. Return from this algorithm, and run the following steps when fetching the descendants of a module script asynchronously - completes with result.

            4. -
            5. -

              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.

              -
            6. - -
            7. Let parse error be the result of finding the first parse error - given result.

            8. +
                +
              1. +

                If result is null, then run onComplete given result, and + return.

                -
              2. 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.

                +
              3. -
                  -
                1. Let record be result's record.

                2. +
                3. Let parse error be the result of finding the first parse error + given result.

                4. -

                  Perform record.Link().

                  +

                  If parse error is null, then:

                  -

                  This step will recursively call Link on all of the module's unlinked dependencies.

                  +
                    +
                  1. Let record be result's record.

                  2. + +
                  3. +

                    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.

                    +
                  4. +
                5. -
                - -
              4. Otherwise, set result's error to - rethrow to parse error.

              5. +
              6. Otherwise, set result's error + to rethrow to parse error.

              7. -
              8. Run onComplete given result.

              9. +
              10. Run onComplete given result.

              11. +
              +

            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).

            1. If module script's record is null, - then asynchronously complete this algorithm with module script and return.

            2. + run onComplete with module script and return.

            3. Let record be module script's record.

            4. If record is not a Cyclic Module Record, or if - record.[[RequestedModules]] is empty, - asynchronously complete this algorithm with module script.

            5. + record.[[RequestedModules]] is empty, run + onComplete with module script and return.

            6. Let moduleRequests be a new empty list.

            7. @@ -93543,35 +93544,48 @@ document.querySelector("button").addEventListener("click", bound);
            8. Assert: options is not null, as module script is a JavaScript module script.

            9. +
            10. Let pendingCount be the length of moduleRequests.

            11. + +
            12. Let failed be false.

            13. +
            14. 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.

              +
                +
              1. If failed is true, return.

              2. -

                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.

                +
              3. If result is null, then set failed to true, run + onComplete with null, and return.

              4. -

                Otherwise, wait until all of the internal module script graph fetching procedure - invocations have asynchronously completed. Asynchronously complete this algorithm with - module script.

                +
              5. Assert: pendingCount is greater than zero.

              6. + +
              7. Decrement pendingCount by one.

              8. + +
              9. If pendingCount is zero, run onComplete with module + script.

              10. +
              + +

              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).

            1. 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:

                -
              1. If result is null, asynchronously complete this algorithm with null, and - return.

              2. +
              3. If result is null, run onComplete with null, and return.

              4. Fetch the descendants of - result given fetch client settings object, destination, and - visited set.

              5. - -
              6. When the appropriate algorithm asynchronously completes with final result, - asynchronously complete this algorithm with final result.

              7. + result given fetch client settings object, destination, + visited set, and with onComplete.

              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.

              + 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 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.

              + 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

              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.

            2. 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:

              1. Let requestURL be request's

              2. If moduleResponsesMap[requestURL] exists, then asynchronously complete the perform the fetch steps with - moduleResponsesMap[requestURL].

              3. + exists">exists, then run processCustomFetchResponse with + moduleResponsesMap[requestURL] and return.

              4. Set moduleResponsesMap[requestURL] to "fetching".

              5. @@ -93272,8 +93283,7 @@ document.querySelector("button").addEventListener("click", bound);
              6. Set moduleResponsesMap[requestURL] to response.

              7. -
              8. Asynchronously complete the perform the - fetch steps with response.

              9. +
              10. Run processCustomFetchResponse with response.

            @@ -93685,9 +93695,10 @@ document.querySelector("button").addEventListener("click", bound);

            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:

            + given request, is top-level and processCustomFetchResponse:

              +
            1. If is top-level is not set, fetch + request with processCustomFetchResponse as processResponseConsumeBody and return.

            2. +
            3. Set request's reserved client to inside settings.
            4. -
            5. Fetch request, and asynchronously wait - to run the remaining steps as part of fetch's process response for the response response.

            6. +
            7. Fetch request. Return from this + algorithm, and run the remaining steps as part of the fetch's process response for + the response response.

            8. Set worker global scope's url to response's SharedWorkerGlobalScope : WorkerGlobalScope issue #207 for more details.

            9. -
            10. Asynchronously complete the perform the - fetch steps with response.

            11. +
            12. 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?= Date: Mon, 19 Sep 2022 15:54:48 +0200 Subject: [PATCH 14/17] fix: Run `onComplete` for modules with no dependencies --- source | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source b/source index 6adc19d4fb3..1fa60ae2694 100644 --- a/source +++ b/source @@ -93556,6 +93556,9 @@ document.querySelector("button").addEventListener("click", bound);
          3. Let pendingCount be the length of moduleRequests.

          4. +
          5. If pendingCount is zero, run onComplete with module + script.

          6. +
          7. Let failed be false.

          8. From 069f8f1f923378d827381396292a74acdd56369f Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Tue, 27 Sep 2022 16:02:09 +0900 Subject: [PATCH 15/17] Nits and nearby cleanups --- source | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/source b/source index 1fa60ae2694..96fd1cfbed5 100644 --- a/source +++ b/source @@ -25612,35 +25612,36 @@ document.body.appendChild(wbr);
          9. If el's href attribute's value is the empty string, then return.

          10. -
          11. 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.

          12. 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.

          13. + task on the networking task source given el to fire an event named error + at el, and return.

          14. 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.

          15. + attribute's value, relative to el's node document. If that fails, then + return. Otherwise, let url be the resulting URL record.

            -
          16. Let settings object be the link element's node - document's relevant settings object.

          17. +
          18. Let settings object be el's node document's + relevant settings object.

          19. Let credentials mode be the CORS settings attribute credentials - mode for the crossorigin attribute.

          20. + mode for el's crossorigin + attribute.

            -
          21. Let cryptographic nonce be the current value of the element's - [[CryptographicNonce]] internal slot.

          22. +
          23. Let cryptographic nonce be + el.[[CryptographicNonce]].

          24. -
          25. 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.

          26. -
          27. Let referrer policy be the current state of the element's

            Let referrer policy be the current state of el's referrerpolicy attribute.

          28. Let options be a script fetch options whose

            1. If result is null, then fire an - event named error at the link element, + event named error at el, and return.

            2. Fire an event named load at the link element.

            3. + data-x="event-load">load
              at el.

          @@ -60433,7 +60434,7 @@ o............A....e
        3. 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:

          1. Mark as ready el given result.

          2. @@ -92839,8 +92840,8 @@ document.querySelector("button").addEventListener("click", bound); export for="fetching scripts">processCustomFetchResponse algorithm. The perform the fetch algorithm - must run processCustomFetchResponse with a + 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 From 6f95d058aa9a03ba2af8121baa0070e2f56f3b9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Ribaudo?= Date: Tue, 27 Sep 2022 19:50:27 +0200 Subject: [PATCH 16/17] Review --- source | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/source b/source index 96fd1cfbed5..d5c40d23334 100644 --- a/source +++ b/source @@ -93056,22 +93056,26 @@ document.querySelector("button").addEventListener("click", bound); parser-inserted
            ", synchronous flag is set, and whose use-URL-credentials flag is set.

            +
          3. Let response be null.

          4. +
          5. 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:

            + +
              +
            1. Set response to customFetchResponse.

            2. +
            -

            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.

          6. Finalize and report timing with response, settings @@ -93572,10 +93576,10 @@ document.querySelector("button").addEventListener("click", bound); result:

              -
            1. If failed is true, return.

            2. +
            3. If failed is true, then abort these steps.

            4. If result is null, then set failed to true, run - onComplete with null, and return.

            5. + onComplete with null, and abort these steps.

            6. Assert: pendingCount is greater than zero.

            7. @@ -93589,7 +93593,7 @@ document.querySelector("button").addEventListener("click", bound); data-x="fetching-scripts-perform-fetch">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 +

              The fetches performed by the internal module script graph fetching procedure are performed in parallel to each other.

            @@ -103810,7 +103814,7 @@ interface SharedWorkerGlobalScope : WorkerGlobalScope
          7. Run the environment discarding steps for inside settings.

          8. -
          9. Return.

          10. +
          11. Abort these steps.

        4. Associate worker with worker global scope.

        5. @@ -105164,7 +105168,7 @@ interface WorkletGlobalScope {};
      3. -
      4. Return.
      5. +
      6. Abort these steps.
    2. From 2977c21ad5a259abd2b92444a5a1c87ffe2181d8 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Wed, 28 Sep 2022 14:44:38 +0900 Subject: [PATCH 17/17] Tweak wording and fix variable name --- source | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source b/source index d5c40d23334..f06aee3d2a0 100644 --- a/source +++ b/source @@ -93075,7 +93075,7 @@ document.querySelector("button").addEventListener("click", bound);

      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.

      + synchronously, and response will have been set when this step completes.

    3. Finalize and report timing with response, settings