@@ -33,7 +33,7 @@ spec: RFC6455; urlPrefix: https://datatracker.ietf.org/doc/html/rfc6455
33
33
text: Reading the Client's Opening Handshake; url: section-4.2.1
34
34
text: %x1 denotes a text frame; url: section-5.2
35
35
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
37
37
text: Start The WebSocket Closing Handshake; url: section-7.1.2
38
38
text: The WebSocket Closing Handshake is Started; url: section-7.1.3
39
39
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|:
871
871
872
872
# Transport # {#transport}
873
873
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
-
880
874
Note: The encoding of [=commands=] and [=events=] as messages is
881
875
similar to JSON-RPC, but this specification does not normatively
882
876
reference it. [[JSON-RPC]] The normative requirements on [=remote ends=]
883
877
are instead given as a precise processing model, while no
884
878
normative requirements are given for [=local ends=] .
885
879
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=] .
888
882
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=] .
892
884
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=] .
898
888
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.
901
890
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.
904
892
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.
907
895
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.
911
901
912
902
A [=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}
914
915
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:
917
930
918
931
<div>
919
932
920
933
When a client [=establishes a WebSocket connection=] |connection| by
921
934
connecting 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
924
937
accept the incoming connection:
925
938
926
939
1. Let |resource name| be the resource name from [=reading the
@@ -936,8 +949,7 @@ accept the incoming connection:
936
949
connection should be accepted, and if it is not stop running these
937
950
steps and act as if the requested service is not available.
938
951
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=] .
941
953
942
954
1. Return.
943
955
@@ -955,25 +967,40 @@ accept the incoming connection:
955
967
connection should be accepted, and if it is not stop running these
956
968
steps and act as if the requested service is not available.
957
969
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=]
960
972
when a server chooses to accept an incoming connection.
961
973
962
974
Issue: Do we support > 1 connection for a single session?
963
975
964
976
</div>
965
977
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.
969
995
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:
974
998
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|.
977
1004
978
1005
<div algorithm>
979
1006
@@ -1031,8 +1058,8 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
1031
1058
[=implementation-defined=] [=listener/host=] , [=listener/port=] ,
1032
1059
[=listener/secure flag=] , and an empty [=list of WebSocket resources=] .
1033
1060
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|.
1036
1063
1037
1064
1. Append |resource name| to the [=list of WebSocket resources=] for
1038
1065
|listener|.
@@ -1045,15 +1072,15 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
1045
1072
</div>
1046
1073
1047
1074
Note: 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
1049
1076
an [=endpoint node=] supports at most one session at a time, so it's
1050
1077
expected to only have a single listener.
1051
1078
1052
1079
Note: For an [=endpoint node=] the [=listener/host=] in the above steps will
1053
1080
typically be "<code> localhost</code> ".
1054
1081
1055
1082
<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=]
1057
1084
|connection|, type |type| and data |data|:
1058
1085
1059
1086
1. 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=]
1069
1096
is used for UTF-8 errors.
1070
1097
1071
1098
1. 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.
1075
1101
1076
1102
1. Let |parsed| be the result of [=parse JSON into Infra values|parsing JSON
1077
1103
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=]
1116
1142
1. If |method| is "<code> session.new</code> ", let |session| be the entry in
1117
1143
the list of [=active sessions=] whose [=session ID=] is equal to the
1118
1144
"<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=] .
1122
1147
1123
1148
1. Let |response| be a new [=/map=] matching the <code> CommandResponse</code>
1124
1149
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=]
1128
1153
1. Let |serialized| be the result of [=serialize an infra value to JSON
1129
1154
bytes=] given |response|.
1130
1155
1131
- 1. [=Send a WebSocket message=] comprised of |serialized| over
1156
+ 1. [=Send a connection message=] comprised of |serialized| over
1132
1157
|connection|.
1133
1158
1134
1159
1. Otherwise:
@@ -1252,14 +1277,14 @@ To <dfn>get valid top-level traversables by ids</dfn> given a [=/list=] of conte
1252
1277
1. Let |serialized| be the result of [=serialize an infra value to JSON
1253
1278
bytes=] given |body|.
1254
1279
1255
- 1. [=list/For each=] |connection| in |session|'s [=session WebSocket connections=] :
1280
+ 1. [=list/For each=] |connection| in |session|'s [=session connections=] :
1256
1281
1257
- 1. [=Send a WebSocket message=] comprised of |serialized| over |connection|.
1282
+ 1. [=Send a connection message=] comprised of |serialized| over |connection|.
1258
1283
1259
1284
</div>
1260
1285
1261
1286
<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=]
1263
1288
|connection|, |command id|, and |error code|:
1264
1289
1265
1290
1. 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=]
1277
1302
Note: |command id| can be null, in which case the <code> id</code> field will
1278
1303
also be set to null, not omitted from |response|.
1279
1304
1280
- 1. [=Send a WebSocket message=] comprised of |response| over |connection|.
1305
+ 1. [=Send a connection message=] comprised of |response| over |connection|.
1281
1306
1282
1307
</div>
1283
1308
1284
1309
1285
1310
<div algorithm>
1286
1311
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|:
1289
1313
1290
1314
1. If there is a [=BiDi session=] [=associated with connection=] |connection|:
1291
1315
1292
1316
1. Let |session| be the [=BiDi session=] [=associated with connection=]
1293
1317
|connection|.
1294
1318
1295
- 1. Remove |connection| from |session|'s [=session WebSocket
1296
- connections=] .
1319
+ 1. Remove |connection| from |session|'s [=session connections=] .
1297
1320
1298
- 1. Otherwise, if [=WebSocket connections not associated with a session=]
1321
+ 1. Otherwise, if [=connections not associated with a session=]
1299
1322
[=list/contains=] |connection|, [=list/remove=] |connection| from that set.
1300
1323
1301
1324
Note: This does not end any [=/session=] .
@@ -1307,16 +1330,11 @@ the listener if it wants.
1307
1330
1308
1331
<div algorithm>
1309
1332
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|:
1314
1334
1315
- 1. [=Start the WebSocket closing handshake=] with |connection|.
1335
+ 1. For each |connection| in |session|'s [=session connections=] :
1316
1336
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|.
1320
1338
1321
1339
</div>
1322
1340
@@ -1338,11 +1356,9 @@ with parameters |session|, |capabilities|, and |flags| is:
1338
1356
1339
1357
1. [=Assert=] : |webSocketUrl| is true.
1340
1358
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|.
1343
1360
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|.
1346
1362
1347
1363
1. [=Set a property=] on |capabilities| named
1348
1364
"<code> webSocketUrl</code> " to |webSocketUrl|.
@@ -1361,7 +1377,8 @@ communicated out-of-band. An implementation that allows this <dfn>supports
1361
1377
BiDi-only sessions</dfn> . At the time such an implementation is ready to accept
1362
1378
requests to start a WebDriver session, it must:
1363
1379
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.
1365
1382
1366
1383
</div>
1367
1384
@@ -1643,7 +1660,7 @@ To <dfn>end the session</dfn> given |session|:
1643
1660
1644
1661
To <dfn>cleanup the session</dfn> given |session|:
1645
1662
1646
- 1. [=Close the WebSocket connections=] with |session|.
1663
+ 1. [=Close the connections=] with |session|.
1647
1664
1648
1665
1. For each |user context| in the [=set of user contexts=] :
1649
1666
@@ -2042,7 +2059,7 @@ The [=remote end steps=] given |session| and <var ignore>command parameters</var
2042
2059
2043
2060
1. Return [=success=] with data null, and in parallel run the following steps:
2044
2061
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
2046
2063
response to this command.
2047
2064
2048
2065
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>
2664
2681
return [=error=] with [=error code=] [=unable to close browser=] , and then
2665
2682
run the following steps [=in parallel=] :
2666
2683
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
2668
2685
response to this command.
2669
2686
2670
2687
1. [=Cleanup the session=] with |session|.
@@ -2683,7 +2700,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
2683
2700
2684
2701
1. Return [=success=] with data null, and run the following steps [=in parallel=] .
2685
2702
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
2687
2704
response to this command.
2688
2705
2689
2706
1. [=Cleanup the session=] with |session|.
@@ -2696,7 +2713,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
2696
2713
Note: For example this might include cleanly shutting down any OS-level
2697
2714
processes associated with the browser under automation, removing temporary
2698
2715
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
2700
2717
differences between browsers and operating systems it is not possible to
2701
2718
specify in detail precise invariants [=local ends=] can depend on here.
2702
2719
0 commit comments