@@ -1541,6 +1541,14 @@ A [=BiDi session=] has a
15411541A [=BiDi session=] has a <dfn>user context to proxy configuration map</dfn> , which is
15421542a [=/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+
15441552When 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
@@ -6153,6 +6162,86 @@ The [=remote end steps=] with |command parameters| are:
61536162
61546163</div>
61556164
6165+ #### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions}
6166+
6167+ The <dfn export for=commands>emulation.setNetworkConditions</dfn> command
6168+ emulates specific network conditions for the given browsing context or for a user
6169+ context.
6170+
6171+ <dl>
6172+ <dt> Command Type</dt>
6173+ <dd>
6174+ <pre class="cddl" data-cddl-module="remote-cddl">
6175+ emulation.SetNetworkConditions = (
6176+ method: "emulation.setNetworkConditions",
6177+ params: emulation.setNetworkConditionsParameters
6178+ )
6179+
6180+ emulation.setNetworkConditionsParameters = {
6181+ networkConditions: emulation.NetworkConditions / null,
6182+ ? contexts: [+browsingContext.BrowsingContext] ,
6183+ ? userContexts: [+browser.UserContext] ,
6184+ }
6185+
6186+ emulation.NetworkConditions = emulation.NetworkConditionsOffline
6187+
6188+ emulation.NetworkConditionsOffline = {
6189+ type: "offline"
6190+ }
6191+ </pre>
6192+ </dd>
6193+ <dt> Result Type</dt>
6194+ <dd>
6195+ <code>
6196+ EmptyResult
6197+ </code>
6198+ </dd>
6199+ </dl>
6200+
6201+ <div algorithm="remote end steps for emulation.setNetworkConditions">
6202+
6203+ The [=remote end steps=] with |command parameters| are:
6204+
6205+ 1. If |command parameters| [=map/contains=] "<code> userContexts</code> "
6206+ and |command parameters| [=map/contains=] "<code> context</code> ",
6207+ return [=error=] with [=error code=] [=invalid argument=] .
6208+
6209+ 1. If |command parameters| doesn't [=map/contain=] "<code> userContexts</code> "
6210+ and |command parameters| doesn't [=map/contain=] "<code> context</code> ",
6211+ return [=error=] with [=error code=] [=invalid argument=] .
6212+
6213+ 1. Let |emulated network conditions| be null.
6214+
6215+ 1. If |command parameters|["<code>networkConditions</code>"] is not null and
6216+ |command parameters|["<code>networkConditions</code>"]["<code>type</code>"]
6217+ equals "<code> offline</code> ", set |emulated network conditions| to a new
6218+ [=emulated network conditions struct=] with
6219+ [=emulated-network-conditions-struct/offline=] set to true.
6220+
6221+ 1. If the <code> contexts</code> field of |command parameters| is present:
6222+
6223+ 1. Let |navigables| be the result of [=trying=] to
6224+ [=get valid top-level traversables by ids=] with
6225+ |command parameters|["<code>contexts</code>"] .
6226+
6227+ 1. For each |navigable| of |navigables|:
6228+
6229+ 1. [=map/Set=] [=emulated network conditions map=] [|navigable|] to
6230+ |emulated network conditions|.
6231+
6232+ 1. If the <code> userContexts</code> field of |command parameters| is present:
6233+
6234+ 1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=]
6235+ with |command parameters|["<code>userContexts</code>"] .
6236+
6237+ 1. For each |user context| of |user contexts|:
6238+
6239+ 1. [=map/Set=] [=emulated network conditions map=] [|user context|] to |emulated network conditions|.
6240+
6241+ 1. Return [=success=] with data null.
6242+
6243+ </div>
6244+
61566245#### The emulation.setScreenOrientationOverride Command #### {#command-emulation-setScreenOrientationOverride}
61576246
61586247The <dfn export for=commands>emulation.setScreenOrientationOverride</dfn> command
@@ -9383,6 +9472,29 @@ and |user context| are:
93839472
93849473</div>
93859474
9475+ <div algorithm>
9476+ The steps to <dfn>get emulated network conditions</dfn> given |related navigables|
9477+ are:
9478+
9479+ 1. For each |navigable| of |related navigables|:
9480+
9481+ 1. Let |top-level traversable| be |navigable|’s [=navigable/top-level traversable=] .
9482+
9483+ 1. Let |user context| be |top-level traversable|'s [=associated user context=] .
9484+
9485+ 1. For each |session| in [=active BiDI sessions=] :
9486+
9487+ 1. If |session|'s [=emulated network conditions map=] [=map/contains=]
9488+ |top-level traversable|, return
9489+ [=emulated network conditions map=] [|top-level traversable|] .
9490+
9491+ 1. If |session|'s [=emulated network conditions map=] [=map/contains=]
9492+ |user context|, return [=emulated network conditions map=] [|user context|] .
9493+
9494+ 1. Return null.
9495+
9496+ </div>
9497+
93869498<div algorithm>
93879499The [=remote end event trigger=] is the <dfn export>WebDriver BiDi before
93889500request sent</dfn> steps given |request|:
@@ -9490,8 +9602,17 @@ request sent</dfn> steps given |request|:
94909602
94919603 Note: While waiting, no further processing of the request occurs.
94929604
9605+ 1. Let |emulated network conditions| be the result of
9606+ [=get emulated network conditions=] with |related navigables|.
9607+
9608+ 1. If |emulated network conditions| is not null and
9609+ |emulated network conditions|'s [=emulated-network-conditions-struct/offline=] is
9610+ true, return ([=network error=] , "<code> complete</code> ").
9611+
949396121. Return (|response|, |response status|).
94949613
9614+ Issue: Respect return value in Fetch's "HTTP-network-or-cache fetch" algorithm.
9615+
94959616</div>
94969617
94979618#### The network.fetchError Event #### {#event-network-fetchError}
0 commit comments