@@ -33,7 +33,7 @@ spec: RFC6455; urlPrefix: https://datatracker.ietf.org/doc/html/rfc6455
3333 text: Reading the Client's Opening Handshake; url: section-4.2.1
3434 text: %x1 denotes a text frame; url: section-5.2
3535 text: Send a WebSocket Message; url: section-6.1
36- text: A WebSocket Message Has Been Received; url: section-6.2
36+ text: a WebSocket Message Has Been Received; url: section-6.2
3737 text: Start The WebSocket Closing Handshake; url: section-7.1.2
3838 text: The WebSocket Closing Handshake is Started; url: section-7.1.3
3939 text: The WebSocket Connection is Closed; url: section-7.1.4
@@ -871,56 +871,72 @@ To <dfn>obtain a set of event names</dfn> given a |name|:
871871
872872# Transport # {#transport}
873873
874- Message transport is provided using the WebSocket protocol.
875- [[!RFC6455]]
876-
877- Note: In the terms of the WebSocket protocol, the [=local end=] is the
878- client and the [=remote end=] is the server / remote host.
879-
880874Note: The encoding of [=commands=] and [=events=] as messages is
881875similar to JSON-RPC, but this specification does not normatively
882876reference it. [[JSON-RPC]] The normative requirements on [=remote ends=]
883877are instead given as a precise processing model, while no
884878normative requirements are given for [=local ends=] .
885879
886- A <dfn>WebSocket listener </dfn> is a network endpoint that is able
887- to accept incoming [[!RFC6455|WebSocket]] connections .
880+ A <dfn>message transport </dfn> is an abstract interface for passing
881+ messages between the [=local end=] and the [=remote end=] .
888882
889- A [=WebSocket listener=] has a <dfn for=listener>host</dfn> , a <dfn
890- for=listener> port</dfn> , a <dfn for=listener>secure flag</dfn> , and a
891- <dfn>list of WebSocket resources</dfn> .
883+ <dfn>Connection steps</dfn> for a [=message transport=] are the steps taken when the [=local end=] establishes a new [=connection=] .
892884
893- When a [=WebSocket listener=] |listener| is created, a [=remote end=]
894- must start to listen for WebSocket connections on the host and port
895- given by |listener|'s [=listener/host=] and [=listener/port=] . If
896- |listener|'s [=listener/secure flag=] is set, then connections
897- established from |listener| must be TLS encrypted.
885+ A <dfn>connection listener</dfn> is a mechanism that is able to accept incoming [=connections=] .
898886
899- A [=remote end=] has a [=/set=] of [=WebSocket listeners=] <dfn>active
900- listeners</dfn> , which is initially empty.
887+ A <dfn>connection</dfn> is an abstract WebDriver BiDi connection between the [=local end=] and the [=remote end=] .
901888
902- A [=remote end=] has a [=/set=] of <dfn>WebSocket connections not associated with a
903- session</dfn> , which is initially empty.
889+ A [=connection=] has the <dfn>send a connection message</dfn> steps for sending a message over the connection.
904890
905- A <dfn>WebSocket connection</dfn> is a network connection that follows the
906- requirements of the [[!RFC6455|WebSocket protocol]]
891+ A [=connection=] has the <dfn>close the connection</dfn> steps for closing the connection.
907892
908- A [=BiDi session=] has a [=/set=] of <dfn>session WebSocket
909- connections</dfn> whose elements are [=WebSocket connections=] . This is
910- initially empty.
893+ A [=remote end=] has a [=/set=] of [=connection listeners=] <dfn>active listeners</dfn> ,
894+ which is initially empty.
895+
896+ A [=remote end=] has a [=/set=] of <dfn>connections not associated with a session</dfn> ,
897+ which is initially empty.
898+
899+ A [=BiDi session=] has a [=/set=] of <dfn>session connections</dfn>
900+ whose elements are [=connections=] . This is initially empty.
911901
912902A [=BiDi session=] |session| is <dfn>associated with connection</dfn>
913- |connection| if |session|'s [=session WebSocket connections=] contains |connection|.
903+ |connection| if |session|'s [=session connections=] contains |connection|.
904+
905+ Note: Each [=connection=] is associated with at most one [=BiDi session=] .
906+
907+ When <dfn>a message has been received</dfn> for a [=connection=] |connection|
908+ with type |type| and data |data|, a [=remote end=]
909+ must [=handle an incoming message=] given |connection|, |type| and |data|.
910+
911+ When <dfn>the connection is closed</dfn> for a [=connection=] |connection|,
912+ a [=remote end=] must [=handle a connection closing=] given |connection|.
913+
914+ Note: Both conditions are needed because it is possible for a connection to be
915+ closed without a closing handshake.
916+
917+ ## WebSocket Transport ## {#websocket-transport-section}
918+
919+ The <dfn>WebSocket transport</dfn> is a [=message transport=] implementation
920+ using the WebSocket protocol.
921+ [[!RFC6455]] .
922+
923+ Note: In the terms of the WebSocket protocol, the [=local end=] is the
924+ client and the [=remote end=] is the server / remote host.
914925
915- Note: Each [=WebSocket connection=] is associated with at most one [=BiDi
916- session=] .
926+ When a [=WebSocket listener=] |listener| is created, a [=remote end=]
927+ must start to listen for WebSocket connections on the host and port
928+ given by |listener|'s [=listener/host=] and [=listener/port=] . If
929+ |listener|'s [=listener/secure flag=] is set, then connections
930+ established from |listener| must be TLS encrypted.
931+
932+ The [=connection steps=] for the [=WebSocket transport=] are:
917933
918934<div>
919935
920936When a client [=establishes a WebSocket connection=] |connection| by
921937connecting to one of the set of [=active listeners=] |listener|, the
922- implementation must proceed according to the WebSocket [=server-side
923- requirements=] , with the following steps run when deciding whether to
938+ implementation must proceed according to the WebSocket
939+ [=server-side requirements=] , with the following steps run when deciding whether to
924940accept the incoming connection:
925941
9269421. Let |resource name| be the resource name from [=reading the
@@ -936,8 +952,7 @@ accept the incoming connection:
936952 connection should be accepted, and if it is not stop running these
937953 steps and act as if the requested service is not available.
938954
939- 1. Add the connection to [=WebSocket connections not associated with a
940- session=] .
955+ 1. Add the connection to [=connections not associated with a session=] .
941956
942957 1. Return.
943958
@@ -955,25 +970,36 @@ accept the incoming connection:
955970 connection should be accepted, and if it is not stop running these
956971 steps and act as if the requested service is not available.
957972
958- 1. Otherwise append |connection| to |session|'s [=session WebSocket
959- connections=] , and proceed with the WebSocket [=server-side requirements=]
973+ 1. Otherwise append |connection| to |session|'s [=session connections=] ,
974+ and proceed with the WebSocket [=server-side requirements=]
960975 when a server chooses to accept an incoming connection.
961976
962977Issue: Do we support > 1 connection for a single session?
963978
964979</div>
965980
966- When [=a WebSocket message has been received=] for a [=WebSocket
967- connection=] |connection| with type |type| and data |data|, a [=remote end=]
968- must [=handle an incoming message=] given |connection|, |type| and |data|.
981+ A <dfn>WebSocket listener</dfn> is a network endpoint that is able to accept
982+ incoming [[!RFC6455|WebSocket]] connections. A [=WebSocket listener=] is a
983+ [=connection listener=] .
984+
985+ A [=WebSocket listener=] has a <dfn for=listener>host</dfn> , a <dfn
986+ for=listener> port</dfn> , a <dfn for=listener>secure flag</dfn> , and a
987+ <dfn>list of WebSocket resources</dfn> .
988+
989+ A <dfn>WebSocket connection</dfn> is a network [=connection=] that follows the
990+ requirements of the [[!RFC6455|WebSocket protocol]] .
969991
970- When [=the WebSocket closing handshake is started=] or when [=the
971- WebSocket connection is closed=] for a [=WebSocket connection=]
972- |connection|, a [=remote end=] must [=handle a connection closing=]
973- given |connection|.
992+ [=A message has been received=] for a [=WebSocket connection=] when [=a WebSocket Message Has Been Received=] .
993+ [=The connection is closed=] for a [=WebSocket connection=] when [=the WebSocket closing handshake is started=]
994+ or when [=the WebSocket connection is closed=] .
995+ The [=send a connection message=] steps for a [=WebSocket connection=] are [=send a WebSocket Message=] .
996+ The [=close the connection=] steps for a [=WebSocket connection=] |connection| are:
974997
975- Note: Both conditions are needed because it is possible for a
976- WebSocket connection to be closed without a closing handshake.
998+ 1. [=Start the WebSocket closing handshake=] with |connection|.
999+
1000+ Note: this will result in the steps in [=handle a connection closing=]
1001+ being run for |connection|, which will clean up resources associated with
1002+ |connection|.
9771003
9781004<div algorithm>
9791005
@@ -1031,8 +1057,8 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
10311057 [=implementation-defined=] [=listener/host=] , [=listener/port=] ,
10321058 [=listener/secure flag=] , and an empty [=list of WebSocket resources=] .
10331059
1034- 1. Let |resource name| be the result of [=construct a WebSocket
1035- resource name=] with |session|.
1060+ 1. Let |resource name| be the result of [=construct a WebSocket resource name=]
1061+ with |session|.
10361062
103710631. Append |resource name| to the [=list of WebSocket resources=] for
10381064 |listener|.
@@ -1045,15 +1071,15 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
10451071</div>
10461072
10471073Note: An [=intermediary node=] handling multiple sessions can use one
1048- or many WebSocket listeners. [[!WEBDRIVER|WebDriver]] defines that
1074+ or many listeners. [[!WEBDRIVER|WebDriver]] defines that
10491075an [=endpoint node=] supports at most one session at a time, so it's
10501076expected to only have a single listener.
10511077
10521078Note: For an [=endpoint node=] the [=listener/host=] in the above steps will
10531079typically be "<code> localhost</code> ".
10541080
10551081<div algorithm>
1056- To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
1082+ To <dfn>handle an incoming message</dfn> given a [=connection=]
10571083|connection|, type |type| and data |data|:
10581084
105910851. If |type| is not [=%x1 denotes a text frame|text=] , [=send an error
@@ -1069,9 +1095,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
10691095 is used for UTF-8 errors.
10701096
107110971. If there is a [=BiDi Session=] [=associated with connection=] |connection|,
1072- let |session| be that session. Otherwise if |connection| is in [=WebSocket
1073- connections not associated with a session=] , let |session| be
1074- null. Otherwise, return.
1098+ let |session| be that session. Otherwise if |connection| is in [=connections not associated with a session=] ,
1099+ let |session| be null. Otherwise, return.
10751100
107611011. Let |parsed| be the result of [=parse JSON into Infra values|parsing JSON
10771102 into Infra values=] given |data|. If this throws an exception, then [=send
@@ -1116,9 +1141,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
11161141 1. If |method| is "<code> session.new</code> ", let |session| be the entry in
11171142 the list of [=active sessions=] whose [=session ID=] is equal to the
11181143 "<code> sessionId</code> " property of |value|, [=set/append=]
1119- |connection| to |session|'s [=session WebSocket connections=] , and
1120- remove |connection| from the [=WebSocket connections not associated with
1121- a session=] .
1144+ |connection| to |session|'s [=session connections=] , and
1145+ remove |connection| from the [=connections not associated with a session=] .
11221146
11231147 1. Let |response| be a new [=/map=] matching the <code> CommandResponse</code>
11241148 production in the {^local end definition^} with the <code> id</code>
@@ -1128,7 +1152,7 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
11281152 1. Let |serialized| be the result of [=serialize an infra value to JSON
11291153 bytes=] given |response|.
11301154
1131- 1. [=Send a WebSocket message=] comprised of |serialized| over
1155+ 1. [=Send a connection message=] comprised of |serialized| over
11321156 |connection|.
11331157
113411581. Otherwise:
@@ -1252,14 +1276,14 @@ To <dfn>get valid top-level traversables by ids</dfn> given a [=/list=] of conte
125212761. Let |serialized| be the result of [=serialize an infra value to JSON
12531277 bytes=] given |body|.
12541278
1255- 1. [=list/For each=] |connection| in |session|'s [=session WebSocket connections=] :
1279+ 1. [=list/For each=] |connection| in |session|'s [=session connections=] :
12561280
1257- 1. [=Send a WebSocket message=] comprised of |serialized| over |connection|.
1281+ 1. [=Send a connection message=] comprised of |serialized| over |connection|.
12581282
12591283</div>
12601284
12611285<div algorithm>
1262- To <dfn>send an error response</dfn> given a [=WebSocket connection=]
1286+ To <dfn>send an error response</dfn> given a [=connection=]
12631287|connection|, |command id|, and |error code|:
12641288
126512891. Let |error data| be a new [=/map=] matching the <code> ErrorResponse</code>
@@ -1277,25 +1301,23 @@ To <dfn>send an error response</dfn> given a [=WebSocket connection=]
12771301 Note: |command id| can be null, in which case the <code> id</code> field will
12781302 also be set to null, not omitted from |response|.
12791303
1280- 1. [=Send a WebSocket message=] comprised of |response| over |connection|.
1304+ 1. [=Send a connection message=] comprised of |response| over |connection|.
12811305
12821306</div>
12831307
12841308
12851309<div algorithm>
12861310
1287- To <dfn>handle a connection closing</dfn> given a [=WebSocket connection=]
1288- |connection|:
1311+ To <dfn>handle a connection closing</dfn> given a [=connection=] |connection|:
12891312
129013131. If there is a [=BiDi session=] [=associated with connection=] |connection|:
12911314
12921315 1. Let |session| be the [=BiDi session=] [=associated with connection=]
12931316 |connection|.
12941317
1295- 1. Remove |connection| from |session|'s [=session WebSocket
1296- connections=] .
1318+ 1. Remove |connection| from |session|'s [=session connections=] .
12971319
1298- 1. Otherwise, if [=WebSocket connections not associated with a session=]
1320+ 1. Otherwise, if [=connections not associated with a session=]
12991321 [=list/contains=] |connection|, [=list/remove=] |connection| from that set.
13001322
13011323Note: This does not end any [=/session=] .
@@ -1307,16 +1329,11 @@ the listener if it wants.
13071329
13081330<div algorithm>
13091331
1310- To <dfn>close the WebSocket connections</dfn> given |session|:
1311-
1312- 1. For each |connection| in |session|'s [=session WebSocket
1313- connections=] :
1332+ To <dfn>close the connections</dfn> given |session|:
13141333
1315- 1. [=Start the WebSocket closing handshake=] with |connection|.
1334+ 1. For each |connection| in |session|'s [=session connections=] :
13161335
1317- Note: this will result in the steps in [=handle a connection closing=]
1318- being run for |connection|, which will clean up resources associated with
1319- |connection|.
1336+ 1. Run [=close the connection=] steps for the |connection|.
13201337
13211338</div>
13221339
@@ -1338,11 +1355,9 @@ with parameters |session|, |capabilities|, and |flags| is:
13381355
133913561. [=Assert=] : |webSocketUrl| is true.
13401357
1341- 1. Let |listener| be the result of [=start listening for a WebSocket
1342- connection=] given |session|.
1358+ 1. Let |listener| be the result of [=start listening for a WebSocket connection=] given |session|.
13431359
1344- 1. Set |webSocketUrl| to the result of [=construct a WebSocket
1345- URL=] with |listener| and |session|.
1360+ 1. Set |webSocketUrl| to the result of [=construct a WebSocket URL=] with |listener| and |session|.
13461361
134713621. [=Set a property=] on |capabilities| named
13481363 "<code> webSocketUrl</code> " to |webSocketUrl|.
@@ -1361,7 +1376,8 @@ communicated out-of-band. An implementation that allows this <dfn>supports
13611376BiDi-only sessions</dfn> . At the time such an implementation is ready to accept
13621377requests to start a WebDriver session, it must:
13631378
1364- 1. [=Start listening for a WebSocket connection=] given null.
1379+ 1. Let |transport| be a [=WebSocket transport=] .
1380+ 1. Run [=start listening for a WebSocket connection=] for |transport| given null.
13651381
13661382</div>
13671383
@@ -1643,7 +1659,7 @@ To <dfn>end the session</dfn> given |session|:
16431659
16441660To <dfn>cleanup the session</dfn> given |session|:
16451661
1646- 1. [=Close the WebSocket connections=] with |session|.
1662+ 1. [=Close the connections=] with |session|.
16471663
164816641. For each |user context| in the [=set of user contexts=] :
16491665
@@ -2042,7 +2058,7 @@ The [=remote end steps=] given |session| and <var ignore>command parameters</var
20422058
204320591. Return [=success=] with data null, and in parallel run the following steps:
20442060
2045- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2061+ 1. Wait until the [=Send a connection message=] steps have been called with the
20462062 response to this command.
20472063
20482064 Issue: this is rather imprecise language, but hopefully it's clear that the
@@ -2664,7 +2680,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26642680 return [=error=] with [=error code=] [=unable to close browser=] , and then
26652681 run the following steps [=in parallel=] :
26662682
2667- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2683+ 1. Wait until the [=Send a connection message=] steps have been called with the
26682684 response to this command.
26692685
26702686 1. [=Cleanup the session=] with |session|.
@@ -2683,7 +2699,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26832699
268427001. Return [=success=] with data null, and run the following steps [=in parallel=] .
26852701
2686- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2702+ 1. Wait until the [=Send a connection message=] steps have been called with the
26872703 response to this command.
26882704
26892705 1. [=Cleanup the session=] with |session|.
@@ -2696,7 +2712,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26962712 Note: For example this might include cleanly shutting down any OS-level
26972713 processes associated with the browser under automation, removing temporary
26982714 state, such as user profile data, created by the [=remote end=] while under
2699- automation, or shutting down the [=WebSocket Listener=] . Because of
2715+ automation, or shutting down the [=Connection Listener=] . Because of
27002716 differences between browsers and operating systems it is not possible to
27012717 specify in detail precise invariants [=local ends=] can depend on here.
27022718
0 commit comments