@@ -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 =] .
888+
889+ A [=connection=] has the <dfn>send a connection message</dfn> steps for sending a message over the connection .
898890
899- A [=remote end=] has a [=/set=] of [=WebSocket listeners=] <dfn>active
900- listeners</dfn> , which is initially empty.
891+ A [=connection=] has the <dfn>close the connection</dfn> steps for closing the connection.
901892
902- A [=remote end=] has a [=/set=] of <dfn>WebSocket connections not associated with a
903- session</dfn> , which is initially empty.
893+ A [=remote end=] has a [=/set=] of [=connection listeners=] <dfn>active listeners</dfn> ,
894+ which is initially empty.
904895
905- A <dfn>WebSocket connection</dfn> is a network connection that follows the
906- requirements of the [[!RFC6455|WebSocket protocol]]
896+ A [=remote end=] has a [=/set=] of <dfn>connections not associated with a session</dfn> ,
897+ which is initially empty.
907898
908- A [=BiDi session=] has a [=/set=] of <dfn>session WebSocket
909- connections</dfn> whose elements are [=WebSocket connections=] . This is
910- initially empty.
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}
915+
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.
914928
915- Note: Each [=WebSocket connection=] is associated with at most one [=BiDi
916- session=] .
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,45 @@ 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> .
969985
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|.
986+ A <dfn>WebSocket connection</dfn> is a network [=connection=] that follows the
987+ requirements of the [[!RFC6455|WebSocket protocol]] .
974988
975- Note: Both conditions are needed because it is possible for a
976- WebSocket connection to be closed without a closing handshake.
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.
995+
996+ The [=send a connection message=] steps for a [=WebSocket connection=] are [=send a WebSocket Message=] .
997+
998+ <div>
999+
1000+ The [=close the connection=] steps for a [=WebSocket connection=] |connection| are:
1001+
1002+ 1. [=Start the WebSocket closing handshake=] with |connection|.
1003+
1004+ Note: this will result in the steps in [=handle a connection closing=]
1005+ being run for |connection|, which will clean up resources associated with
1006+ |connection|.
1007+
1008+ </div>
9771009
9781010<div algorithm>
9791011
@@ -1031,8 +1063,8 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
10311063 [=implementation-defined=] [=listener/host=] , [=listener/port=] ,
10321064 [=listener/secure flag=] , and an empty [=list of WebSocket resources=] .
10331065
1034- 1. Let |resource name| be the result of [=construct a WebSocket
1035- resource name=] with |session|.
1066+ 1. Let |resource name| be the result of [=construct a WebSocket resource name=]
1067+ with |session|.
10361068
103710691. Append |resource name| to the [=list of WebSocket resources=] for
10381070 |listener|.
@@ -1045,15 +1077,15 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
10451077</div>
10461078
10471079Note: An [=intermediary node=] handling multiple sessions can use one
1048- or many WebSocket listeners. [[!WEBDRIVER|WebDriver]] defines that
1080+ or many listeners. [[!WEBDRIVER|WebDriver]] defines that
10491081an [=endpoint node=] supports at most one session at a time, so it's
10501082expected to only have a single listener.
10511083
10521084Note: For an [=endpoint node=] the [=listener/host=] in the above steps will
10531085typically be "<code> localhost</code> ".
10541086
10551087<div algorithm>
1056- To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
1088+ To <dfn>handle an incoming message</dfn> given a [=connection=]
10571089|connection|, type |type| and data |data|:
10581090
105910911. If |type| is not [=%x1 denotes a text frame|text=] , [=send an error
@@ -1069,9 +1101,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
10691101 is used for UTF-8 errors.
10701102
107111031. 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.
1104+ let |session| be that session. Otherwise if |connection| is in [=connections not associated with a session=] ,
1105+ let |session| be null. Otherwise, return.
10751106
107611071. Let |parsed| be the result of [=parse JSON into Infra values|parsing JSON
10771108 into Infra values=] given |data|. If this throws an exception, then [=send
@@ -1116,9 +1147,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
11161147 1. If |method| is "<code> session.new</code> ", let |session| be the entry in
11171148 the list of [=active sessions=] whose [=session ID=] is equal to the
11181149 "<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=] .
1150+ |connection| to |session|'s [=session connections=] , and
1151+ remove |connection| from the [=connections not associated with a session=] .
11221152
11231153 1. Let |response| be a new [=/map=] matching the <code> CommandResponse</code>
11241154 production in the {^local end definition^} with the <code> id</code>
@@ -1128,7 +1158,7 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
11281158 1. Let |serialized| be the result of [=serialize an infra value to JSON
11291159 bytes=] given |response|.
11301160
1131- 1. [=Send a WebSocket message=] comprised of |serialized| over
1161+ 1. [=Send a connection message=] comprised of |serialized| over
11321162 |connection|.
11331163
113411641. Otherwise:
@@ -1252,14 +1282,14 @@ To <dfn>get valid top-level traversables by ids</dfn> given a [=/list=] of conte
125212821. Let |serialized| be the result of [=serialize an infra value to JSON
12531283 bytes=] given |body|.
12541284
1255- 1. [=list/For each=] |connection| in |session|'s [=session WebSocket connections=] :
1285+ 1. [=list/For each=] |connection| in |session|'s [=session connections=] :
12561286
1257- 1. [=Send a WebSocket message=] comprised of |serialized| over |connection|.
1287+ 1. [=Send a connection message=] comprised of |serialized| over |connection|.
12581288
12591289</div>
12601290
12611291<div algorithm>
1262- To <dfn>send an error response</dfn> given a [=WebSocket connection=]
1292+ To <dfn>send an error response</dfn> given a [=connection=]
12631293|connection|, |command id|, and |error code|:
12641294
126512951. Let |error data| be a new [=/map=] matching the <code> ErrorResponse</code>
@@ -1277,25 +1307,23 @@ To <dfn>send an error response</dfn> given a [=WebSocket connection=]
12771307 Note: |command id| can be null, in which case the <code> id</code> field will
12781308 also be set to null, not omitted from |response|.
12791309
1280- 1. [=Send a WebSocket message=] comprised of |response| over |connection|.
1310+ 1. [=Send a connection message=] comprised of |response| over |connection|.
12811311
12821312</div>
12831313
12841314
12851315<div algorithm>
12861316
1287- To <dfn>handle a connection closing</dfn> given a [=WebSocket connection=]
1288- |connection|:
1317+ To <dfn>handle a connection closing</dfn> given a [=connection=] |connection|:
12891318
129013191. If there is a [=BiDi session=] [=associated with connection=] |connection|:
12911320
12921321 1. Let |session| be the [=BiDi session=] [=associated with connection=]
12931322 |connection|.
12941323
1295- 1. Remove |connection| from |session|'s [=session WebSocket
1296- connections=] .
1324+ 1. Remove |connection| from |session|'s [=session connections=] .
12971325
1298- 1. Otherwise, if [=WebSocket connections not associated with a session=]
1326+ 1. Otherwise, if [=connections not associated with a session=]
12991327 [=list/contains=] |connection|, [=list/remove=] |connection| from that set.
13001328
13011329Note: This does not end any [=/session=] .
@@ -1307,16 +1335,11 @@ the listener if it wants.
13071335
13081336<div algorithm>
13091337
1310- To <dfn>close the WebSocket connections</dfn> given |session|:
1311-
1312- 1. For each |connection| in |session|'s [=session WebSocket
1313- connections=] :
1338+ To <dfn>close the connections</dfn> given |session|:
13141339
1315- 1. [=Start the WebSocket closing handshake=] with |connection|.
1340+ 1. For each |connection| in |session|'s [=session connections=] :
13161341
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|.
1342+ 1. Run [=close the connection=] steps for the |connection|.
13201343
13211344</div>
13221345
@@ -1338,11 +1361,9 @@ with parameters |session|, |capabilities|, and |flags| is:
13381361
133913621. [=Assert=] : |webSocketUrl| is true.
13401363
1341- 1. Let |listener| be the result of [=start listening for a WebSocket
1342- connection=] given |session|.
1364+ 1. Let |listener| be the result of [=start listening for a WebSocket connection=] given |session|.
13431365
1344- 1. Set |webSocketUrl| to the result of [=construct a WebSocket
1345- URL=] with |listener| and |session|.
1366+ 1. Set |webSocketUrl| to the result of [=construct a WebSocket URL=] with |listener| and |session|.
13461367
134713681. [=Set a property=] on |capabilities| named
13481369 "<code> webSocketUrl</code> " to |webSocketUrl|.
@@ -1361,7 +1382,8 @@ communicated out-of-band. An implementation that allows this <dfn>supports
13611382BiDi-only sessions</dfn> . At the time such an implementation is ready to accept
13621383requests to start a WebDriver session, it must:
13631384
1364- 1. [=Start listening for a WebSocket connection=] given null.
1385+ 1. Let |transport| be a [=WebSocket transport=] .
1386+ 1. Run [=start listening for a WebSocket connection=] for |transport| given null.
13651387
13661388</div>
13671389
@@ -1643,7 +1665,7 @@ To <dfn>end the session</dfn> given |session|:
16431665
16441666To <dfn>cleanup the session</dfn> given |session|:
16451667
1646- 1. [=Close the WebSocket connections=] with |session|.
1668+ 1. [=Close the connections=] with |session|.
16471669
164816701. For each |user context| in the [=set of user contexts=] :
16491671
@@ -2042,7 +2064,7 @@ The [=remote end steps=] given |session| and <var ignore>command parameters</var
20422064
204320651. Return [=success=] with data null, and in parallel run the following steps:
20442066
2045- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2067+ 1. Wait until the [=Send a connection message=] steps have been called with the
20462068 response to this command.
20472069
20482070 Issue: this is rather imprecise language, but hopefully it's clear that the
@@ -2664,7 +2686,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26642686 return [=error=] with [=error code=] [=unable to close browser=] , and then
26652687 run the following steps [=in parallel=] :
26662688
2667- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2689+ 1. Wait until the [=Send a connection message=] steps have been called with the
26682690 response to this command.
26692691
26702692 1. [=Cleanup the session=] with |session|.
@@ -2683,7 +2705,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26832705
268427061. Return [=success=] with data null, and run the following steps [=in parallel=] .
26852707
2686- 1. Wait until the [=Send a WebSocket message=] steps have been called with the
2708+ 1. Wait until the [=Send a connection message=] steps have been called with the
26872709 response to this command.
26882710
26892711 1. [=Cleanup the session=] with |session|.
@@ -2696,7 +2718,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
26962718 Note: For example this might include cleanly shutting down any OS-level
26972719 processes associated with the browser under automation, removing temporary
26982720 state, such as user profile data, created by the [=remote end=] while under
2699- automation, or shutting down the [=WebSocket Listener=] . Because of
2721+ automation, or shutting down the [=Connection Listener=] . Because of
27002722 differences between browsers and operating systems it is not possible to
27012723 specify in detail precise invariants [=local ends=] can depend on here.
27022724
0 commit comments