@@ -1537,6 +1537,14 @@ A [=BiDi session=] has a
15371537A [=BiDi session=]  has a <dfn>user context to proxy configuration map</dfn> , which is
15381538a [=/map=]  between [=user contexts=]  and [=proxy configuration=] .
15391539
1540+ An <dfn>emulated network conditions struct</dfn>  is a [=struct=]  with:
1541+ * [=struct/Item=]  named <dfn attribute for="emulated-network-conditions-struct">offline</dfn> 
1542+   which is a boolean or null.
1543+ 
1544+ A [=BiDi session=]  has an <dfn>emulated network conditions map</dfn> , which is a weak
1545+ map between [=navigables=]  or [=user contexts=]  and
1546+ [=emulated network conditions struct=]  or null.
1547+ 
15401548When a [=user context=]  is [=set/remove|removed=]  from the
15411549[=set of user contexts=] , [=remove user context subscriptions=] .
15421550
@@ -5808,6 +5816,7 @@ relating to emulation of browser APIs.
58085816EmulationCommand = (
58095817  emulation.SetGeolocationOverride //
58105818  emulation.SetLocaleOverride //
5819+   emulation.SetNetworkConditions //
58115820  emulation.SetScreenOrientationOverride
58125821)
58135822</pre> 
@@ -6057,6 +6066,96 @@ The [=remote end steps=] with |command parameters| are:
60576066
60586067</div> 
60596068
6069+ #### The emulation.setNetworkConditions Command ####  {#command-emulation-setNetworkConditions}
6070+ 
6071+ The <dfn export for=commands>emulation.setNetworkConditions</dfn>  command
6072+ emulates specific network conditions for the given browsing context or for a user
6073+ context.
6074+ 
6075+ <dl> 
6076+    <dt> Command Type</dt> 
6077+    <dd> 
6078+     <pre class="cddl" data-cddl-module="remote-cddl"> 
6079+       emulation.setNetworkConditions = (
6080+         method: "emulation.setNetworkConditions",
6081+         params: emulation.setNetworkConditionsParameters
6082+       )
6083+ 
6084+       emulation.setNetworkConditionsParameters = {
6085+         networkConditions: emulation.NetworkConditions / null,
6086+         ? contexts: [+browsingContext.BrowsingContext] ,
6087+         ? userContexts: [+browser.UserContext] ,
6088+       }
6089+ 
6090+       emulation.NetworkConditions = emulation.NetworkConditionsOffline
6091+ 
6092+       emulation.NetworkConditionsOffline = {
6093+         type: "offline"
6094+       }
6095+     </pre> 
6096+    </dd> 
6097+    <dt> Result Type</dt> 
6098+    <dd> 
6099+     <code> 
6100+      EmptyResult
6101+     </code> 
6102+    </dd> 
6103+ </dl> 
6104+ 
6105+ <div algorithm="remote end steps for emulation.setNetworkConditions"> 
6106+ 
6107+ The [=remote end steps=]  with |command parameters| are:
6108+ 
6109+ 1. If |command parameters| [=map/contains=]  "<code> userContexts</code> "
6110+    and |command parameters| [=map/contains=]  "<code> context</code> ",
6111+    return [=error=]  with [=error code=]  [=invalid argument=] .
6112+ 
6113+ 1. If |command parameters| doesn't [=map/contain=]  "<code> userContexts</code> "
6114+    and |command parameters| doesn't [=map/contain=]  "<code> context</code> ",
6115+    return [=error=]  with [=error code=]  [=invalid argument=] .
6116+ 
6117+ 1. Let |emulated network conditions| be null.
6118+ 
6119+ 1. If |command parameters| [=map/contains=]  "<code> NetworkConditions</code> ":
6120+ 
6121+    1. If |command parameters|["<code>networkConditions</code>"]["<code>type</code>"] 
6122+       equals offline, set |emulated network conditions| to a new
6123+       [=emulated network conditions struct=]  with [=struct/item=] 
6124+       "<code> offline</code> " set to true.
6125+ 
6126+ 1. Let |navigables| be a [=/set=] .
6127+ 
6128+ 1. If the <code> contexts</code>  field of |command parameters| is present:
6129+ 
6130+    1. Let |navigables| be the result of [=trying=]  to
6131+       [=get valid top-level traversables by ids=]  with
6132+       |command parameters|["<code>contexts</code>"] .
6133+ 
6134+ 1. Otherwise:
6135+ 
6136+    1. Assert the <code> userContexts</code>  field of |command parameters| is present.
6137+ 
6138+    1. Let |user contexts| be the result of [=trying=]  to [=get valid user contexts=] 
6139+       with |command parameters|["<code>userContexts</code>"] .
6140+ 
6141+    1. For each |user context| of |user contexts|:
6142+ 
6143+       1. [=map/Set=]  [=emulated network conditions map=] [|user context|]  to |emulated network conditions|.
6144+ 
6145+       1. [=list/For each=]  |top-level traversable| of the list of all
6146+          [=/top-level traversables=]  whose [=associated user context=]  is
6147+          |user context|:
6148+ 
6149+          1. [=list/Append=]  |top-level traversable| to |navigables|.
6150+ 
6151+ 1. For each |navigable| of |navigables|:
6152+ 
6153+    1. [=map/Set=]  [=emulated network conditions map=] [|navigable|]  to |emulated network conditions|.
6154+ 
6155+ 1. Return [=success=]  with data null.
6156+ 
6157+ </div> 
6158+ 
60606159#### The emulation.setScreenOrientationOverride Command ####  {#command-emulation-setScreenOrientationOverride}
60616160
60626161The <dfn export for=commands>emulation.setScreenOrientationOverride</dfn>  command
0 commit comments