Skip to content

Commit aeaf0f8

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 c29a684 commit aeaf0f8

File tree

1 file changed

+93
-2
lines changed

1 file changed

+93
-2
lines changed

index.bs

+93-2
Original file line numberDiff line numberDiff line change
@@ -4597,7 +4597,8 @@ NetworkCommand = (
45974597
network.ContinueWithAuth //
45984598
network.FailRequest //
45994599
network.ProvideResponse //
4600-
network.RemoveIntercept
4600+
network.RemoveIntercept //
4601+
network.SetCacheMode //
46014602
)
46024603

46034604
</pre>
@@ -4624,6 +4625,13 @@ A [=remote end=] has a <dfn>before request sent map</dfn> which is initially an
46244625
empty map. It's used to track the network events for which a
46254626
<code>network.beforeRequestSent</code> event has already been sent.
46264627

4628+
A [=remote end=] has a <dfn>default cache mode override</dfn> which is null or a
4629+
string. It is initially null.
4630+
4631+
A [=remote end=] has a <dfn>cache mode override map</dfn> which is initially an
4632+
empty weak map. It's used to track the cache mode to use for requests from
4633+
specific browsing contexts.
4634+
46274635
### Network Intercepts ### {#network-intercepts}
46284636

46294637
A <dfn>network intercept</dfn> is a mechanism to allow remote ends to intercept
@@ -4870,7 +4878,6 @@ request in addition to the context.
48704878
<div algorithm>
48714879
To <dfn>process a network event</dfn> given |session|, |event|, and |request|:
48724880

4873-
48744881
1. Let |request data| be the result of [=get the request data=] with |request|.
48754882

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

64396446
</div>
64406447

6448+
#### The network.setCacheMode Command #### {#command-network-setCacheMode}
6449+
6450+
The <dfn export for=commands>network.removeSetCacheMode</dfn> command overrides
6451+
the network cache behaviour for certain requests.
6452+
6453+
<dl>
6454+
<dt>Command Type</dt>
6455+
<dd>
6456+
<pre class="cddl remote-cddl">
6457+
network.SetCacheMode = (
6458+
method: "network.setCacheMode",
6459+
params: network.SetCacheModeParameters
6460+
)
6461+
6462+
network.SetCacheModeParameters = {
6463+
mode: "no-store" / null,
6464+
? contexts: [browsingContext.BrowsingContext]
6465+
}
6466+
</pre>
6467+
</dd>
6468+
<dt>Return Type</dt>
6469+
<dd>
6470+
<pre class="cddl">
6471+
EmptyResult
6472+
</pre>
6473+
</dd>
6474+
</dl>
6475+
6476+
<div algorithm>
6477+
The <dfn export>WebDriver BiDi update request cache mode</dfn> steps given
6478+
|request| are:
6479+
6480+
1. Let |context| be null.
6481+
6482+
1. If |request|'s [=request/window=] is an [=environment settings object=]:
6483+
6484+
1. Let |environment settings| be |request|'s [=request/window=]
6485+
6486+
1. If there is a [=/browsing context=] whose [=active window=] is |environment
6487+
settings|' [=environment settings object/global object=], set |context| to
6488+
the [=top-level browsing context=] for that context.
6489+
6490+
1. If |context| is not null:
6491+
6492+
1. If [=cache mode override map=] [=map/contains=] |context|, set
6493+
|request|&apos;s [=request/cache mode=] to [=cache mode override
6494+
map=][|context|] and return.
6495+
6496+
1. If [=default cache mode override=] is not null, set
6497+
|request|&apos;s [=request/cache mode=] to [=default cache mode override=].
6498+
6499+
</div>
6500+
6501+
<div algorithm="remote end steps for network.setCacheMode">
6502+
The [=remote end steps=] given <var ignore>session</var> and |command parameters| are:
6503+
6504+
1. Let |mode| be |command parameters|["<code>mode</code>"].
6505+
6506+
1. If |command parameters| does not [=map/contain=] "<code>contexts</code>", set
6507+
the [=default cache mode override=] to |mode| and return [=success=] with
6508+
data null.
6509+
6510+
1. Let |contexts| be an empty [=/list=].
6511+
6512+
1. For each |context id| of |command parameters|["<code>contexts</code>"]:
6513+
6514+
1. Let |context| be the result of [=trying=] to [=get a browsing context=]
6515+
with |context id|.
6516+
6517+
1. If |context| is not a [=top-level browsing context=], return [=error=]
6518+
with [=error code=] [=invalid argument=].
6519+
6520+
1. [=list/Append=] |context| to |contexts|.
6521+
6522+
1. For each |context| in |contexts|:
6523+
6524+
1. If |mode| is null and [=cache mode override map=] [=map/contains=]
6525+
|context| [=map/remove=] |context| from [=cache mode override map=].
6526+
6527+
1. Otherwise, set [=cache mode override map=][|context|] to |mode|.
6528+
6529+
1. Return [=success=] with data null.
6530+
6531+
</div>
64416532

64426533
### Events ### {#module-network-event}
64436534

0 commit comments

Comments
 (0)