@@ -328,6 +328,12 @@ spec: RFC9110; urlPrefix: https://httpwg.org/specs/rfc9110.html
328328spec: STREAMS; urlPrefix: https://streams.spec.whatwg.org/
329329 type: dfn
330330 text: ReadableStream; url: #readablestream
331+ spec: WebSockets; urlPrefix: https://websockets.spec.whatwg.org/
332+ type: dfn
333+ text: WebSocket; url: #websocket
334+ spec: WebTransport; urlPrefix: https://w3c.github.io/webtransport/
335+ type: dfn
336+ text: Cleanup WebTransport; url: #webtransport-cleanup
331337</pre>
332338
333339<style>
@@ -766,7 +772,7 @@ The <dfn export>set of sessions for which an event is enabled</dfn> given |event
766772
7677731. Let |sessions| be a new [=/set=] .
768774
769- 1. For each |session| in [=active BiDI sessions=] :
775+ 1. For each |session| in [=active BiDi sessions=] :
770776
771777 1. If [=event is enabled=] with |session|, |event name| and |navigables|,
772778 append |session| to |sessions|.
@@ -1543,6 +1549,20 @@ A [=BiDi session=] has a
15431549A [=BiDi session=] has a <dfn>user context to proxy configuration map</dfn> , which is
15441550a [=/map=] between [=user contexts=] and [=proxy configuration=] .
15451551
1552+ An <dfn>emulated network conditions struct</dfn> is a [=struct=] with:
1553+ * [=struct/item=] named <dfn id="emulated-network-conditions-struct-offline"
1554+ for="emulated-network-conditions-struct"> offline</dfn> which is a boolean or null.
1555+
1556+ A [=BiDi session=] has a <dfn for=session>emulated network conditions</dfn> which is
1557+ a [=struct=] with an [=struct/item=] named <dfn
1558+ for="emulated network conditions"> default network conditions</dfn> , which is an
1559+ [=emulated network conditions struct=] or null, an [=struct/item=] named
1560+ <dfn for="emulated network conditions">user context network conditions</dfn> , which
1561+ is a weak map between [=user contexts=] and [=emulated network conditions struct=] ,
1562+ and a [=struct/item=] named
1563+ <dfn for="emulated network conditions">navigable network conditions</dfn> , which is a
1564+ weak map between [=navigables=] and [=emulated network conditions struct=] .
1565+
15461566When a [=user context=] is [=set/remove|removed=] from the
15471567[=set of user contexts=] , [=remove user context subscriptions=] .
15481568
@@ -5930,6 +5950,7 @@ EmulationCommand = (
59305950 emulation.SetForcedColorsModeThemeOverride //
59315951 emulation.SetGeolocationOverride //
59325952 emulation.SetLocaleOverride //
5953+ emulation.SetNetworkConditions //
59335954 emulation.SetScreenOrientationOverride //
59345955 emulation.SetScriptingEnabled //
59355956 emulation.SetTimezoneOverride //
@@ -6276,6 +6297,128 @@ The [=remote end steps=] with |command parameters| are:
62766297
62776298</div>
62786299
6300+ #### The emulation.setNetworkConditions Command #### {#command-emulation-setNetworkConditions}
6301+
6302+ The <dfn export for=commands>emulation.setNetworkConditions</dfn> command
6303+ emulates specific network conditions for the given browsing context or for a user
6304+ context.
6305+
6306+ <dl>
6307+ <dt> Command Type</dt>
6308+ <dd>
6309+ <pre class="cddl" data-cddl-module="remote-cddl">
6310+ emulation.SetNetworkConditions = (
6311+ method: "emulation.setNetworkConditions",
6312+ params: emulation.setNetworkConditionsParameters
6313+ )
6314+
6315+ emulation.setNetworkConditionsParameters = {
6316+ networkConditions: emulation.NetworkConditions / null,
6317+ ? contexts: [+browsingContext.BrowsingContext] ,
6318+ ? userContexts: [+browser.UserContext] ,
6319+ }
6320+
6321+ emulation.NetworkConditions = emulation.NetworkConditionsOffline
6322+
6323+ emulation.NetworkConditionsOffline = {
6324+ type: "offline"
6325+ }
6326+ </pre>
6327+ </dd>
6328+ <dt> Result Type</dt>
6329+ <dd>
6330+ <code>
6331+ EmptyResult
6332+ </code>
6333+ </dd>
6334+ </dl>
6335+
6336+ <div algorithm>
6337+
6338+ To <dfn>apply network conditions</dfn> :
6339+
6340+ 1. For each [=WebSocket=] object |webSocket|:
6341+
6342+ 1. Let |realm| be |webSocket|'s [=relevant Realm=] .
6343+
6344+ 1. Let |environment settings| be the [=environment settings object=] whose
6345+ [=realm execution context=] 's Realm component is |realm|.
6346+
6347+ 1. If the result of [=WebDriver BiDi network is offline=] with |environment settings| is true:
6348+
6349+ 1. [=Fail the WebSocket connection=] |webSocket|.
6350+
6351+ 1. For each [=WebTransport=] object |webTransport|:
6352+
6353+ 1. Let |realm| be |webSocket|'s [=relevant Realm=] .
6354+
6355+ 1. Let |environment settings| be the [=environment settings object=] whose
6356+ [=realm execution context=] 's Realm component is |realm|.
6357+
6358+ 1. If the result of [=WebDriver BiDi network is offline=] with |environment settings| is true:
6359+
6360+ 1. [=Cleanup WebTransport=] |webTransport|.
6361+
6362+ </div>
6363+
6364+ <div algorithm="remote end steps for emulation.setNetworkConditions">
6365+
6366+ The [=remote end steps=] with |command parameters| and |session| are:
6367+
6368+ 1. If |command parameters| [=map/contains=] "<code> userContexts</code> "
6369+ and |command parameters| [=map/contains=] "<code> context</code> ",
6370+ return [=error=] with [=error code=] [=invalid argument=] .
6371+
6372+ 1. Let |emulated network conditions| be null.
6373+
6374+ 1. If |command parameters|["<code>networkConditions</code>"] is not null and
6375+ |command parameters|["<code>networkConditions</code>"]["<code>type</code>"]
6376+ equals "<code> offline</code> ", set |emulated network conditions| to a new
6377+ [=emulated network conditions struct=] with
6378+ [=emulated-network-conditions-struct/offline=] set to true.
6379+
6380+ 1. If the <code> contexts</code> field of |command parameters| is present:
6381+
6382+ 1. Let |navigables| be the result of [=trying=] to
6383+ [=get valid top-level traversables by ids=] with
6384+ |command parameters|["<code>contexts</code>"] .
6385+
6386+ 1. For each |navigable| of |navigables|:
6387+
6388+ 1. If |emulated network conditions| is null, [=map/remove=] |navigable| from
6389+ |session|'s [=emulated network conditions=]' s
6390+ [=emulated network conditions/navigable network conditions=]
6391+
6392+ 1. Otherwise, [=map/set=] |session|'s [=emulated network conditions=]' s
6393+ [=emulated network conditions/navigable network conditions=] [|navigable|] to
6394+ |emulated network conditions|.
6395+
6396+ 1. If the <code> userContexts</code> field of |command parameters| is present:
6397+
6398+ 1. Let |user contexts| be the result of [=trying=] to [=get valid user contexts=]
6399+ with |command parameters|["<code>userContexts</code>"] .
6400+
6401+ 1. For each |user context| of |user contexts|:
6402+
6403+ 1. If |emulated network conditions| is null, [=map/remove=] |user context| from
6404+ |session|'s [=emulated network conditions=]' s
6405+ [=emulated network conditions/user context network conditions=] .
6406+
6407+ 1. Otherwise, [=map/set=] |session|'s [=emulated network conditions=]' s
6408+ [=emulated network conditions/user context network conditions=] [|user context|]
6409+ to |emulated network conditions|.
6410+
6411+ 1. If |command parameters| doesn't [=map/contain=] "<code> userContexts</code> "
6412+ and |command parameters| doesn't [=map/contain=] "<code> context</code> ",
6413+ [=map/set=] |session|'s [=emulated network conditions=]' s
6414+ [=emulated network conditions/default network conditions=] to |emulated network conditions|.
6415+
6416+ 1. [=Apply network conditions=] .
6417+
6418+ 1. Return [=success=] with data null.
6419+
6420+ </div>
6421+
62796422#### The emulation.setScreenOrientationOverride Command #### {#command-emulation-setScreenOrientationOverride}
62806423
62816424The <dfn export for=commands>emulation.setScreenOrientationOverride</dfn> command
@@ -9684,6 +9827,60 @@ and |user context| are:
96849827
96859828</div>
96869829
9830+ <div algorithm>
9831+ The steps to <dfn>get emulated network conditions</dfn> given |related navigables|
9832+ are:
9833+
9834+ 1. For each |navigable| of |related navigables|:
9835+
9836+ 1. Let |top-level traversable| be |navigable|’s [=navigable/top-level traversable=] .
9837+
9838+ 1. Let |user context| be |top-level traversable|'s [=associated user context=] .
9839+
9840+ 1. For each |session| in [=active BiDi sessions=] :
9841+
9842+ 1. If |session|'s [=emulated network conditions=]' s
9843+ [=emulated network conditions/navigable network conditions=]
9844+ [=map/contains=] |top-level traversable|, return |session|'s
9845+ [=emulated network conditions=] 's
9846+ [=emulated network conditions/navigable network conditions=] [|top-level traversable|] .
9847+
9848+ 1. For each |session| in [=active BiDi sessions=] :
9849+
9850+ 1. If |session|'s [=emulated network conditions=]' s
9851+ [=emulated network conditions/user context network conditions=]
9852+ [=map/contains=] |user context|, return |session|'s
9853+ [=emulated network conditions=] 's
9854+ [=emulated network conditions/user context network conditions=] [|user context|] .
9855+
9856+ 1. For each |session| in [=active BiDi sessions=] :
9857+
9858+ 1. If |session|'s [=emulated network conditions=]' s
9859+ [=emulated network conditions/default network conditions=] is not null,
9860+ return |session|'s [=emulated network conditions=]' s
9861+ [=emulated network conditions/default network conditions=] .
9862+
9863+ 1. Return null.
9864+
9865+ </div>
9866+
9867+ <div algorithm>
9868+ The <dfn export>WebDriver BiDi network is offline</dfn> steps given
9869+ [=environment settings object=] |settings| are:
9870+
9871+ 1. Let |navigable| be |settings|'s [=relevant global object=]' s
9872+ <a>associated <code>Document</code></a> 's [=/node navigable=] .
9873+
9874+ 1. Let |emulated network conditions| be the result of
9875+ [=get emulated network conditions=] with [|navigable|] .
9876+
9877+ 1. If |emulated network conditions| is not null and |emulated network conditions|'s
9878+ [=emulated-network-conditions-struct/offline=] is true, return true.
9879+
9880+ 1. Return false.
9881+
9882+ </div>
9883+
96879884<div algorithm>
96889885The [=remote end event trigger=] is the <dfn export>WebDriver BiDi before request sent</dfn> steps
96899886given [=/request=] |request|:
@@ -9793,8 +9990,17 @@ given [=/request=] |request|:
97939990
97949991 Note: While waiting, no further processing of the request occurs.
97959992
9993+ 1. Let |emulated network conditions| be the result of
9994+ [=get emulated network conditions=] with |related navigables|.
9995+
9996+ 1. If |emulated network conditions| is not null and
9997+ |emulated network conditions|'s [=emulated-network-conditions-struct/offline=] is
9998+ true, return ([=network error=] , "<code> complete</code> ").
9999+
9796100001. Return (|response|, |response status|).
979710001
10002+ Issue: Respect return value in Fetch's "HTTP-network-or-cache fetch" algorithm.
10003+
979810004</div>
979910005
980010006#### The network.fetchError Event #### {#event-network-fetchError}
@@ -13378,7 +13584,7 @@ The [=remote end event trigger=] is:
1337813584Define the following [=console steps=] with |method|, |args|, and
1337913585<var ignore> options</var> :
1338013586
13381- 1. For each |session| in [=active BiDI sessions=] :
13587+ 1. For each |session| in [=active BiDi sessions=] :
1338213588
1338313589 1. If |method| is "<code> error</code> " or "<code> assert</code> ", let |level| be
1338413590 "<code> error</code> ". If |method| is "<code> debug</code> " or "<code> trace</code> "
0 commit comments