From d41ef172e120a3e1852d243d36e8f2e66aafb1f7 Mon Sep 17 00:00:00 2001 From: James Graham Date: Fri, 18 Nov 2022 10:20:40 +0000 Subject: [PATCH 1/2] 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 de4606f20..b44c83990 100644 --- a/fetch.bs +++ b/fetch.bs @@ -2156,6 +2156,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. @@ -2197,6 +2202,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 @@ -2273,7 +2287,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 @@ -4829,6 +4845,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.

  • @@ -5170,6 +5191,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 @@ -5297,8 +5325,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. +

    @@ -5704,6 +5736,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. @@ -5799,6 +5835,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.

  • @@ -6062,6 +6100,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 48fc0f93357c440fe83a1431c61cddef73a4915c Mon Sep 17 00:00:00 2001 From: James Graham Date: Wed, 29 May 2024 12:21:46 +0100 Subject: [PATCH 2/2] Allow WebDriver BiDi to override the cache mode The primary use case here is allowing WebDriver to enforce that requests do not use the network cache, including the CORS preflight cache. But for future extension the this works by calling into WebDriver BiDi to get a cache behavior for the request, which is then translated into specific implementation on the fetch side (e.g. setting the request's cache mode, or not using the preflight cache). For now the only possible values of the cache behavior are "default" and "bypass", so we only need to check for the latter value. --- fetch.bs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index b44c83990..9127c50c2 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5237,6 +5237,8 @@ these steps:
  • There is at least one item in the CORS-unsafe request-header names with request's header list for which there is no header-name cache entry match using request. + +
  • WebDriver BiDi cache behavior with request is "bypass".

    Then: @@ -5615,6 +5617,9 @@ run these steps: default `User-Agent` value) to httpRequest's header list. +

  • If WebDriver BiDi cache behavior with request is "bypass, then + set httpRequest's cache mode to "no-store". +

  • If httpRequest's cache mode is "default" and httpRequest's header list contains `If-Modified-Since`, @@ -6495,8 +6500,9 @@ populates the CORS-preflight cache to minimize the number of these

  • If max-age is greater than an imposed limit on max-age, then set max-age to the imposed limit. -

  • If the user agent does not provide for a cache, then - return response. +

  • If the user agent does not provide for a cache, + or WebDriver BiDi cache behavior with request is "bypass", + then return response.

  • For each method in methods for which there is a method cache entry match using request, set matching entry's