Skip to content

Commit 233c9db

Browse files
committed
Add network.setCacheMode command
This currently only allows setting the request cache mode to 'no-store' which bypasses the cache entirely. If we have future use cases for setting different cache modes, this appraoch would be extensible to those use cases.
1 parent 05a283e commit 233c9db

File tree

1 file changed

+93
-2
lines changed

1 file changed

+93
-2
lines changed

index.bs

Lines changed: 93 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4689,7 +4689,8 @@ NetworkCommand = (
46894689
network.ContinueWithAuth //
46904690
network.FailRequest //
46914691
network.ProvideResponse //
4692-
network.RemoveIntercept
4692+
network.RemoveIntercept //
4693+
network.SetCacheMode //
46934694
)
46944695

46954696
</pre>
@@ -4716,6 +4717,13 @@ A [=remote end=] has a <dfn>before request sent map</dfn> which is initially an
47164717
empty map. It's used to track the network events for which a
47174718
<code>network.beforeRequestSent</code> event has already been sent.
47184719

4720+
A [=remote end=] has a <dfn>default cache mode override</dfn> which is null or a
4721+
string. It is initially null.
4722+
4723+
A [=remote end=] has a <dfn>cache mode override map</dfn> which is initially an
4724+
empty weak map. It's used to track the cache mode to use for requests from
4725+
specific browsing contexts.
4726+
47194727
### Network Intercepts ### {#network-intercepts}
47204728

47214729
A <dfn>network intercept</dfn> is a mechanism to allow remote ends to intercept
@@ -4972,7 +4980,6 @@ request in addition to the context.
49724980
<div algorithm>
49734981
To <dfn>process a network event</dfn> given |session|, |event|, and |request|:
49744982

4975-
49764983
1. Let |request data| be the result of [=get the request data=] with |request|.
49774984

49784985
<!-- TODO: update this to "[=request/navigation id=] once the fetch parts land-->
@@ -6554,6 +6561,90 @@ requests will be affected.
65546561

65556562
</div>
65566563

6564+
#### The network.setCacheMode Command #### {#command-network-setCacheMode}
6565+
6566+
The <dfn export for=commands>network.removeSetCacheMode</dfn> command overrides
6567+
the network cache behaviour for certain requests.
6568+
6569+
<dl>
6570+
<dt>Command Type</dt>
6571+
<dd>
6572+
<pre class="cddl remote-cddl">
6573+
network.SetCacheMode = (
6574+
method: "network.setCacheMode",
6575+
params: network.SetCacheModeParameters
6576+
)
6577+
6578+
network.SetCacheModeParameters = {
6579+
mode: "no-store" / null,
6580+
? contexts: [browsingContext.BrowsingContext]
6581+
}
6582+
</pre>
6583+
</dd>
6584+
<dt>Return Type</dt>
6585+
<dd>
6586+
<pre class="cddl">
6587+
EmptyResult
6588+
</pre>
6589+
</dd>
6590+
</dl>
6591+
6592+
<div algorithm>
6593+
The <dfn export>WebDriver BiDi update request cache mode</dfn> steps given
6594+
|request| are:
6595+
6596+
1. Let |context| be null.
6597+
6598+
1. If |request|'s [=request/window=] is an [=environment settings object=]:
6599+
6600+
1. Let |environment settings| be |request|'s [=request/window=]
6601+
6602+
1. If there is a [=/browsing context=] whose [=active window=] is |environment
6603+
settings|' [=environment settings object/global object=], set |context| to
6604+
the [=top-level browsing context=] for that context.
6605+
6606+
1. If |context| is not null:
6607+
6608+
1. If [=cache mode override map=] [=map/contains=] |context|, set
6609+
|request|&apos;s [=request/cache mode=] to [=cache mode override
6610+
map=][|context|] and return.
6611+
6612+
1. If [=default cache mode override=] is not null, set
6613+
|request|&apos;s [=request/cache mode=] to [=default cache mode override=].
6614+
6615+
</div>
6616+
6617+
<div algorithm="remote end steps for network.setCacheMode">
6618+
The [=remote end steps=] given <var ignore>session</var> and |command parameters| are:
6619+
6620+
1. Let |mode| be |command parameters|["<code>mode</code>"].
6621+
6622+
1. If |command parameters| does not [=map/contain=] "<code>contexts</code>", set
6623+
the [=default cache mode override=] to |mode| and return [=success=] with
6624+
data null.
6625+
6626+
1. Let |contexts| be an empty [=/list=].
6627+
6628+
1. For each |context id| of |command parameters|["<code>contexts</code>"]:
6629+
6630+
1. Let |context| be the result of [=trying=] to [=get a browsing context=]
6631+
with |context id|.
6632+
6633+
1. If |context| is not a [=top-level browsing context=], return [=error=]
6634+
with [=error code=] [=invalid argument=].
6635+
6636+
1. [=list/Append=] |context| to |contexts|.
6637+
6638+
1. For each |context| in |contexts|:
6639+
6640+
1. If |mode| is null and [=cache mode override map=] [=map/contains=]
6641+
|context| [=map/remove=] |context| from [=cache mode override map=].
6642+
6643+
1. Otherwise, set [=cache mode override map=][|context|] to |mode|.
6644+
6645+
1. Return [=success=] with data null.
6646+
6647+
</div>
65576648

65586649
### Events ### {#module-network-event}
65596650

0 commit comments

Comments
 (0)