Skip to content

Commit 42d52fc

Browse files
emulation.setNetworkConditions
1 parent f1d6555 commit 42d52fc

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed

index.bs

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1541,6 +1541,14 @@ A [=BiDi session=] has a
15411541
A [=BiDi session=] has a <dfn>user context to proxy configuration map</dfn>, which is
15421542
a [=/map=] between [=user contexts=] and [=proxy configuration=].
15431543

1544+
An <dfn>emulated network conditions struct</dfn> is a [=struct=] with:
1545+
* [=struct/item=] named <dfn id="emulated-network-conditions-struct-offline"
1546+
for="emulated-network-conditions-struct">offline</dfn> which is a boolean or null.
1547+
1548+
A [=BiDi session=] has an <dfn>emulated network conditions map</dfn>, which is a weak
1549+
map between [=navigables=] or [=user contexts=] and
1550+
[=emulated network conditions struct=] or null.
1551+
15441552
When a [=user context=] is [=set/remove|removed=] from the
15451553
[=set of user contexts=], [=remove user context subscriptions=].
15461554

@@ -5825,6 +5833,7 @@ EmulationCommand = (
58255833
emulation.SetForcedColorsModeThemeOverride //
58265834
emulation.SetGeolocationOverride //
58275835
emulation.SetLocaleOverride //
5836+
emulation.SetNetworkConditions //
58285837
emulation.SetScreenOrientationOverride //
58295838
emulation.SetScriptingEnabled //
58305839
emulation.SetTimezoneOverride //
@@ -6163,6 +6172,86 @@ The [=remote end steps=] with |command parameters| are:
61636172

61646173
</div>
61656174

6175+
#### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions}
6176+
6177+
The <dfn export for=commands>emulation.setNetworkConditions</dfn> command
6178+
emulates specific network conditions for the given browsing context or for a user
6179+
context.
6180+
6181+
<dl>
6182+
<dt>Command Type</dt>
6183+
<dd>
6184+
<pre class="cddl" data-cddl-module="remote-cddl">
6185+
emulation.SetNetworkConditions = (
6186+
method: "emulation.setNetworkConditions",
6187+
params: emulation.setNetworkConditionsParameters
6188+
)
6189+
6190+
emulation.setNetworkConditionsParameters = {
6191+
networkConditions: emulation.NetworkConditions / null,
6192+
? contexts: [+browsingContext.BrowsingContext],
6193+
? userContexts: [+browser.UserContext],
6194+
}
6195+
6196+
emulation.NetworkConditions = emulation.NetworkConditionsOffline
6197+
6198+
emulation.NetworkConditionsOffline = {
6199+
type: "offline"
6200+
}
6201+
</pre>
6202+
</dd>
6203+
<dt>Result Type</dt>
6204+
<dd>
6205+
<code>
6206+
EmptyResult
6207+
</code>
6208+
</dd>
6209+
</dl>
6210+
6211+
<div algorithm="remote end steps for emulation.setNetworkConditions">
6212+
6213+
The [=remote end steps=] with |command parameters| are:
6214+
6215+
1. If |command parameters| [=map/contains=] "<code>userContexts</code>"
6216+
and |command parameters| [=map/contains=] "<code>context</code>",
6217+
return [=error=] with [=error code=] [=invalid argument=].
6218+
6219+
1. If |command parameters| doesn't [=map/contain=] "<code>userContexts</code>"
6220+
and |command parameters| doesn't [=map/contain=] "<code>context</code>",
6221+
return [=error=] with [=error code=] [=invalid argument=].
6222+
6223+
1. Let |emulated network conditions| be null.
6224+
6225+
1. If |command parameters|["<code>networkConditions</code>"] is not null and
6226+
|command parameters|["<code>networkConditions</code>"]["<code>type</code>"]
6227+
equals "<code>offline</code>", set |emulated network conditions| to a new
6228+
[=emulated network conditions struct=] with
6229+
[=emulated-network-conditions-struct/offline=] set to true.
6230+
6231+
1. If the <code>contexts</code> field of |command parameters| is present:
6232+
6233+
1. Let |navigables| be the result of [=trying=] to
6234+
[=get valid top-level traversables by ids=] with
6235+
|command parameters|["<code>contexts</code>"].
6236+
6237+
1. For each |navigable| of |navigables|:
6238+
6239+
1. [=map/Set=] [=emulated network conditions map=][|navigable|] to
6240+
|emulated network conditions|.
6241+
6242+
1. If the <code>userContexts</code> field of |command parameters| is present:
6243+
6244+
1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=]
6245+
with |command parameters|["<code>userContexts</code>"].
6246+
6247+
1. For each |user context| of |user contexts|:
6248+
6249+
1. [=map/Set=] [=emulated network conditions map=][|user context|] to |emulated network conditions|.
6250+
6251+
1. Return [=success=] with data null.
6252+
6253+
</div>
6254+
61666255
#### The emulation.setScreenOrientationOverride Command #### {#command-emulation-setScreenOrientationOverride}
61676256

61686257
The <dfn export for=commands>emulation.setScreenOrientationOverride</dfn> command
@@ -9507,6 +9596,29 @@ and |user context| are:
95079596

95089597
</div>
95099598

9599+
<div algorithm>
9600+
The steps to <dfn>get emulated network conditions</dfn> given |related navigables|
9601+
are:
9602+
9603+
1. For each |navigable| of |related navigables|:
9604+
9605+
1. Let |top-level traversable| be |navigable|’s [=navigable/top-level traversable=].
9606+
9607+
1. Let |user context| be |top-level traversable|'s [=associated user context=].
9608+
9609+
1. For each |session| in [=active BiDI sessions=]:
9610+
9611+
1. If |session|'s [=emulated network conditions map=] [=map/contains=]
9612+
|top-level traversable|, return
9613+
[=emulated network conditions map=][|top-level traversable|].
9614+
9615+
1. If |session|'s [=emulated network conditions map=] [=map/contains=]
9616+
|user context|, return [=emulated network conditions map=][|user context|].
9617+
9618+
1. Return null.
9619+
9620+
</div>
9621+
95109622
<div algorithm>
95119623
The [=remote end event trigger=] is the <dfn export>WebDriver BiDi before
95129624
request sent</dfn> steps given |request|:
@@ -9614,8 +9726,17 @@ request sent</dfn> steps given |request|:
96149726

96159727
Note: While waiting, no further processing of the request occurs.
96169728

9729+
1. Let |emulated network conditions| be the result of
9730+
[=get emulated network conditions=] with |related navigables|.
9731+
9732+
1. If |emulated network conditions| is not null and
9733+
|emulated network conditions|'s [=emulated-network-conditions-struct/offline=] is
9734+
true, return ([=network error=], "<code>complete</code>").
9735+
96179736
1. Return (|response|, |response status|).
96189737

9738+
Issue: Respect return value in Fetch's "HTTP-network-or-cache fetch" algorithm.
9739+
96199740
</div>
96209741

96219742
#### The network.fetchError Event #### {#event-network-fetchError}

0 commit comments

Comments
 (0)