From ae15bd9bed80a50540c900dc6fb9ba2afb4cf101 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 16 Mar 2022 14:09:47 +0200 Subject: [PATCH 01/31] Move `finalize and report timing` to controller A new method called `conclude` reports the timing for the resource. The timing info used is the one attached to the fetch rather than one attached to a response. This is done to reduce ambiguities when timing info is attached to the `response`, as it's unclear what happens to that timing info when a response is cloned, reused, serialized or stored & restored from cache. --- fetch.bs | 81 ++++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 67 insertions(+), 14 deletions(-) diff --git a/fetch.bs b/fetch.bs index e82e45b18..62d18a2aa 100644 --- a/fetch.bs +++ b/fetch.bs @@ -223,8 +223,12 @@ lt="authentication entry">authentication entries (for HTTP authentication). items:
-
state (default "ongoing") -
"ongoing", "terminated", or "aborted" +
state (default "requesting") +
"requesting", "responding", "concluded", + "terminated", or "aborted" + +
conclude steps (default null) +
Null or an algorithm responsible for finalizing the fetch and reporting timing information

To abort a fetch controller @@ -235,6 +239,24 @@ lt="authentication entry">authentication entries (for HTTP authentication). controller, set controller's state to "terminated". +

To conclude a fetch controller +controller, perform the following steps given a string +initiatorType, an optional "client" or global object +global (default "client"), and an optional "original" or +response finalResponse (default "original"):

+ +
    +
  1. Assert: this's state is "responding". + +

  2. Assert: this's conclude steps is not null. + +

  3. Invoke this's conclude steps with + initiatorType and global. + +

  4. Set controller's state to + "concluded". +

+

A fetch params fetchParams is aborted if its controller's state is "aborted". @@ -4283,22 +4305,54 @@ steps: fetchParams and a response response, run these steps:

    +
  1. Let timingInfo be fetchParams's + timing info.

  2. + +
  3. Set response's timing info to timingInfo.

  4. + +
  5. Set fetchParams's controller's + state to "responding". +

  6. -

    If response is a network error, then: +

    Set fetchParams's controller's + conclude steps to the following steps given a string + initiatorType, a "client" or global object + global, and an "original" or response + finalResponse:

      +
    1. If global is "client", then set global to + fetchParams's request's client's + global object. + +

    2. If finalResponse is "original", then set finalResponse + to response. + +

    3. If finalResponse is an aborted network error, then return. + +

    4. If request's URL's scheme is not an + HTTP(S) scheme, then return. + +

    5. Let timingInfo be fetchParams's + timing info. + +

    6. Let cacheState be response's cache state. +

    7. -

      Set response's URL list to « fetchParams's - request's URL list[0] ». +

      If finalResponse's timing allow passed flag is not set, + then set timingInfo to a the result of creating an opaque timing info for + timingInfo and set cacheState to the empty string. -

      This is needed as after cloning fetchParams's - request's URL list earlier, response - might have been set to a network error.

      +

      This covers the case of finalResponse being a network error.

    8. -
    9. Set response's timing info to the result of - creating an opaque timing info for fetchParams's - timing info.

    10. +
    11. Set timingInfo's end time to the + coarsened shared current time given global's + relevant settings object's + cross-origin isolated capability. + +

    12. Mark resource timing for timingInfo, request's + URL initiatorType, global, and cacheState.

  7. @@ -7721,9 +7775,8 @@ method steps are: controller.
-
  • Let handleFetchDone given response response be to - finalize and report timing with response, globalObject, and - "fetch". +

  • Let handleFetchDone be to + conclude controller given "fetch".

  • Set controller to the result of calling fetch given From 1e62dffb42432172f0a534ba7bdfa675c8c2b263 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 17 Mar 2022 08:42:54 +0200 Subject: [PATCH 02/31] Nits --- fetch.bs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index 62d18a2aa..9613ddbfc 100644 --- a/fetch.bs +++ b/fetch.bs @@ -246,6 +246,8 @@ lt="authentication entry">authentication entries (for HTTP authentication). response finalResponse (default "original"):

      +
    1. If this's state is "aborted", then return. +

    2. Assert: this's state is "responding".

    3. Assert: this's conclude steps is not null. @@ -4330,8 +4332,8 @@ steps:

    4. If finalResponse is an aborted network error, then return. -

    5. If request's URL's scheme is not an - HTTP(S) scheme, then return. +

    6. If fetchParams's request's URL's + scheme is not an HTTP(S) scheme, then return.

    7. Let timingInfo be fetchParams's timing info. From eb83a2482317153170b65a3b01af90fb0526102b Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 20 Mar 2022 14:16:33 +0200 Subject: [PATCH 03/31] Maintain previous ID --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index 9613ddbfc..a2fe7210b 100644 --- a/fetch.bs +++ b/fetch.bs @@ -239,8 +239,8 @@ lt="authentication entry">authentication entries (for HTTP authentication). controller, set controller's state to "terminated". -

      To conclude a fetch controller -controller, perform the following steps given a string +

      To conclude a +fetch controller controller, perform the following steps given a string initiatorType, an optional "client" or global object global (default "client"), and an optional "original" or response finalResponse (default "original"):

      From 07431d2fa79976ec0157b364c1b96844d9a52d97 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Sun, 20 Mar 2022 15:10:09 +0200 Subject: [PATCH 04/31] Expose resource info separately --- fetch.bs | 141 +++++++++++++++++-------------------------------------- 1 file changed, 42 insertions(+), 99 deletions(-) diff --git a/fetch.bs b/fetch.bs index a2fe7210b..27e6e0fcd 100644 --- a/fetch.bs +++ b/fetch.bs @@ -208,12 +208,12 @@ lt="authentication entry">authentication entries (for HTTP authentication).
      cross-origin isolated capability (default false)
      A boolean. -
      controller (default a new fetch controller) -
      A fetch controller. -
      timing info
      A fetch timing info. +
      controller +
      A fetch controller. +
      preloaded response candidate (default null)
      Null, "pending", or a response. @@ -227,6 +227,9 @@ lt="authentication entry">authentication entries (for HTTP authentication).
      "requesting", "responding", "concluded", "terminated", or "aborted" +
      timing info +
      A fetch timing info +
      conclude steps (default null)
      Null or an algorithm responsible for finalizing the fetch and reporting timing information @@ -240,10 +243,11 @@ lt="authentication entry">authentication entries (for HTTP authentication). "terminated".

      To conclude a -fetch controller controller, perform the following steps given a string -initiatorType, an optional "client" or global object -global (default "client"), and an optional "original" or -response finalResponse (default "original"):

      +fetch controller controller, perform the following steps given an optional +string initiatorType (default "other"), an optional "client" or +global object global (default "client"), and an optional +"original" or response finalResponse (default +"original"):

      1. If this's state is "aborted", then return. @@ -282,10 +286,6 @@ following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]

        end time (default 0)
        A {{DOMHighResTimeStamp}}. -
        encoded body size (default 0) -
        decoded body size (default 0) -
        A number. -
        final connection timing info (default null)
        Null or a connection timing info. @@ -293,6 +293,16 @@ following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
        A list of strings. +

        A fetch resource info is a struct used to maintain +information needed by Resource Timing and Navigation Timing. It has the +following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]] + +

        +
        encoded body size (default 0) +
        decoded body size (default 0) +
        A number. +
        +

        To create an opaque timing info, given a fetch timing info timingInfo, return a new @@ -300,22 +310,6 @@ given a fetch timing info timingInfo, return a new post-redirect start time are timingInfo's start time. -

        To update timing info from stored response, given a -connection timing info timingInfo and a response -response, perform the following steps: - -

          -
        1. Let storedTimingInfo be response's timing info. - -

        2. If storedTimingInfo is null, then return. - -

        3. Set timingInfo's encoded body size to - storedTimingInfo's encoded body size. - -

        4. Set timingInfo's decoded body size to - storedTimingInfo's decoded body size. -

        -

        To queue a fetch task, given an algorithm algorithm, a global object or a parallel queue taskDestination, run these steps: @@ -2111,6 +2105,11 @@ message as HTTP/2 does not support them. "local", or "validated"). Unlesss stated otherwise, it is the empty string. +

        A response has an associated +resource info +(a fetch resource info). Unlesss stated otherwise, it is a new +fetch resource info. +

        This is intended for usage by Service Workers and Resource Timing. [[SW]] [[RESOURCE-TIMING]]

      - -
    8. -

      Set response's timing info to timingInfo. - -

      Attaching the timing info to a response is what makes it exposed to the web as a - Resource Timing entry later. This step is done here, as resource-timing entries are available only - for HTTP fetches, including ones that are handled by service-workers or HTTP cache, and not for, - e.g., data:, blob: URL fetches, and are only available after all the - relevant security checks have succeeded. +

    9. Return response. Typically actualResponse's body's @@ -5315,9 +5262,6 @@ steps. They return a response.

    10. Set response to storedResponse.

    11. Set response's cache state to "validated". - -

    12. Update timing info from stored response given fetchParams's - timing info and response.

  • @@ -5333,9 +5277,6 @@ steps. They return a response.

    If forwardResponse is a network error, this effectively caches the network error, which is sometimes known as "negative caching". - -

    The associated timing info is stored in the cache - alongside the response. @@ -5748,8 +5689,9 @@ optional boolean forceNewConnection (default false), run these steps:

  • Let codings be the result of extracting header list values given `Content-Encoding` and response's header list. -

  • Increase timingInfo's encoded body size - by bytes's length. +

  • Increase response's resource info's + encoded body size by bytes's + length.

  • Set bytes to the result of handling content @@ -5758,7 +5700,8 @@ optional boolean forceNewConnection (default false), run these steps:

    This makes the `Content-Length` header unreliable to the extent that it was reliable to begin with. -

  • Increase timingInfo's decoded body size by +

  • Increase response's resource info's + decoded body size by bytes's length.

  • If bytes is failure, then terminate From 6ba027a7473e4b2b486750004a86f022b9401fac Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 4 Apr 2022 19:52:51 +0300 Subject: [PATCH 05/31] Pass all parameters to conclude steps --- fetch.bs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/fetch.bs b/fetch.bs index 27e6e0fcd..5351ba0a3 100644 --- a/fetch.bs +++ b/fetch.bs @@ -245,9 +245,10 @@ lt="authentication entry">authentication entries (for HTTP authentication).

    To conclude a fetch controller controller, perform the following steps given an optional string initiatorType (default "other"), an optional "client" or -global object global (default "client"), and an optional +global object global (default "client"), an optional "original" or response finalResponse (default -"original"):

    +"original"), and an optional "now" or {{DOMHighResTimeStamp}} +unsafeResponseEndTime:

    1. If this's state is "aborted", then return. @@ -256,8 +257,12 @@ string initiatorType (default "other"), an optional "

      Assert: this's conclude steps is not null. +

    2. If unsafeResponseEndTime is "now", then set + unsafeResponseEndTime to the unsafe shared current time. +

    3. Invoke this's conclude steps with - initiatorType and global. + initiatorType, global, finalResponse, and + unsafeResponseEndTime.

    4. Set controller's state to "concluded". @@ -4316,8 +4321,8 @@ steps:

      Set fetchParams's controller's conclude steps to the following steps given a string initiatorType, a "client" or global object - global, and an "original" or response - finalResponse: + global, an "original" or response + finalResponse, and a {{DOMHighResTimeStamp}} unsafeResponseEndTime:

      1. If global is "client", then set global to @@ -4348,8 +4353,8 @@ steps:

        This covers the case of finalResponse being a network error.

      2. -
      3. Set timingInfo's end time to the - coarsened shared current time given global's +

      4. Set timingInfo's end time to the result of + coarsening unsafeResponseEndTime given global's relevant settings object's cross-origin isolated capability. From a4b1ca41ba746837107824237466a01b59a04e50 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 22 Apr 2022 10:46:13 +0300 Subject: [PATCH 06/31] Nits, and rename some phases --- fetch.bs | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/fetch.bs b/fetch.bs index 5351ba0a3..92f3e5380 100644 --- a/fetch.bs +++ b/fetch.bs @@ -223,8 +223,8 @@ lt="authentication entry">authentication entries (for HTTP authentication). items:

        -
        state (default "requesting") -
        "requesting", "responding", "concluded", +
        state (default "fetching") +
        "fetching", "transmitting", "concluded", "terminated", or "aborted"
        timing info @@ -248,12 +248,12 @@ string initiatorType (default "other"), an optional "global object global (default "client"), an optional "original" or response finalResponse (default "original"), and an optional "now" or {{DOMHighResTimeStamp}} -unsafeResponseEndTime:

        +unsafeResponseEndTime (default "now"):

        1. If this's state is "aborted", then return. -

        2. Assert: this's state is "responding". +

        3. Assert: this's state is "transmitting".

        4. Assert: this's conclude steps is not null. @@ -298,13 +298,15 @@ following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]

          A list of strings.
        -

        A fetch resource info is a struct used to maintain +

        A response body info is a struct used to maintain information needed by Resource Timing and Navigation Timing. It has the following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]

        -
        encoded body size (default 0) -
        decoded body size (default 0) +
        encoded body + size (default 0) +
        decoded body + size (default 0)
        A number.
        @@ -2107,19 +2109,19 @@ message as HTTP/2 does not support them.

        A response has an associated cache state (the empty string, -"local", or "validated"). Unlesss stated otherwise, it is the empty +"local", or "validated"). Unless stated otherwise, it is the empty string. -

        A response has an associated -resource info -(a fetch resource info). Unlesss stated otherwise, it is a new -fetch resource info. -

        This is intended for usage by Service Workers and Resource Timing. [[SW]] [[RESOURCE-TIMING]] +

        A response has an associated +body info +(a response body info). Unless stated otherwise, it is a new +response body info. +

        A response has an associated CORS-exposed header-name list (a list of zero or more header @@ -4312,10 +4314,10 @@ steps:

        1. Let timingInfo be fetchParams's - timing info.

        2. + timing info.
        3. Set fetchParams's controller's - state to "responding". + state to "transmitting".

        4. Set fetchParams's controller's @@ -4342,12 +4344,12 @@ steps:

        5. Let cacheState be response's cache state. -

        6. Let resourceInfo be response's resource info. +

        7. Let bodyInfo be response's body info.

        8. If finalResponse's timing allow passed flag is not set, then set timingInfo to a the result of creating an opaque timing info for - timingInfo, set resourceInfo to a new fetch resource info and + timingInfo, set bodyInfo to a new response body info and set cacheState to the empty string.

          This covers the case of finalResponse being a network error. @@ -4360,7 +4362,7 @@ steps:

        9. Mark resource timing for timingInfo, request's URL initiatorType, global, cacheState, - and resourceInfo. + and bodyInfo.

      5. @@ -5694,8 +5696,8 @@ optional boolean forceNewConnection (default false), run these steps:
      6. Let codings be the result of extracting header list values given `Content-Encoding` and response's header list. -

      7. Increase response's resource info's - encoded body size by bytes's +

      8. Increase response's body info's + encoded body size by bytes's length.

      9. @@ -5705,8 +5707,8 @@ optional boolean forceNewConnection (default false), run these steps:

        This makes the `Content-Length` header unreliable to the extent that it was reliable to begin with. -

      10. Increase response's resource info's - decoded body size by +

      11. Increase response's body info's + decoded body size by bytes's length.

      12. If bytes is failure, then terminate From ee02a161752499a325d9a23653e209ebdbcd5b9c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 22 Apr 2022 10:49:36 +0300 Subject: [PATCH 07/31] Align server-timing with conclude --- fetch.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fetch.bs b/fetch.bs index 92f3e5380..a15995326 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4319,6 +4319,9 @@ steps:

      13. Set fetchParams's controller's state to "transmitting". +

      14. Let timingInfo be fetchParams's + timing info. +

      15. Set fetchParams's controller's conclude steps to the following steps given a string @@ -4339,9 +4342,6 @@ steps:

      16. If fetchParams's request's URL's scheme is not an HTTP(S) scheme, then return. -

      17. Let timingInfo be fetchParams's - timing info. -

      18. Let cacheState be response's cache state.

      19. Let bodyInfo be response's body info. @@ -4367,8 +4367,8 @@ steps:

      20. Otherwise, if fetchParams's request's - client is a secure context, set response's - timing info's server-timing headers to the + client is a secure context, set timingInfo's + server-timing headers to the result of getting, decoding, and splitting `Server-Timing` from response's header list. From e570139f840b997579a9ccb066c8561f82832818 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 25 Apr 2022 13:42:38 +0300 Subject: [PATCH 08/31] Note about caching --- fetch.bs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fetch.bs b/fetch.bs index a15995326..5eb93f797 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5284,6 +5284,9 @@ steps. They return a response.

        If forwardResponse is a network error, this effectively caches the network error, which is sometimes known as "negative caching". + +

        forwardResponse's body info should be stored + as part of the response.

    From dac82aaa5130b87d37ed7a49a413c6ac8f207a87 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 25 Apr 2022 13:45:55 +0300 Subject: [PATCH 09/31] Note about caching --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index 5eb93f797..f9d743490 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5285,7 +5285,7 @@ steps. They return a response.

    If forwardResponse is a network error, this effectively caches the network error, which is sometimes known as "negative caching". -

    forwardResponse's body info should be stored +

    The user agent should store forwardResponse's body info as part of the response. From a1e3592af6cf29e5a18130df8261dbb4afd05d00 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 25 Apr 2022 13:50:51 +0300 Subject: [PATCH 10/31] Note about caching --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index f9d743490..903880695 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5285,7 +5285,7 @@ steps. They return a response.

    If forwardResponse is a network error, this effectively caches the network error, which is sometimes known as "negative caching". -

    The user agent should store forwardResponse's body info +

    The user agent should store forwardResponse's body info as part of the response. From 47d2a5c64dc31af71ad8ced6f8fdd14964656313 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 11 May 2022 19:48:51 +0300 Subject: [PATCH 11/31] Rename states --- fetch.bs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/fetch.bs b/fetch.bs index 903880695..f98a72e03 100644 --- a/fetch.bs +++ b/fetch.bs @@ -223,9 +223,15 @@ lt="authentication entry">authentication entries (for HTTP authentication). items:

    -
    state (default "fetching") -
    "fetching", "transmitting", "concluded", - "terminated", or "aborted" +
    state (default "requesting") +
    + "requesting", "responding", "concluded", + "terminated", or "aborted" + +

    The states of the fetch controller + only make sense in the context of half-duplex HTTP fetches (where the request is + complete before the response starts). Using them in other contexts should be handled + with care.

    timing info
    A fetch timing info @@ -253,7 +259,7 @@ string initiatorType (default "other"), an optional "
  • If this's state is "aborted", then return. -

  • Assert: this's state is "transmitting". +

  • Assert: this's state is "responding".

  • Assert: this's conclude steps is not null. @@ -4317,7 +4323,7 @@ steps: timing info.

  • Set fetchParams's controller's - state to "transmitting". + state to "responding".

  • Let timingInfo be fetchParams's timing info. @@ -4742,7 +4748,6 @@ these steps:

  • -
  • Return response. Typically actualResponse's body's From e11d3379bc2258da458ec5b04aec837ed66bc73c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 11 May 2022 20:02:30 +0300 Subject: [PATCH 12/31] Unshould --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index f98a72e03..13c8647b8 100644 --- a/fetch.bs +++ b/fetch.bs @@ -230,8 +230,8 @@ lt="authentication entry">authentication entries (for HTTP authentication).

    The states of the fetch controller only make sense in the context of half-duplex HTTP fetches (where the request is - complete before the response starts). Using them in other contexts should be handled - with care.

    + complete before the response starts). Handle with care when using them in other + contexts.

    timing info
    A fetch timing info From ac555536ccc42f4a61d715b6f52ae87244c18519 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 17 May 2022 10:02:03 +0100 Subject: [PATCH 13/31] Fix some CR nits --- fetch.bs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fetch.bs b/fetch.bs index 13c8647b8..ef202056d 100644 --- a/fetch.bs +++ b/fetch.bs @@ -208,12 +208,12 @@ lt="authentication entry">authentication entries (for HTTP authentication).
    cross-origin isolated capability (default false)
    A boolean. -
    timing info -
    A fetch timing info. -
    controller
    A fetch controller. +
    timing info +
    A fetch timing info. +
    preloaded response candidate (default null)
    Null, "pending", or a response. @@ -234,10 +234,10 @@ lt="authentication entry">authentication entries (for HTTP authentication). contexts.

    timing info -
    A fetch timing info +
    A fetch timing info.
    conclude steps (default null) -
    Null or an algorithm responsible for finalizing the fetch and reporting timing information +
    Null or an algorithm responsible for finalizing the fetch and reporting timing information.

    To abort a fetch controller @@ -4367,7 +4367,7 @@ steps: cross-origin isolated capability.

  • Mark resource timing for timingInfo, request's - URL initiatorType, global, cacheState, + URL, initiatorType, global, cacheState, and bodyInfo. From dc1f604f16005cc4be0dbbcb5b01eb18c9565514 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 23 May 2022 18:00:40 +0100 Subject: [PATCH 14/31] Simplify state --- fetch.bs | 112 +++++++++++++++++++++++++------------------------------ 1 file changed, 50 insertions(+), 62 deletions(-) diff --git a/fetch.bs b/fetch.bs index ef202056d..a09559575 100644 --- a/fetch.bs +++ b/fetch.bs @@ -223,21 +223,14 @@ lt="authentication entry">authentication entries (for HTTP authentication). items:

    -
    state (default "requesting") -
    - "requesting", "responding", "concluded", - "terminated", or "aborted" - -

    The states of the fetch controller - only make sense in the context of half-duplex HTTP fetches (where the request is - complete before the response starts). Handle with care when using them in other - contexts.

    +
    state (default "ongoing") +
    "ongoing", "terminated", or "aborted"
    timing info
    A fetch timing info.
    conclude steps (default null) -
    Null or an algorithm responsible for finalizing the fetch and reporting timing information. +
    Null or an algorithm responsible for reporting timing information.

    To abort a fetch controller @@ -259,8 +252,6 @@ string initiatorType (default "other"), an optional "

  • If this's state is "aborted", then return. -

  • Assert: this's state is "responding". -

  • Assert: this's conclude steps is not null.

  • If unsafeResponseEndTime is "now", then set @@ -269,9 +260,6 @@ string initiatorType (default "other"), an optional "

    Invoke this's conclude steps with initiatorType, global, finalResponse, and unsafeResponseEndTime. - -

  • Set controller's state to - "concluded".

    A fetch params fetchParams is aborted if @@ -4322,57 +4310,11 @@ steps:

  • Let timingInfo be fetchParams's timing info. -

  • Set fetchParams's controller's - state to "responding". -

  • Let timingInfo be fetchParams's timing info.

  • -

    Set fetchParams's controller's - conclude steps to the following steps given a string - initiatorType, a "client" or global object - global, an "original" or response - finalResponse, and a {{DOMHighResTimeStamp}} unsafeResponseEndTime: - -

      -
    1. If global is "client", then set global to - fetchParams's request's client's - global object. - -

    2. If finalResponse is "original", then set finalResponse - to response. - -

    3. If finalResponse is an aborted network error, then return. - -

    4. If fetchParams's request's URL's - scheme is not an HTTP(S) scheme, then return. - -

    5. Let cacheState be response's cache state. - -

    6. Let bodyInfo be response's body info. - -

    7. -

      If finalResponse's timing allow passed flag is not set, - then set timingInfo to a the result of creating an opaque timing info for - timingInfo, set bodyInfo to a new response body info and - set cacheState to the empty string. - -

      This covers the case of finalResponse being a network error. -

    8. - -
    9. Set timingInfo's end time to the result of - coarsening unsafeResponseEndTime given global's - relevant settings object's - cross-origin isolated capability. - -

    10. Mark resource timing for timingInfo, request's - URL, initiatorType, global, cacheState, - and bodyInfo. -

    - -
  • -

    Otherwise, if fetchParams's request's +

    If fetchParams's request's client is a secure context, set timingInfo's server-timing headers to the result of getting, decoding, and splitting `Server-Timing` @@ -4388,6 +4330,52 @@ steps:

  • Set fetchParams's request's done flag. +

  • +

    Set fetchParams's controller's + conclude steps to the following steps given a string + initiatorType, a "client" or global object + global, an "original" or response + finalResponse, and a {{DOMHighResTimeStamp}} unsafeResponseEndTime: + +

      +
    1. If global is "client", then set global to + fetchParams's request's client's + global object. + +

    2. If finalResponse is "original", then set finalResponse + to response. + +

    3. If finalResponse is an aborted network error, then return. + +

    4. Assert: finalResponse is response or a network error. + +

    5. If fetchParams's request's URL's + scheme is not an HTTP(S) scheme, then return. + +

    6. Let cacheState be response's cache state. + +

    7. Let bodyInfo be response's body info. + +

    8. +

      If finalResponse's timing allow passed flag is not set, + then set timingInfo to a the result of creating an opaque timing info for + timingInfo, set bodyInfo to a new response body info and + set cacheState to the empty string. + +

      This covers the case of finalResponse being a network error. +

    9. + +
    10. Set timingInfo's end time to the result of + coarsening unsafeResponseEndTime given global's + relevant settings object's + cross-origin isolated capability. + +

    11. Mark resource timing for timingInfo, request's + URL, initiatorType, global, cacheState, + and bodyInfo. +

    +
  • +
  • If fetchParams's process response end-of-body is not null, then queue a fetch task to run fetchParams's process response end-of-body given response with From 2b17c8f6633212ba812a29c80ae6df862f873042 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 23 May 2022 18:10:44 +0100 Subject: [PATCH 15/31] nits --- fetch.bs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fetch.bs b/fetch.bs index a09559575..6d97c4cff 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4310,13 +4310,10 @@ steps:

  • Let timingInfo be fetchParams's timing info. -

  • Let timingInfo be fetchParams's - timing info. -

  • -

    If fetchParams's request's - client is a secure context, set timingInfo's - server-timing headers to the +

    If response is not a network error and fetchParams's + request's client is a secure context, then set + timingInfo's server-timing headers to the result of getting, decoding, and splitting `Server-Timing` from response's header list. From e8395c0afc45c6c23fb2277262f0712373bb2192 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 24 May 2022 13:18:46 +0100 Subject: [PATCH 16/31] Dedup timing-info --- fetch.bs | 76 ++++++++++++++++++++++++++------------------------------ 1 file changed, 35 insertions(+), 41 deletions(-) diff --git a/fetch.bs b/fetch.bs index 6d97c4cff..c348f0f21 100644 --- a/fetch.bs +++ b/fetch.bs @@ -208,7 +208,7 @@ lt="authentication entry">authentication entries (for HTTP authentication).

    cross-origin isolated capability (default false)
    A boolean. -
    controller +
    controller (default a new fetch controller)
    A fetch controller.
    timing info @@ -226,10 +226,7 @@ lt="authentication entry">authentication entries (for HTTP authentication).
    state (default "ongoing")
    "ongoing", "terminated", or "aborted" -
    timing info -
    A fetch timing info. - -
    conclude steps (default null) +
    report timing steps (default null)
    Null or an algorithm responsible for reporting timing information. @@ -241,7 +238,7 @@ lt="authentication entry">authentication entries (for HTTP authentication). controller, set controller's state to "terminated". -

    To conclude a +

    To report timing for a fetch controller controller, perform the following steps given an optional string initiatorType (default "other"), an optional "client" or global object global (default "client"), an optional @@ -252,12 +249,12 @@ string initiatorType (default "other"), an optional "

  • If this's state is "aborted", then return. -

  • Assert: this's conclude steps is not null. +

  • Assert: this's report timing steps is not null.

  • If unsafeResponseEndTime is "now", then set unsafeResponseEndTime to the unsafe shared current time. -

  • Invoke this's conclude steps with +

  • Invoke this's report timing steps with initiatorType, global, finalResponse, and unsafeResponseEndTime. @@ -3855,9 +3852,6 @@ the request. post-redirect start time are the coarsened shared current time given crossOriginIsolatedCapability. -

  • Let controller be a new fetch controller whose - timing info is timingInfo. -

  • Let fetchParams be a new fetch params whose request is request, timing info is timingInfo, @@ -4329,47 +4323,47 @@ steps:

  • Set fetchParams's controller's - conclude steps to the following steps given a string + report timing steps to the following steps given a string initiatorType, a "client" or global object global, an "original" or response finalResponse, and a {{DOMHighResTimeStamp}} unsafeResponseEndTime:

      -
    1. If global is "client", then set global to - fetchParams's request's client's - global object. - -

    2. If finalResponse is "original", then set finalResponse - to response. +

    3. If global is "client", then set global to + fetchParams's request's client's + global object. -

    4. If finalResponse is an aborted network error, then return. +

    5. If finalResponse is "original", then set finalResponse + to response. -

    6. Assert: finalResponse is response or a network error. +

    7. If finalResponse is an aborted network error, then return. -

    8. If fetchParams's request's URL's - scheme is not an HTTP(S) scheme, then return. +

    9. Assert: finalResponse is response or a network error. -

    10. Let cacheState be response's cache state. +

    11. If fetchParams's request's URL's + scheme is not an HTTP(S) scheme, then return. -

    12. Let bodyInfo be response's body info. +

    13. Let cacheState be response's cache state. -

    14. -

      If finalResponse's timing allow passed flag is not set, - then set timingInfo to a the result of creating an opaque timing info for - timingInfo, set bodyInfo to a new response body info and - set cacheState to the empty string. +

    15. Let bodyInfo be response's body info. -

      This covers the case of finalResponse being a network error. -

    16. - -
    17. Set timingInfo's end time to the result of - coarsening unsafeResponseEndTime given global's - relevant settings object's - cross-origin isolated capability. - -

    18. Mark resource timing for timingInfo, request's - URL, initiatorType, global, cacheState, - and bodyInfo. +

    19. +

      If finalResponse's timing allow passed flag is not set, + then set timingInfo to a the result of creating an opaque timing info for + timingInfo, set bodyInfo to a new response body info and + set cacheState to the empty string. + +

      This covers the case of finalResponse being a network error. +

    20. + +
    21. Set timingInfo's end time to the result of + coarsening unsafeResponseEndTime given global's + relevant settings object's + cross-origin isolated capability. + +

    22. Mark resource timing for timingInfo, request's + URL, initiatorType, global, cacheState, + and bodyInfo.

  • @@ -7721,7 +7715,7 @@ method steps are:
  • Let handleFetchDone be to - conclude controller given "fetch". + report timing for controller given "fetch".

  • Set controller to the result of calling fetch given From 4f4bc768c1acf08951d5e87838a185aa51e71d60 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 24 May 2022 17:30:41 +0100 Subject: [PATCH 17/31] Refactor to auto-report timing --- fetch.bs | 114 ++++++++++++++++++++++++------------------------------- 1 file changed, 50 insertions(+), 64 deletions(-) diff --git a/fetch.bs b/fetch.bs index c348f0f21..4ae2797bc 100644 --- a/fetch.bs +++ b/fetch.bs @@ -205,6 +205,12 @@ lt="authentication entry">authentication entries (for HTTP authentication).

    task destination (default null)
    Null, a global object, or a parallel queue. +
    initiator type (default "other") +
    A string. + +
    timing global (default null) +
    Null or a global object. +
    cross-origin isolated capability (default false)
    A boolean. @@ -225,9 +231,6 @@ lt="authentication entry">authentication entries (for HTTP authentication).
    state (default "ongoing")
    "ongoing", "terminated", or "aborted" - -
    report timing steps (default null) -
    Null or an algorithm responsible for reporting timing information.

    To abort a fetch controller @@ -238,27 +241,6 @@ lt="authentication entry">authentication entries (for HTTP authentication). controller, set controller's state to "terminated". -

    To report timing for a -fetch controller controller, perform the following steps given an optional -string initiatorType (default "other"), an optional "client" or -global object global (default "client"), an optional -"original" or response finalResponse (default -"original"), and an optional "now" or {{DOMHighResTimeStamp}} -unsafeResponseEndTime (default "now"):

    - -
      -
    1. If this's state is "aborted", then return. - -

    2. Assert: this's report timing steps is not null. - -

    3. If unsafeResponseEndTime is "now", then set - unsafeResponseEndTime to the unsafe shared current time. - -

    4. Invoke this's report timing steps with - initiatorType, global, finalResponse, and - unsafeResponseEndTime. -

    -

    A fetch params fetchParams is aborted if its controller's state is "aborted". @@ -3793,15 +3775,18 @@ an optional algorithm processEarlyHintsResponse algorithm processResponse, an optional algorithm processResponseEndOfBody, an optional algorithm processResponseConsumeBody, -and an optional boolean useParallelQueue (default false), run -the steps below. If given, processRequestBodyChunkLength must be an algorithm accepting -an integer representing the number of bytes transmitted. If given, -processRequestEndOfBody must be an algorithm accepting no arguments. If given, -processEarlyHintsResponse must be an algorithm accepting a response. If -given, processResponse must be an algorithm accepting a response. If given, -processResponseEndOfBody must be an algorithm accepting a response. If -given, processResponseConsumeBody must be an algorithm accepting a response -and null, failure, or a byte sequence. +an optional boolean useParallelQueue (default false), an +optional string initiatorType (default "other"), +and an optional "client", "none" or a global object +timingGlobal (default "client"), run the steps +below. If given, processRequestBodyChunkLength must be an algorithm acceptin an integer +representing the number of bytes transmitted. If given processRequestEndOfBody must be an +algorithm accepting no arguments. If given, processEarlyHintsResponse must be an +algorithm accepting a response. If given, processResponse must be an +algorithm accepting a response. If given, processResponseEndOfBody must be +an algorithm accepting a response. If given, processResponseConsumeBody must +be an algorithm accepting a response and null, failure, or a +byte sequence.

    The user agent may be asked to suspend the ongoing fetch. @@ -3842,6 +3827,10 @@ the request.

  • If useParallelQueue is true, then set taskDestination to the result of starting a new parallel queue. +

  • If timingGlobal is "client", then set timingGlobal + to request's client's + global object. + +

  • If timingGlobal is "client", then set timingGlobal to + request's client's global object. +

  • Let timingInfo be a new fetch timing info whose start time and post-redirect start time are the @@ -4313,11 +4337,15 @@ steps:

  • Set fetchParams's request's done flag. -

  • Let global be fetchParams's timing global. -

  • -

    If global is not null, then queue a fetch task given - global to run the following steps: +

    If fetchParams's request's + destination is "document", then set fetchParams's + controller's full timing info to + fetchParams's timing info. + +

    Set fetchParams's controller's report timing steps to the following steps given a global object global:

    1. If fetchParams's request's URL's @@ -4340,10 +4368,22 @@ steps:

      This covers the case of response being a network error.

    2. -
    3. Mark resource timing for timingInfo, request's +

    4. If fetchParams's initiator type is not null, then + mark resource timing for timingInfo, request's URL, fetchParams's initiator type, global, cacheState, and bodyInfo.

    + +
  • Let global be fetchParams's timing global. + +

  • +

    If fetchParams's initiator type is not null and + fetchParams's timing global is not null, then + queue a fetch task to run fetchParams's controller's + report timing steps given fetchParams's + timing global and fetchParams's + initiator type, withfetchParams's + timing global.

  • If fetchParams's process response end-of-body is not @@ -8183,8 +8223,8 @@ in a parallel queue if useParallelQueue is as arguments will be invoked. Hopefully most standards will not need this.

    initiatorType -

    Takes a string that defaults to "other", to indicate the - {{PerformanceResourceTiming/initiatorType}} for Resource Timing. [[RESOURCE-TIMING]] +

    Takes null or a string, to indicate the {{PerformanceResourceTiming/initiatorType}} for + Resource Timing. If not given, the entry is not reported. [[RESOURCE-TIMING]]

    timingGlobal

    Takes "client", "none" or a global object (default From 9a9b6cceb41eb89a460c21442d154a272d9aae60 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 27 May 2022 10:47:50 +0100 Subject: [PATCH 20/31] Explicit ID --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index b713c833a..614062334 100644 --- a/fetch.bs +++ b/fetch.bs @@ -248,8 +248,8 @@ lt="authentication entry">authentication entries (for HTTP authentication).

  • Call this's report timing steps with global. -

    To extract full timing info given a -fetch controller controller: +

    To extract full timing info +given a fetch controller controller:

    1. Assert: this's full timing info is not null. From f35a7bce3b686459d7be3e3748b9abba3077dc0d Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 27 May 2022 11:09:20 +0100 Subject: [PATCH 21/31] nits --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index 614062334..f6f207292 100644 --- a/fetch.bs +++ b/fetch.bs @@ -3803,8 +3803,8 @@ an optional boolean useParallelQueue (def optional null or string initiatorType (default null), and an optional "client" or a global object timingGlobal (default "client"), run the steps -below. If given, processRequestBodyChunkLength must be an algorithm acceptin an integer -representing the number of bytes transmitted. If given processRequestEndOfBody must be an +below. If given, processRequestBodyChunkLength must be an algorithm accepting an integer +representing the number of bytes transmitted. If given, processRequestEndOfBody must be an algorithm accepting no arguments. If given, processEarlyHintsResponse must be an algorithm accepting a response. If given, processResponse must be an algorithm accepting a response. If given, processResponseEndOfBody must be From 4bd90b1cf57c32d5aa38ae96d0b3737393a80776 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Fri, 27 May 2022 17:02:48 +0100 Subject: [PATCH 22/31] PR nits --- fetch.bs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fetch.bs b/fetch.bs index f6f207292..d4069fc6d 100644 --- a/fetch.bs +++ b/fetch.bs @@ -3845,8 +3845,13 @@ the request.

    2. Set crossOriginIsolatedCapability to request's client's cross-origin isolated capability. + +

    3. Set timingGlobal to request's client's + global object.

    +
  • Assert: timingGlobal is null or a global object. +

  • If useParallelQueue is true, then set taskDestination to the result of starting a new parallel queue. @@ -3855,10 +3860,6 @@ the request. wanting to do a ping without request body might do so as well, but if you do have a request body you definitely need this as otherwise transmit-request-body loop breaks down. --> -

  • If timingGlobal is "client", then set timingGlobal to - request's client's global object. -

  • Let timingInfo be a new fetch timing info whose start time and post-redirect start time are the @@ -4343,9 +4344,9 @@ steps: controller's full timing info to fetchParams's timing info. -

    Set fetchParams's controller's report timing steps to the following steps given a global object global: +

    Set fetchParams's controller's + report timing steps to the following steps given a + global object global:

    1. If fetchParams's request's URL's From 37e09f6da76fdbd5a38806160a397d7296e0f152 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 30 May 2022 14:40:32 +0100 Subject: [PATCH 23/31] Move to own li --- fetch.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fetch.bs b/fetch.bs index d4069fc6d..32bb903b0 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4338,12 +4338,12 @@ steps:

    2. Set fetchParams's request's done flag. -

    3. -

      If fetchParams's request's - destination is "document", then set fetchParams's - controller's full timing info to - fetchParams's timing info. +

    4. If fetchParams's request's + destination is "document", then set fetchParams's + controller's full timing info to + fetchParams's timing info. +

    5. Set fetchParams's controller's report timing steps to the following steps given a global object global: From 6af3b82e100d2c7ab3fd7d738ee5b54c02674006 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 7 Jun 2022 17:19:17 +0100 Subject: [PATCH 24/31] Fix PR nits --- fetch.bs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/fetch.bs b/fetch.bs index 32bb903b0..09bfd10ab 100644 --- a/fetch.bs +++ b/fetch.bs @@ -300,9 +300,9 @@ information needed by Resource Timing and Navigation Timingitems: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]

      -
      encoded body +
      encoded size (default 0) -
      decoded body +
      decoded size (default 0)
      A number.
      @@ -3801,7 +3801,7 @@ algorithm processResponseEndOfBody, an op processResponseConsumeBody, an optional boolean useParallelQueue (default false), an optional null or string initiatorType (default null), -and an optional "client" or a global object +and an optional "client", "none", or a global object timingGlobal (default "client"), run the steps below. If given, processRequestBodyChunkLength must be an algorithm accepting an integer representing the number of bytes transmitted. If given, processRequestEndOfBody must be an @@ -3850,7 +3850,7 @@ the request. global object.
    -
  • Assert: timingGlobal is null or a global object. +

  • Assert: timingGlobal is "none" or a global object.

  • If useParallelQueue is true, then set taskDestination to the result of starting a new parallel queue. @@ -4354,7 +4354,7 @@ steps:

  • Set timingInfo's end time to the relative high resolution time given unsafeEndTime and - global.

  • + global.
  • Let cacheState be response's cache state. @@ -4367,7 +4367,6 @@ steps: set cacheState to the empty string.

    This covers the case of response being a network error. -

  • If fetchParams's initiator type is not null, then mark resource timing for timingInfo, request's @@ -4379,10 +4378,10 @@ steps:

  • If fetchParams's initiator type is not null and - fetchParams's timing global is not null, then - queue a fetch task to run fetchParams's controller's - report timing steps given fetchParams's - timing global and fetchParams's + fetchParams's timing global is not "none", + then queue a fetch task to run fetchParams's + controller's report timing steps given + fetchParams's timing global and fetchParams's initiator type, withfetchParams's timing global.

  • @@ -5704,7 +5703,7 @@ optional boolean forceNewConnection (default false), run these steps: `Content-Encoding` and response's header list.
  • Increase response's body info's - encoded body size by bytes's + encoded size by bytes's length.

  • @@ -5715,7 +5714,7 @@ optional boolean forceNewConnection (default false), run these steps: unreliable to the extent that it was reliable to begin with.
  • Increase response's body info's - decoded body size by + decoded size by bytes's length.

  • If bytes is failure, then terminate From 43be574b0224ea00b103b6394397a45258608a6c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 7 Jun 2022 18:36:00 +0100 Subject: [PATCH 25/31] Associate initiator type with request --- fetch.bs | 93 +++++++++++++++++++++++--------------------------------- 1 file changed, 38 insertions(+), 55 deletions(-) diff --git a/fetch.bs b/fetch.bs index 09bfd10ab..2313ea44f 100644 --- a/fetch.bs +++ b/fetch.bs @@ -205,12 +205,6 @@ lt="authentication entry">authentication entries (for HTTP authentication).

    task destination (default null)
    Null, a global object, or a parallel queue. -
    initiator type (default null) -
    Null or a string. - -
    timing global (default null) -
    Null or a global object. -
    cross-origin isolated capability (default false)
    A boolean. @@ -1426,6 +1420,10 @@ this flag set are subject to additional processing requirements.

    A request has an associated service-workers mode, that is "all" or "none". Unless stated otherwise it is "all". +

    A request has an associated null or string +initiator type. Unless stated otherwise it is null. +[[RESOURCE-TIMING]] +

    This determines which service workers will receive a {{fetch!!event}} event for this fetch. @@ -2114,11 +2112,6 @@ string. -

    A response has an associated -body info -(a response body info). Unless stated otherwise, it is a new -response body info. -

    A response has an associated CORS-exposed header-name list (a list of zero or more header @@ -2149,6 +2142,11 @@ allowed on the resource fetched by looking at the flag of the response returned. the response of a redirect has to be set if it was set for previous responses in the redirect chain, this is also tracked internally using the request's timing allow failed flag. +

    A response has an associated +body info +(a response body info). Unless stated otherwise, it is a new +response body info. +

    A response has an associated service worker timing info (null or a service worker timing info), which is initially null. @@ -3799,17 +3797,15 @@ an optional algorithm processEarlyHintsResponse algorithm processResponse, an optional algorithm processResponseEndOfBody, an optional algorithm processResponseConsumeBody, -an optional boolean useParallelQueue (default false), an -optional null or string initiatorType (default null), -and an optional "client", "none", or a global object -timingGlobal (default "client"), run the steps -below. If given, processRequestBodyChunkLength must be an algorithm accepting an integer -representing the number of bytes transmitted. If given, processRequestEndOfBody must be an -algorithm accepting no arguments. If given, processEarlyHintsResponse must be an -algorithm accepting a response. If given, processResponse must be an -algorithm accepting a response. If given, processResponseEndOfBody must be -an algorithm accepting a response. If given, processResponseConsumeBody must -be an algorithm accepting a response and null, failure, or a byte sequence. +and an optional boolean useParallelQueue (default false), run +the steps below. If given, processRequestBodyChunkLength must be an algorithm accepting +an integer representing the number of bytes transmitted. If given, +processRequestEndOfBody must be an algorithm accepting no arguments. If given, +processEarlyHintsResponse must be an algorithm accepting a response. If +given, processResponse must be an algorithm accepting a response. If given, +processResponseEndOfBody must be an algorithm accepting a response. If +given, processResponseConsumeBody must be an algorithm accepting a response +and null, failure, or a byte sequence.

    The user agent may be asked to suspend the ongoing fetch. @@ -3845,13 +3841,8 @@ the request.

  • Set crossOriginIsolatedCapability to request's client's cross-origin isolated capability. - -

  • Set timingGlobal to request's client's - global object. -

  • Assert: timingGlobal is "none" or a global object. -

  • If useParallelQueue is true, then set taskDestination to the result of starting a new parallel queue. @@ -3869,8 +3860,6 @@ the request. request is request, timing info is timingInfo, controller is controller, - initiator type is initiatorType, - timing global is timingGlobal, process request body chunk length is processRequestBodyChunkLength, process request end-of-body is processRequestEndOfBody, @@ -4368,23 +4357,24 @@ steps:

    This covers the case of response being a network error. -

  • If fetchParams's initiator type is not null, then - mark resource timing for timingInfo, request's - URL, fetchParams's initiator type, - global, cacheState, and bodyInfo. +

  • If fetchParams's request's + initiator type is not null, then + mark resource timing given timingInfo, request's + URL, request's + initiator type, global, cacheState, and + bodyInfo. -

  • Let global be fetchParams's timing global. +

  • Let client be fetchParams's request's + client. -

  • -

    If fetchParams's initiator type is not null and - fetchParams's timing global is not "none", - then queue a fetch task to run fetchParams's - controller's report timing steps given - fetchParams's timing global and fetchParams's - initiator type, withfetchParams's - timing global. -

  • +
  • If fetchParams's request's + initiator type is not null and client is not null, then + queue a fetch task to run fetchParams's controller's + report timing steps given client's + global object and request's + initiator type, with client's + global object.

  • If fetchParams's process response end-of-body is not null, then queue a fetch task to run fetchParams's @@ -7084,6 +7074,9 @@ constructor steps are:

    URL list
    A clone of request's URL list. + +
    initiator type +
    "fetch".
  • @@ -7735,8 +7728,8 @@ method steps are:
  • Set controller to the result of calling fetch given - request, with initiatorType set to "fetch, and - processResponse given response being these substeps: + request and processResponse given response being + these substeps:

    1. If locallyAborted is true, terminate these substeps. @@ -8221,16 +8214,6 @@ in a parallel queue if useParallelQueue is

      useParallelQueue

      Takes a boolean that defaults to false. Indicates where the algorithms passed as arguments will be invoked. Hopefully most standards will not need this. - -

      initiatorType -

      Takes null or a string, to indicate the {{PerformanceResourceTiming/initiatorType}} for - Resource Timing. If not given, the entry is not reported. [[RESOURCE-TIMING]] - -

      timingGlobal -

      Takes "client", "none" or a global object (default - "client"). Indicates which global object is used for enqueuing the - {{PerformanceResourceTiming}} entry. If "none" is passed, the entry is not reported. - [[RESOURCE-TIMING]]

      When invoked, the fetch operation returns a fetch controller. The From 448f3ae666776bb72de64cb7016b01bf60237e34 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Thu, 9 Jun 2022 11:25:16 +0100 Subject: [PATCH 26/31] Spell out initiator-type values --- fetch.bs | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/fetch.bs b/fetch.bs index 2313ea44f..6a16be303 100644 --- a/fetch.bs +++ b/fetch.bs @@ -1420,9 +1420,29 @@ this flag set are subject to additional processing requirements.

      A request has an associated service-workers mode, that is "all" or "none". Unless stated otherwise it is "all". -

      A request has an associated null or string -initiator type. Unless stated otherwise it is null. -[[RESOURCE-TIMING]] +

      A request has an associated +initiator type, which is null, +"audio", +"beacon", +"body", +"css", +"early-hint", +"embed", +"fetch", +"font", +"frame", +"iframe", +"image", +"img", +"input", +"link", +"object", +"ping", +"script", +"track", +"video", +"xmlhttprequest", or +"other". Unless stated otherwise it is null. [[RESOURCE-TIMING]]

      This determines which service workers will receive a {{fetch!!event}} event for this fetch. From 53f81ca3f1db764c42f4f35a54573146bd8b5734 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 14 Jun 2022 10:17:52 +0100 Subject: [PATCH 27/31] Change normative back to note --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index 6a16be303..8d2858556 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5298,8 +5298,8 @@ steps. They return a response.

      If forwardResponse is a network error, this effectively caches the network error, which is sometimes known as "negative caching". -

      The user agent should store forwardResponse's body info - as part of the response. +

      The associated body info is stored in the cache + alongside the response.

    From c5614debf15d979a27a22371afb192bb58c29fb1 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 14 Jun 2022 10:45:11 +0100 Subject: [PATCH 28/31] Dedup end-of-body task --- fetch.bs | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/fetch.bs b/fetch.bs index 8d2858556..b2ccbad76 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4344,9 +4344,6 @@ steps:
    1. Let unsafeEndTime be the unsafe shared current time. -

    2. Set fetchParams's request's - done flag. -

    3. If fetchParams's request's destination is "document", then set fetchParams's controller's full timing info to @@ -4385,20 +4382,28 @@ steps: bodyInfo.

    -
  • Let client be fetchParams's request's - client. +

  • +

    Let processResponseEndOfBodyTask be the following steps: -

  • If fetchParams's request's - initiator type is not null and client is not null, then - queue a fetch task to run fetchParams's controller's - report timing steps given client's - global object and request's - initiator type, with client's - global object. +

      +
    1. If fetchParams's process response end-of-body is + not null, then call fetchParams's + process response end-of-body given response. + +

    2. If fetchParams's request's + initiator type is not null and fetchParams's + request's client is not null, then + run fetchParams's controller's + report timing steps given fetchParams's + request's client's + global object and request's + initiator type. + +

    3. Set fetchParams's request's + done flag. +

    -
  • If fetchParams's process response end-of-body is not - null, then queue a fetch task to run fetchParams's - process response end-of-body given response with +

  • Queue a fetch task to run processResponseEndOfBodyTask with fetchParams's task destination.

  • From ff7190ccf9f3a6293ceffcfa63d1115605e32846 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Tue, 14 Jun 2022 13:59:53 +0200 Subject: [PATCH 29/31] nits --- fetch.bs | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/fetch.bs b/fetch.bs index b2ccbad76..bdcbb5596 100644 --- a/fetch.bs +++ b/fetch.bs @@ -237,7 +237,8 @@ lt="authentication entry">authentication entries (for HTTP authentication). fetch controller controller given a global object global:
      -
    1. Assert: this's report timing steps is not null. +

    2. Assert: this's report timing steps is not + null.

    3. Call this's report timing steps with global.

    @@ -246,7 +247,8 @@ lt="authentication entry">authentication entries (for HTTP authentication). given a fetch controller controller:
      -
    1. Assert: this's full timing info is not null. +

    2. Assert: this's full timing info is not + null.

    3. Return this's full timing info.

    @@ -1443,6 +1445,8 @@ is "all" or "none". Unless stated otherwise it is "video", "xmlhttprequest", or "other". Unless stated otherwise it is null. [[RESOURCE-TIMING]] +

    This determines which service workers will receive a {{fetch!!event}} event for this fetch. @@ -4369,7 +4373,7 @@ steps:

  • If response's timing allow passed flag is not set, then set timingInfo to a the result of creating an opaque timing info for - timingInfo, set bodyInfo to a new response body info and + timingInfo, set bodyInfo to a new response body info, and set cacheState to the empty string.

    This covers the case of response being a network error. @@ -4386,21 +4390,21 @@ steps:

    Let processResponseEndOfBodyTask be the following steps:

      +
    1. Set fetchParams's request's + done flag. +

    2. If fetchParams's process response end-of-body is - not null, then call fetchParams's + non-null, then run fetchParams's process response end-of-body given response.

    3. If fetchParams's request's - initiator type is not null and fetchParams's - request's client is not null, then - run fetchParams's controller's + initiator type is non-null and fetchParams's + request's client is non-null, then run + fetchParams's controller's report timing steps given fetchParams's request's client's global object and request's initiator type. - -

    4. Set fetchParams's request's - done flag.

  • Queue a fetch task to run processResponseEndOfBodyTask with From 622c6046cab375acd7bef791dc7354a1570e6075 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 15 Jun 2022 09:43:38 +0100 Subject: [PATCH 30/31] Remove leftover arg --- fetch.bs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index bdcbb5596..16f9dbe83 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4403,8 +4403,7 @@ steps: fetchParams's controller's report timing steps given fetchParams's request's client's - global object and request's - initiator type. + global object.

  • Queue a fetch task to run processResponseEndOfBodyTask with From 9f0745ab2d82b65071778acaaf24196681031396 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 15 Jun 2022 10:17:50 +0100 Subject: [PATCH 31/31] Account for sync XHR --- fetch.bs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fetch.bs b/fetch.bs index 16f9dbe83..941244e99 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4399,10 +4399,11 @@ steps:

  • If fetchParams's request's initiator type is non-null and fetchParams's - request's client is non-null, then run - fetchParams's controller's - report timing steps given fetchParams's request's client's + global object is fetchParams's + task destination, then run fetchParams's + controller's report timing steps given + fetchParams's request's client's global object.