From 59396464b69b4e54b8ff7cc7ab55e5734319b9ea Mon Sep 17 00:00:00 2001 From: James Graham Date: Fri, 18 Nov 2022 10:20:40 +0000 Subject: [PATCH 1/6] Add WebDriver BiDi network request logging --- fetch.bs | 47 ++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 3 deletions(-) diff --git a/fetch.bs b/fetch.bs index 122efc771..01f0d19b3 100755 --- a/fetch.bs +++ b/fetch.bs @@ -2225,6 +2225,11 @@ Unless stated otherwise, it is false.

This is for exclusive use by HTML's navigate algorithm. [[!HTML]] +

A request has an associated WebDriver navigation id +(null or a string). Unless stated otherwise, it is null. + +

This is for exclusive use by HTML's navigate algorithm. [[!HTML]] +

A request has an associated boolean render-blocking. Unless stated otherwise, it is false. @@ -2266,6 +2271,15 @@ otherwise, it is unset. done flag, and timing allow failed flag are used as bookkeeping details by the fetch algorithm. +

A request has an associated +WebDriver id +which is a unique string automatically set when the request is created. + +

The [=request/WebDriver id=] is used by WebDriver-BiDi. It remains constant +across all requests resulting from a redirect of an initial request. When a +request is [=request/cloned=], the created request gets a unique +[=request/WebDriver id=]. [[!WEBDRIVER-BIDI]] +


A subresource request is a request @@ -2356,7 +2370,9 @@ is to return the result of serializing a request origin with request

  1. Let newRequest be a copy of request, except for its - body. + body and WebDriver id. + +

  2. Set newRequest's WebDriver id to a new unique string.

  3. If request's body is non-null, set newRequest's body to the result of cloning request's @@ -5128,6 +5144,11 @@ steps: URL, fetchParams's request's initiator type, global, cacheState, bodyInfo, and responseStatus. + +

  4. If response is a network error, run + the WebDriver BiDi fetch error steps with request. Otherwise + run the WebDriver BiDi response completed steps with + request and response.

  • @@ -5586,6 +5607,13 @@ these steps: filtered response; otherwise to response's internal response. +
  • Run the [=WebDriver BiDi response started=] steps with + request and response. + +

  • If one of the following is true @@ -5713,8 +5741,12 @@ these steps:

    "follow"
    -
    1. Set response to the result of running HTTP-redirect fetch given - fetchParams and response.

    +
      +
    1. Run the WebDriver BiDi response completed steps with request and + response. +
    2. Set response to the result of running HTTP-redirect fetch given + fetchParams and response. +

    @@ -6120,6 +6152,10 @@ run these steps:

    This intentionally does not depend on httpRequest's credentials mode. + +

  • Run the WebDriver BiDi before request sent steps with request. +

  • Set httpCache to the result of determining the HTTP cache partition, given httpRequest. @@ -6215,6 +6251,8 @@ run these steps:

  • If aborted, then return the appropriate network error for fetchParams. +

  • If response is not null, run the WebDriver BiDi response + started steps with request and response.

  • @@ -6478,6 +6516,9 @@ optional boolean forceNewConnection (default false), run these steps:
  • Wait until all the HTTP response headers are transmitted. +

  • Run the [=WebDriver BiDi response started=] steps with + |request| and |response|. +

  • Let status be the HTTP response's status code.

  • From 97daba07668c46150723e36d88e418623df08c8b Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Wed, 1 Oct 2025 16:43:14 +0200 Subject: [PATCH 2/6] Call webdriver bidi hooks to clone request and response bodies --- fetch.bs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/fetch.bs b/fetch.bs index 01f0d19b3..60280a5f7 100755 --- a/fetch.bs +++ b/fetch.bs @@ -4586,6 +4586,8 @@ the response. [[!HTTP-CACHING]] request's body to request's body as a body. +
  • Run the WebDriver BiDi clone network request body steps with request. +

  • If all of the following conditions are true: @@ -6691,6 +6693,8 @@ optional boolean forceNewConnection (default false), run these steps:

  • Set response's body to a new body whose stream is stream. +

  • Run the WebDriver BiDi clone network response body steps with request and response. +

  • If includeCredentials is true, then the user agent should parse and store response `Set-Cookie` headers given request and response. From 69323066f8065987b260f663912d8500a57fb637 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Tue, 6 Jan 2026 17:17:23 +0100 Subject: [PATCH 3/6] Preserve webdriver id for CORS preflight --- fetch.bs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fetch.bs b/fetch.bs index 60280a5f7..4d51d5f8b 100755 --- a/fetch.bs +++ b/fetch.bs @@ -2276,8 +2276,8 @@ bookkeeping details by the fetch algorithm. which is a unique string automatically set when the request is created.

    The [=request/WebDriver id=] is used by WebDriver-BiDi. It remains constant -across all requests resulting from a redirect of an initial request. When a -request is [=request/cloned=], the created request gets a unique +across redirects, authentication attempts, and CORS-preflight fetches of an initial request. +When a request is [=request/cloned=], the created request gets a unique [=request/WebDriver id=]. [[!WEBDRIVER-BIDI]]


    @@ -6835,8 +6835,9 @@ populates the CORS-preflight cache to minimize the number of these origin is request's origin, referrer is request's referrer, referrer policy is request's referrer policy, - mode is "cors", and - response tainting is "cors". + mode is "cors", + response tainting is "cors", and + WebDriver id is request's WebDriver id.

    The service-workers mode of preflight does not matter as this algorithm uses HTTP-network-or-cache fetch rather than HTTP fetch. From 8001baa49ced4473b5ff34676e8a2961a1e72103 Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Tue, 6 Jan 2026 17:29:50 +0100 Subject: [PATCH 4/6] Fix inconsistencies after rebase --- fetch.bs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/fetch.bs b/fetch.bs index 4d51d5f8b..ae62eb0da 100755 --- a/fetch.bs +++ b/fetch.bs @@ -5609,9 +5609,9 @@ these steps: filtered response; otherwise to response's internal response. -

  • Run the [=WebDriver BiDi response started=] steps with +

  • Run the WebDriver BiDi response started steps with request and response. - @@ -6518,8 +6518,8 @@ optional boolean forceNewConnection (default false), run these steps:

  • Wait until all the HTTP response headers are transmitted. -

  • Run the [=WebDriver BiDi response started=] steps with - |request| and |response|. +

  • Run the WebDriver BiDi response started steps with + request and response.

  • Let status be the HTTP response's status code. From 59a91b060726dbef9b825f865cc6df77681c9aed Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Tue, 6 Jan 2026 18:12:17 +0100 Subject: [PATCH 5/6] Call WebDriver BiDi fetch error and response completed regardless of client consuming the body --- fetch.bs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fetch.bs b/fetch.bs index ae62eb0da..007035e01 100755 --- a/fetch.bs +++ b/fetch.bs @@ -5146,11 +5146,6 @@ steps: URL, fetchParams's request's initiator type, global, cacheState, bodyInfo, and responseStatus. - -

  • If response is a network error, run - the WebDriver BiDi fetch error steps with request. Otherwise - run the WebDriver BiDi response completed steps with - request and response.

  • @@ -5187,6 +5182,11 @@ steps: network error; otherwise response's internal response. +
  • If response is a network error, run + the WebDriver BiDi fetch error steps with request. Otherwise + run the WebDriver BiDi response completed steps with + request and response. +

  • If internalResponse's body is null, then run processResponseEndOfBody. From f3a2ae3d26c9df8809aa26a06bc5b4918388748c Mon Sep 17 00:00:00 2001 From: Julian Descottes Date: Tue, 17 Feb 2026 17:39:41 +0100 Subject: [PATCH 6/6] Address review comments --- fetch.bs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/fetch.bs b/fetch.bs index 007035e01..dab7ed6ce 100755 --- a/fetch.bs +++ b/fetch.bs @@ -2273,7 +2273,8 @@ bookkeeping details by the fetch algorithm.

    A request has an associated WebDriver id -which is a unique string automatically set when the request is created. +which is the result of generating a random UUID, set when the request is +created. [[WEBCRYPTO]]

    The [=request/WebDriver id=] is used by WebDriver-BiDi. It remains constant across redirects, authentication attempts, and CORS-preflight fetches of an initial request. @@ -2372,7 +2373,8 @@ is to return the result of serializing a request origin with request

  • Let newRequest be a copy of request, except for its body and WebDriver id. -

  • Set newRequest's WebDriver id to a new unique string. +

  • Set newRequest's WebDriver id to the result of + generating a random UUID. [[WEBCRYPTO]]

  • If request's body is non-null, set newRequest's body to the result of cloning request's @@ -5182,8 +5184,8 @@ steps: network error; otherwise response's internal response. -

  • If response is a network error, run - the WebDriver BiDi fetch error steps with request. Otherwise +

  • If response is a network error, then run + the WebDriver BiDi fetch error steps with request. Otherwise, run the WebDriver BiDi response completed steps with request and response. @@ -6253,7 +6255,7 @@ run these steps:

  • If aborted, then return the appropriate network error for fetchParams. -

  • If response is not null, run the WebDriver BiDi response +

  • If response is not null, then run the WebDriver BiDi response started steps with request and response.