@@ -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,72 @@ 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=] .
898
886
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=] .
901
888
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.
904
890
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.
907
892
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.
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
+ 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.
914
925
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:
917
933
918
934
<div>
919
935
920
936
When a client [=establishes a WebSocket connection=] |connection| by
921
937
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
938
+ implementation must proceed according to the WebSocket
939
+ [=server-side requirements=] , with the following steps run when deciding whether to
924
940
accept the incoming connection:
925
941
926
942
1. Let |resource name| be the resource name from [=reading the
@@ -936,8 +952,7 @@ accept the incoming connection:
936
952
connection should be accepted, and if it is not stop running these
937
953
steps and act as if the requested service is not available.
938
954
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=] .
941
956
942
957
1. Return.
943
958
@@ -955,25 +970,36 @@ accept the incoming connection:
955
970
connection should be accepted, and if it is not stop running these
956
971
steps and act as if the requested service is not available.
957
972
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=]
960
975
when a server chooses to accept an incoming connection.
961
976
962
977
Issue: Do we support > 1 connection for a single session?
963
978
964
979
</div>
965
980
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]] .
969
991
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:
974
997
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|.
977
1003
978
1004
<div algorithm>
979
1005
@@ -1031,8 +1057,8 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
1031
1057
[=implementation-defined=] [=listener/host=] , [=listener/port=] ,
1032
1058
[=listener/secure flag=] , and an empty [=list of WebSocket resources=] .
1033
1059
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|.
1036
1062
1037
1063
1. Append |resource name| to the [=list of WebSocket resources=] for
1038
1064
|listener|.
@@ -1045,15 +1071,15 @@ To <dfn>start listening for a WebSocket connection</dfn> given a
1045
1071
</div>
1046
1072
1047
1073
Note: 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
1049
1075
an [=endpoint node=] supports at most one session at a time, so it's
1050
1076
expected to only have a single listener.
1051
1077
1052
1078
Note: For an [=endpoint node=] the [=listener/host=] in the above steps will
1053
1079
typically be "<code> localhost</code> ".
1054
1080
1055
1081
<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=]
1057
1083
|connection|, type |type| and data |data|:
1058
1084
1059
1085
1. 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=]
1069
1095
is used for UTF-8 errors.
1070
1096
1071
1097
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.
1098
+ let |session| be that session. Otherwise if |connection| is in [=connections not associated with a session=] ,
1099
+ let |session| be null. Otherwise, return.
1075
1100
1076
1101
1. Let |parsed| be the result of [=parse JSON into Infra values|parsing JSON
1077
1102
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=]
1116
1141
1. If |method| is "<code> session.new</code> ", let |session| be the entry in
1117
1142
the list of [=active sessions=] whose [=session ID=] is equal to the
1118
1143
"<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=] .
1122
1146
1123
1147
1. Let |response| be a new [=/map=] matching the <code> CommandResponse</code>
1124
1148
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=]
1128
1152
1. Let |serialized| be the result of [=serialize an infra value to JSON
1129
1153
bytes=] given |response|.
1130
1154
1131
- 1. [=Send a WebSocket message=] comprised of |serialized| over
1155
+ 1. [=Send a connection message=] comprised of |serialized| over
1132
1156
|connection|.
1133
1157
1134
1158
1. Otherwise:
@@ -1252,14 +1276,14 @@ To <dfn>get valid top-level traversables by ids</dfn> given a [=/list=] of conte
1252
1276
1. Let |serialized| be the result of [=serialize an infra value to JSON
1253
1277
bytes=] given |body|.
1254
1278
1255
- 1. [=list/For each=] |connection| in |session|'s [=session WebSocket connections=] :
1279
+ 1. [=list/For each=] |connection| in |session|'s [=session connections=] :
1256
1280
1257
- 1. [=Send a WebSocket message=] comprised of |serialized| over |connection|.
1281
+ 1. [=Send a connection message=] comprised of |serialized| over |connection|.
1258
1282
1259
1283
</div>
1260
1284
1261
1285
<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=]
1263
1287
|connection|, |command id|, and |error code|:
1264
1288
1265
1289
1. 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=]
1277
1301
Note: |command id| can be null, in which case the <code> id</code> field will
1278
1302
also be set to null, not omitted from |response|.
1279
1303
1280
- 1. [=Send a WebSocket message=] comprised of |response| over |connection|.
1304
+ 1. [=Send a connection message=] comprised of |response| over |connection|.
1281
1305
1282
1306
</div>
1283
1307
1284
1308
1285
1309
<div algorithm>
1286
1310
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|:
1289
1312
1290
1313
1. If there is a [=BiDi session=] [=associated with connection=] |connection|:
1291
1314
1292
1315
1. Let |session| be the [=BiDi session=] [=associated with connection=]
1293
1316
|connection|.
1294
1317
1295
- 1. Remove |connection| from |session|'s [=session WebSocket
1296
- connections=] .
1318
+ 1. Remove |connection| from |session|'s [=session connections=] .
1297
1319
1298
- 1. Otherwise, if [=WebSocket connections not associated with a session=]
1320
+ 1. Otherwise, if [=connections not associated with a session=]
1299
1321
[=list/contains=] |connection|, [=list/remove=] |connection| from that set.
1300
1322
1301
1323
Note: This does not end any [=/session=] .
@@ -1307,16 +1329,11 @@ the listener if it wants.
1307
1329
1308
1330
<div algorithm>
1309
1331
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|:
1314
1333
1315
- 1. [=Start the WebSocket closing handshake=] with |connection|.
1334
+ 1. For each |connection| in |session|'s [=session connections=] :
1316
1335
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|.
1320
1337
1321
1338
</div>
1322
1339
@@ -1338,11 +1355,9 @@ with parameters |session|, |capabilities|, and |flags| is:
1338
1355
1339
1356
1. [=Assert=] : |webSocketUrl| is true.
1340
1357
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|.
1343
1359
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|.
1346
1361
1347
1362
1. [=Set a property=] on |capabilities| named
1348
1363
"<code> webSocketUrl</code> " to |webSocketUrl|.
@@ -1361,7 +1376,8 @@ communicated out-of-band. An implementation that allows this <dfn>supports
1361
1376
BiDi-only sessions</dfn> . At the time such an implementation is ready to accept
1362
1377
requests to start a WebDriver session, it must:
1363
1378
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.
1365
1381
1366
1382
</div>
1367
1383
@@ -1643,7 +1659,7 @@ To <dfn>end the session</dfn> given |session|:
1643
1659
1644
1660
To <dfn>cleanup the session</dfn> given |session|:
1645
1661
1646
- 1. [=Close the WebSocket connections=] with |session|.
1662
+ 1. [=Close the connections=] with |session|.
1647
1663
1648
1664
1. For each |user context| in the [=set of user contexts=] :
1649
1665
@@ -2042,7 +2058,7 @@ The [=remote end steps=] given |session| and <var ignore>command parameters</var
2042
2058
2043
2059
1. Return [=success=] with data null, and in parallel run the following steps:
2044
2060
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
2046
2062
response to this command.
2047
2063
2048
2064
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>
2664
2680
return [=error=] with [=error code=] [=unable to close browser=] , and then
2665
2681
run the following steps [=in parallel=] :
2666
2682
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
2668
2684
response to this command.
2669
2685
2670
2686
1. [=Cleanup the session=] with |session|.
@@ -2683,7 +2699,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
2683
2699
2684
2700
1. Return [=success=] with data null, and run the following steps [=in parallel=] .
2685
2701
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
2687
2703
response to this command.
2688
2704
2689
2705
1. [=Cleanup the session=] with |session|.
@@ -2696,7 +2712,7 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
2696
2712
Note: For example this might include cleanly shutting down any OS-level
2697
2713
processes associated with the browser under automation, removing temporary
2698
2714
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
2700
2716
differences between browsers and operating systems it is not possible to
2701
2717
specify in detail precise invariants [=local ends=] can depend on here.
2702
2718
0 commit comments