From 19bc2003ec7bc3151d22d066ef06af4fdaf9f5dc Mon Sep 17 00:00:00 2001 From: Keita Suzuki Date: Thu, 29 May 2025 13:04:13 +0900 Subject: [PATCH 1/3] Update HTTPFetch algorithm to support new SW Handle Fetch returns This will update the HttpFetch algorithm, particularly the handling of the response for Service Worker fetch (`handle fetch` step). Currently, the response of handle fetch step is assumed to return the `response` type (or null, if the ServiceWorker couldn't handle the fetch and need to fallback to the network request). However, we have changed the `handle fetch` step to also return `service worker timing info` when the ServiceWorker static routing API used, so that the corresponding timing information are correctly exposed when the ServiceWorker could not handle the fetch. To support this new return type, we need to update the handling of the response of `handle fetch`. To expose the Service Worker Timing Info to the resource timing API, we also associate them to the Fetch Timing Info so that it could be later referenced. --- fetch.bs | 67 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 27 deletions(-) diff --git a/fetch.bs b/fetch.bs index 727982cb8..f6b001ef8 100644 --- a/fetch.bs +++ b/fetch.bs @@ -352,6 +352,9 @@ following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
final connection timing info (default null)
Null or a connection timing info. +
service worker timing info (default null) +
Null or a service worker timing info. +
server-timing headers (default « »)
A list of strings.
render-blocking (default false) @@ -5248,48 +5251,57 @@ these steps:
  • Let serviceWorkerStartTime be the coarsened shared current time given fetchParams's cross-origin isolated capability. -

  • Set response to the result of invoking handle fetch for +

  • Let fetchResponse be the result of invoking handle fetch for requestForServiceWorker, with fetchParams's controller and fetchParams's cross-origin isolated capability. [[!HTML]] [[!SW]]

  • -

    If response is non-null, then: -

      -
    1. Set fetchParams's timing info's - final service worker start time to - serviceWorkerStartTime. +

      If fetchResponse is non-null, then: +

      IffetchResponse is response, then: +

        +
      1. Set response to fetchResponse. +

      2. Set fetchParams's timing info's + final service worker start time to + serviceWorkerStartTime. +

      3. Set fetchParams's timing info's + service worker timing info to + response's service worker timing info. -

      4. If request's body is non-null, then - cancel request's body with undefined. +
      5. If request's body is non-null, then + cancel request's body with undefined. -
      6. Set internalResponse to response, if response is not a - filtered response; otherwise to response's - internal response. +

      7. Set internalResponse to response, if response is not a + filtered response; otherwise to response's + internal response. -

      8. -

        If one of the following is true +

      9. +

        If one of the following is true -

          -
        • response's type is "error" +

            +
          • response's type is "error" -

          • request's mode is "same-origin" and - response's type is "cors" +

          • request's mode is "same-origin" and + response's type is "cors" -

          • request's mode is not "no-cors" and - response's type is "opaque" +

          • request's mode is not "no-cors" and + response's type is "opaque" -

          • request's redirect mode is not "manual" and - response's type is "opaqueredirect" +
          • request's redirect mode is not "manual" and + response's type is "opaqueredirect" -
          • request's redirect mode is not "follow" and - response's URL list has more than one item. -
          +
        • request's redirect mode is not "follow" and + response's URL list has more than one item. +
        -

        then return a network error. -

      -
    +

    then return a network error. + +

    IffetchResponse is service worker timing info, then: +

  • Set fetchParams's timing info's + service worker timing info to + fetchResponse. +

  • If response is null, then: @@ -9220,6 +9232,7 @@ Julian Reschke, Jussi Kalliokoski, Jxck, Kagami Sascha Rosylight, +Keita Suzuki, Keith Yeung, Kenji Baheux, Lachlan Hunt, From 074f3c0fe6cb7aa1b83f66c2814d315c77d69b7e Mon Sep 17 00:00:00 2001 From: Keita Suzuki Date: Fri, 30 May 2025 10:28:44 +0900 Subject: [PATCH 2/3] Fix formatting errors --- fetch.bs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fetch.bs b/fetch.bs index f6b001ef8..773eb883a 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5259,7 +5259,7 @@ these steps:

  • If fetchResponse is non-null, then: -

    IffetchResponse is response, then: +

  • IffetchResponse is response, then:

    1. Set response to fetchResponse.

    2. Set fetchParams's timing info's @@ -5297,10 +5297,12 @@ these steps:

      then return a network error.

    -

    IffetchResponse is service worker timing info, then: -

  • Set fetchParams's timing info's - service worker timing info to - fetchResponse. +

  • IffetchResponse is service worker timing info, then: +

      +
    1. Set fetchParams's timing info's + service worker timing info to + fetchResponse. +

  • From 4bc0bf3a2e73f1f2c1c6ea169636b9a09d6b3f59 Mon Sep 17 00:00:00 2001 From: Keita Suzuki Date: Fri, 30 May 2025 10:35:41 +0900 Subject: [PATCH 3/3] Add ordered list to indent an algorithm --- fetch.bs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fetch.bs b/fetch.bs index 773eb883a..1ce95c6d5 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5259,6 +5259,7 @@ these steps:
  • If fetchResponse is non-null, then: +

    1. IffetchResponse is response, then:

      1. Set response to fetchResponse. @@ -5303,6 +5304,7 @@ these steps: service worker timing info to fetchResponse.

      +