@@ -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,69 @@ 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=] .
886+
887+ A <dfn>connection</dfn> is an abstract WebDriver BiDi connection between the [=local end=] and the [=remote end=] .
898888
899- A [=remote end=] has a [=/set=] of [=WebSocket listeners=] <dfn>active
900- listeners</dfn> , which is initially empty.
889+ A [=connection=] has the <dfn>send a connection message</dfn> steps for sending a message over the connection.
901890
902- A [=remote end=] has a [=/set=] of <dfn>WebSocket connections not associated with a
903- session</dfn> , which is initially empty.
891+ A [=connection=] has the <dfn>close the connection</dfn> steps for closing the connection.
904892
905- A <dfn>WebSocket connection</dfn> is a network connection that follows the
906- requirements of the [[!RFC6455|WebSocket protocol]]
893+ A [=remote end=] has a [=/set=] of [= connection listeners=] <dfn>active listeners</dfn> ,
894+ which is initially empty.
907895
908- A [=BiDi session=] has a [=/set=] of <dfn>session WebSocket
909- connections</dfn> whose elements are [=WebSocket connections=] . This is
910- initially empty.
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+ ## WebSocket Transport ## {#websocket-transport-section}
914915
915- Note: Each [=WebSocket connection=] is associated with at most one [=BiDi
916- session=] .
916+ The <dfn>WebSocket transport</dfn> is a [=message transport=] implementation
917+ using the WebSocket protocol.
918+ [[!RFC6455]] .
919+
920+ Note: In the terms of the WebSocket protocol, the [=local end=] is the
921+ client and the [=remote end=] is the server / remote host.
922+
923+ When a [=WebSocket listener=] |listener| is created, a [=remote end=]
924+ must start to listen for WebSocket connections on the host and port
925+ given by |listener|'s [=listener/host=] and [=listener/port=] . If
926+ |listener|'s [=listener/secure flag=] is set, then connections
927+ established from |listener| must be TLS encrypted.
928+
929+ The [=connection steps=] for the [=WebSocket transport=] are:
917930
918931<div>
919932
920933When a client [=establishes a WebSocket connection=] |connection| by
921934connecting 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
935+ implementation must proceed according to the WebSocket
936+ [=server-side requirements=] , with the following steps run when deciding whether to
924937accept the incoming connection:
925938
9269391. Let |resource name| be the resource name from [=reading the
@@ -936,8 +949,7 @@ accept the incoming connection:
936949 connection should be accepted, and if it is not stop running these
937950 steps and act as if the requested service is not available.
938951
939- 1. Add the connection to [=WebSocket connections not associated with a
940- session=] .
952+ 1. Add the connection to [=connections not associated with a session=] .
941953
942954 1. Return.
943955
@@ -955,25 +967,40 @@ accept the incoming connection:
955967 connection should be accepted, and if it is not stop running these
956968 steps and act as if the requested service is not available.
957969
958- 1. Otherwise append |connection| to |session|'s [=session WebSocket
959- connections=] , and proceed with the WebSocket [=server-side requirements=]
970+ 1. Otherwise append |connection| to |session|'s [=session connections=] ,
971+ and proceed with the WebSocket [=server-side requirements=]
960972 when a server chooses to accept an incoming connection.
961973
962974Issue: Do we support > 1 connection for a single session?
963975
964976</div>
965977
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|.
978+ A <dfn>WebSocket listener</dfn> is a network endpoint that is able to accept
979+ incoming [[!RFC6455|WebSocket]] connections. A [=WebSocket listener=] is a
980+ [=connection listener=] .
981+
982+ A [=WebSocket listener=] has a <dfn for=listener>host</dfn> , a <dfn
983+ for=listener> port</dfn> , a <dfn for=listener>secure flag</dfn> , and a
984+ <dfn>list of WebSocket resources</dfn> .
985+
986+ A <dfn>WebSocket connection</dfn> is a network [=connection=] that follows the
987+ requirements of the [[!RFC6455|WebSocket protocol]] .
988+
989+ [=A message has been received=] for a [=WebSocket connection=] when [=a WebSocket Message Has Been Received=] .
990+ [=The connection is closed=] for a [=WebSocket connection=] when [=the WebSocket closing handshake is started=]
991+ or when [=the WebSocket connection is closed=] .
992+
993+ Note: Both conditions are needed because it is possible for a connection to be
994+ closed without a closing handshake.
969995
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|.
996+ The [=send a connection message=] steps for a [=WebSocket connection=] are [=send a WebSocket Message=] .
997+ The [=close the connection=] steps for a [=WebSocket connection=] |connection| are:
974998
975- Note: Both conditions are needed because it is possible for a
976- WebSocket connection to be closed without a closing handshake.
999+ 1. [=Start the WebSocket closing handshake=] with |connection|.
1000+
1001+ Note: this will result in the steps in [=handle a connection closing=]
1002+ being run for |connection|, which will clean up resources associated with
1003+ |connection|.
9771004
9781005<div algorithm>
9791006
@@ -1031,8 +1058,8 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
10311058 [=implementation-defined=] [=listener/host=] , [=listener/port=] ,
10321059 [=listener/secure flag=] , and an empty [=list of WebSocket resources=] .
10331060
1034- 1. Let |resource name| be the result of [=construct a WebSocket
1035- resource name=] with |session|.
1061+ 1. Let |resource name| be the result of [=construct a WebSocket resource name=]
1062+ with |session|.
10361063
103710641. Append |resource name| to the [=list of WebSocket resources=] for
10381065 |listener|.
@@ -1045,15 +1072,15 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
10451072</div>
10461073
10471074Note: An [=intermediary node=] handling multiple sessions can use one
1048- or many WebSocket listeners. [[!WEBDRIVER|WebDriver]] defines that
1075+ or many listeners. [[!WEBDRIVER|WebDriver]] defines that
10491076an [=endpoint node=] supports at most one session at a time, so it's
10501077expected to only have a single listener.
10511078
10521079Note: For an [=endpoint node=] the [=listener/host=] in the above steps will
10531080typically be "<code> localhost</code> ".
10541081
10551082<div algorithm>
1056- To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
1083+ To <dfn>handle an incoming message</dfn> given a [=connection=]
10571084|connection|, type |type| and data |data|:
10581085
105910861. If |type| is not [=%x1 denotes a text frame|text=] , [=send an error
@@ -1069,9 +1096,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
10691096 is used for UTF-8 errors.
10701097
107110981. 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.
1099+ let |session| be that session. Otherwise if |connection| is in [=connections not associated with a session=] ,
1100+ let |session| be null. Otherwise, return.
10751101
107611021. Let |parsed| be the result of [=parse JSON into Infra values|parsing JSON
10771103 into Infra values=] given |data|. If this throws an exception, then [=send
@@ -1116,9 +1142,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
11161142 1. If |method| is "<code> session.new</code> ", let |session| be the entry in
11171143 the list of [=active sessions=] whose [=session ID=] is equal to the
11181144 "<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=] .
1145+ |connection| to |session|'s [=session connections=] , and
1146+ remove |connection| from the [=connections not associated with a session=] .
11221147
11231148 1. Let |response| be a new [=/map=] matching the <code> CommandResponse</code>
11241149 production in the {^local end definition^} with the <code> id</code>
@@ -1128,7 +1153,7 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
11281153 1. Let |serialized| be the result of [=serialize an infra value to JSON
11291154 bytes=] given |response|.
11301155
1131- 1. [=Send a WebSocket message=] comprised of |serialized| over
1156+ 1. [=Send a connection message=] comprised of |serialized| over
11321157 |connection|.
11331158
113411591. Otherwise:
@@ -1252,14 +1277,14 @@ To <dfn>get valid top-level traversables by ids</dfn> given a [=/list=] of conte
125212771. Let |serialized| be the result of [=serialize an infra value to JSON
12531278 bytes=] given |body|.
12541279
1255- 1. [=list/For each=] |connection| in |session|'s [=session WebSocket connections=] :
1280+ 1. [=list/For each=] |connection| in |session|'s [=session connections=] :
12561281
1257- 1. [=Send a WebSocket message=] comprised of |serialized| over |connection|.
1282+ 1. [=Send a connection message=] comprised of |serialized| over |connection|.
12581283
12591284</div>
12601285
12611286<div algorithm>
1262- To <dfn>send an error response</dfn> given a [=WebSocket connection=]
1287+ To <dfn>send an error response</dfn> given a [=connection=]
12631288|connection|, |command id|, and |error code|:
12641289
126512901. Let |error data| be a new [=/map=] matching the <code> ErrorResponse</code>
@@ -1277,25 +1302,23 @@ To <dfn>send an error response</dfn> given a [=WebSocket connection=]
12771302 Note: |command id| can be null, in which case the <code> id</code> field will
12781303 also be set to null, not omitted from |response|.
12791304
1280- 1. [=Send a WebSocket message=] comprised of |response| over |connection|.
1305+ 1. [=Send a connection message=] comprised of |response| over |connection|.
12811306
12821307</div>
12831308
12841309
12851310<div algorithm>
12861311
1287- To <dfn>handle a connection closing</dfn> given a [=WebSocket connection=]
1288- |connection|:
1312+ To <dfn>handle a connection closing</dfn> given a [=connection=] |connection|:
12891313
129013141. If there is a [=BiDi session=] [=associated with connection=] |connection|:
12911315
12921316 1. Let |session| be the [=BiDi session=] [=associated with connection=]
12931317 |connection|.
12941318
1295- 1. Remove |connection| from |session|'s [=session WebSocket
1296- connections=] .
1319+ 1. Remove |connection| from |session|'s [=session connections=] .
12971320
1298- 1. Otherwise, if [=WebSocket connections not associated with a session=]
1321+ 1. Otherwise, if [=connections not associated with a session=]
12991322 [=list/contains=] |connection|, [=list/remove=] |connection| from that set.
13001323
13011324Note: This does not end any [=/session=] .
@@ -1307,16 +1330,11 @@ the listener if it wants.
13071330
13081331<div algorithm>
13091332
1310- To <dfn>close the WebSocket connections</dfn> given |session|:
1311-
1312- 1. For each |connection| in |session|'s [=session WebSocket
1313- connections=] :
1333+ To <dfn>close the connections</dfn> given |session|:
13141334
1315- 1. [=Start the WebSocket closing handshake=] with |connection|.
1335+ 1. For each |connection| in |session|'s [=session connections=] :
13161336
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|.
1337+ 1. Run [=close the connection=] steps for the |connection|.
13201338
13211339</div>
13221340
@@ -1338,11 +1356,9 @@ with parameters |session|, |capabilities|, and |flags| is:
13381356
133913571. [=Assert=] : |webSocketUrl| is true.
13401358
1341- 1. Let |listener| be the result of [=start listening for a WebSocket
1342- connection=] given |session|.
1359+ 1. Let |listener| be the result of [=start listening for a WebSocket connection=] given |session|.
13431360
1344- 1. Set |webSocketUrl| to the result of [=construct a WebSocket
1345- URL=] with |listener| and |session|.
1361+ 1. Set |webSocketUrl| to the result of [=construct a WebSocket URL=] with |listener| and |session|.
13461362
134713631. [=Set a property=] on |capabilities| named
13481364 "<code> webSocketUrl</code> " to |webSocketUrl|.
@@ -1361,7 +1377,8 @@ communicated out-of-band. An implementation that allows this <dfn>supports
13611377BiDi-only sessions</dfn> . At the time such an implementation is ready to accept
13621378requests to start a WebDriver session, it must:
13631379
1364- 1. [=Start listening for a WebSocket connection=] given null.
1380+ 1. Let |transport| be a [=WebSocket transport=] .
1381+ 1. Run [=start listening for a WebSocket connection=] for |transport| given null.
13651382
13661383</div>
13671384
@@ -1643,7 +1660,7 @@ To <dfn>end the session</dfn> given |session|:
16431660
16441661To <dfn>cleanup the session</dfn> given |session|:
16451662
1646- 1. [=Close the WebSocket connections=] with |session|.
1663+ 1. [=Close the connections=] with |session|.
16471664
164816651. For each |user context| in the [=set of user contexts=] :
16491666
@@ -2042,7 +2059,7 @@ The [=remote end steps=] given |session| and <var ignore>command parameters</var
20422059
204320601. Return [=success=] with data null, and in parallel run the following steps:
20442061
2045- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2062+ 1. Wait until the [=Send a connection message=] steps have been called with the
20462063 response to this command.
20472064
20482065 Issue: this is rather imprecise language, but hopefully it's clear that the
@@ -2664,7 +2681,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26642681 return [=error=] with [=error code=] [=unable to close browser=] , and then
26652682 run the following steps [=in parallel=] :
26662683
2667- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2684+ 1. Wait until the [=Send a connection message=] steps have been called with the
26682685 response to this command.
26692686
26702687 1. [=Cleanup the session=] with |session|.
@@ -2683,7 +2700,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26832700
268427011. Return [=success=] with data null, and run the following steps [=in parallel=] .
26852702
2686- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2703+ 1. Wait until the [=Send a connection message=] steps have been called with the
26872704 response to this command.
26882705
26892706 1. [=Cleanup the session=] with |session|.
@@ -2696,7 +2713,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26962713 Note: For example this might include cleanly shutting down any OS-level
26972714 processes associated with the browser under automation, removing temporary
26982715 state, such as user profile data, created by the [=remote end=] while under
2699- automation, or shutting down the [=WebSocket Listener=] . Because of
2716+ automation, or shutting down the [=Connection Listener=] . Because of
27002717 differences between browsers and operating systems it is not possible to
27012718 specify in detail precise invariants [=local ends=] can depend on here.
27022719
0 commit comments