@@ -24,6 +24,7 @@ spec: RFC6455; urlPrefix: https://tools.ietf.org/html/rfc6455
24
24
text: %x1 denotes a text frame; url: section-5.2
25
25
text: Send a WebSocket Message; url: section-6.1
26
26
text: A WebSocket Message Has Been Received; url: section-6.2
27
+ text: Start The WebSocket Closing Handshake; url: section-7.1.2
27
28
text: The WebSocket Closing Handshake is Started; url: section-7.1.3
28
29
text: The WebSocket Connection is Closed; url: section-7.1.4
29
30
text: Fail the WebSocket Connection; url: section-7.1.7
@@ -40,6 +41,7 @@ spec: WEBDRIVER; urlPrefix: https://w3c.github.io/webdriver/
40
41
text: additional WebDriver capability; url: dfn-additional-webdriver-capability
41
42
text: additional capability deserialization algorithm; url: dfn-additional-capability-deserialization-algorithm
42
43
text: capability name; url: dfn-capability-name
44
+ text: close the session; url: dfn-close-the-session
43
45
text: create a session; url: dfn-create-a-session
44
46
text: dispatch actions; url: dfn-dispatch-actions
45
47
text: dispatch tick actions; url: dfn-dispatch-tick-actions
@@ -287,6 +289,7 @@ Command = {
287
289
}
288
290
289
291
CommandData = (
292
+ BrowserCommand //
290
293
BrowsingContextCommand //
291
294
InputCommand //
292
295
NetworkCommand //
@@ -470,6 +473,12 @@ with the following additional codes:
470
473
<dd> Tried to deserialize an unknown <code> SharedReference</code> .
471
474
</dl>
472
475
476
+ <dl>
477
+ <dt> <dfn>unable to close browser</dfn>
478
+ <dd> Tried to close the browser, but failed to do so.
479
+ </dl>
480
+
481
+
473
482
<pre class="cddl local-cddl">
474
483
ErrorCode = ("invalid argument" /
475
484
"invalid session id" /
@@ -479,6 +488,7 @@ ErrorCode = ("invalid argument" /
479
488
"no such node" /
480
489
"no such script" /
481
490
"session not created" /
491
+ "unable to close browser" /
482
492
"unknown command" /
483
493
"unknown error" /
484
494
"unsupported operation")
@@ -827,6 +837,8 @@ To <dfn>handle an incoming message</dfn> given a [=WebSocket connection=]
827
837
an error response=] given |connection|, null, and [=invalid argument=] , and
828
838
finally return.
829
839
840
+ 1. If |session| is not null and not in [=active sessions=] then return.
841
+
830
842
1. Match |parsed| against the [=remote end definition=] . If this results in a
831
843
match:
832
844
@@ -977,6 +989,23 @@ Note: This does not end any [=/session=].
977
989
Issue: Need to hook in to the session ending to allow the UA to close
978
990
the listener if it wants.
979
991
992
+ </div>
993
+
994
+ <div algorithm>
995
+
996
+ To <dfn>close the WebSocket connections</dfn> given |session|:
997
+
998
+ 1. For each |connection| in |session|'s[=session WebSocket
999
+ connections=] :
1000
+
1001
+ 1. [=Start the WebSocket closing handshake=] with |connection|.
1002
+
1003
+ Note: this will result in the steps in [=handle a connection closing=]
1004
+ being run for |connection|, which will clean up resources associated with
1005
+ |connection|.
1006
+
1007
+ </div>
1008
+
980
1009
## Establishing a Connection ## {#establishing}
981
1010
982
1011
WebDriver clients opt in to a bidirectional connection by requesting a
@@ -1172,6 +1201,7 @@ events for monitoring the status of the remote end.
1172
1201
1173
1202
<pre class="cddl remote-cddl">
1174
1203
SessionCommand = (
1204
+ session.End //
1175
1205
session.New //
1176
1206
session.Status //
1177
1207
session.Subscribe //
@@ -1186,7 +1216,26 @@ SessionResult = (session.StatusResult)
1186
1216
</pre>
1187
1217
1188
1218
<div algorithm>
1219
+ To <dfn>end the session</dfn> given |session|:
1220
+
1221
+ 1. Remove |session| from [=active sessions=] .
1222
+
1223
+ 1. If [=active sessions=] is [=list/empty=] , set the [=webdriver-active flag=]
1224
+ to false.
1225
+
1226
+ </div>
1227
+
1228
+ <div algorithm>
1229
+
1230
+ To <dfn>cleanup the session</dfn> given |session|:
1231
+
1232
+ 1. [=Close the WebSocket connections=] with |session|.
1233
+
1234
+ 1. Perform any implementation-specific cleanup steps.
1235
+
1236
+ </div>
1189
1237
1238
+ <div algorithm>
1190
1239
To <dfn>update the event map</dfn> , given
1191
1240
|session|, |requested event names|, |browsing contexts|, and |enabled|:
1192
1241
@@ -1479,6 +1528,50 @@ The [=remote end steps=] given |session| and |command parameters| are:
1479
1528
1480
1529
</div>
1481
1530
1531
+ #### The session.end Command #### {#command-session-end}
1532
+
1533
+ The <dfn export for=commands>session.end</dfn> command ends the current
1534
+ [=/session=] .
1535
+
1536
+ <dl>
1537
+ <dt> Command Type</dt>
1538
+ <dd>
1539
+ <pre class="cddl remote-cddl">
1540
+ session.End = {
1541
+ method: "session.end",
1542
+ params: EmptyParams
1543
+ }
1544
+
1545
+ </pre>
1546
+ </dd>
1547
+ <dt> Result Type</dt>
1548
+ <dd>
1549
+ <pre class="cddl">
1550
+ EmptyResult
1551
+ </pre>
1552
+ </dd>
1553
+ </dl>
1554
+
1555
+ <div algorithm="remote end steps for session.end">
1556
+
1557
+ The [=remote end steps=] given |session| and <var ignore> command parameters</var> are:
1558
+
1559
+ 1. [=End the session=] with |session|.
1560
+
1561
+ 1. Return [=success=] with data null, and in parallel run the following steps:
1562
+
1563
+ 1. Wait until the [=Send a WebSocket message=] steps have been called with the
1564
+ response to this command.
1565
+
1566
+ Issue: this is rather imprecise language, but hopefully it's clear that the
1567
+ intent is that we send the response to the command before starting shutdown
1568
+ of the connections.
1569
+
1570
+ 1. [=Cleanup the session=] with |session|.
1571
+
1572
+ </div>
1573
+
1574
+
1482
1575
#### The session.subscribe Command #### {#command-session-subscribe}
1483
1576
1484
1577
The <dfn export for=commands>session.subscribe</dfn> command enables certain events
@@ -1588,6 +1681,102 @@ The [=remote end steps=] with |session| and |command parameters| are:
1588
1681
1589
1682
</div>
1590
1683
1684
+ ## The browser Module ## {#module-browser}
1685
+
1686
+ The <dfn export for=modules>browser</dfn> module contains commands for
1687
+ managing the remote end browser process.
1688
+
1689
+ ### Definition ### {#module-browser-definition}
1690
+
1691
+ [=remote end definition=]
1692
+
1693
+ <pre class="cddl remote-cddl">
1694
+ BrowserCommand = (
1695
+ browser.Close
1696
+ )
1697
+ </pre>
1698
+
1699
+ [=local end definition=]
1700
+
1701
+ <!-- Nothing yet -->
1702
+ <pre class="cddl local-cddl">
1703
+ </pre>
1704
+
1705
+
1706
+ ### Commands ### {#module-browser-commands}
1707
+
1708
+ #### The browser.close Command #### {#command-browser-close}
1709
+
1710
+ The <dfn export for=commands>browser.close</dfn> command terminates all
1711
+ WebDriver sessions and cleans up automation state in the remote browser instance.
1712
+
1713
+ <dl>
1714
+ <dt> Command Type</dt>
1715
+ <dd>
1716
+ <pre class="cddl remote-cddl">
1717
+ browser.Close = {
1718
+ method: "browser.close",
1719
+ params: EmptyParams,
1720
+ }
1721
+ </pre>
1722
+ </dd>
1723
+ <dt> Return Type</dt>
1724
+ <dd>
1725
+ <pre class="cddl">
1726
+ EmptyResult
1727
+ </pre>
1728
+ </dd>
1729
+ </dl>
1730
+
1731
+ <div algorithm="remote end steps for browser.close">
1732
+ The [=remote end steps=] with |session| and <var ignore> command parameters</var> are:
1733
+
1734
+ 1. [=End the session=] with |session|.
1735
+
1736
+ 1. If [=active sessions=] is not [=list/empty=] an implementation may
1737
+ return [=error=] with [=error code=] [=unable to close browser=] , and then
1738
+ run the following steps [=in parallel=] :
1739
+
1740
+ 1. Wait until the [=Send a WebSocket message=] steps have been called with the
1741
+ response to this command.
1742
+
1743
+ 1. [=Cleanup the session=] with |session|.
1744
+
1745
+ Note: The behaviour in cases where the browser has multiple automation
1746
+ sessions is currently unspecified. It might be that any session can close the
1747
+ browser, or that only the final open session can actually close the browser,
1748
+ or only the first session started can. This behaviour might be fully
1749
+ specified in a future version of this specification.
1750
+
1751
+ 1. For each |active session| in [=active sessions=] :
1752
+
1753
+ 1. [=End the session=] |active session|.
1754
+
1755
+ 1. [=Cleanup the session=] with |active session|
1756
+
1757
+ 1. Return [=success=] with data null, and run the following steps [=in parallel=] .
1758
+
1759
+ 1. Wait until the [=Send a WebSocket message=] steps have been called with the
1760
+ response to this command.
1761
+
1762
+ 1. [=Cleanup the session=] with |session|.
1763
+
1764
+ 1. [=Close=] any [=top-level browsing contexts=] without [=prompting to unload=] .
1765
+
1766
+ Note: This implicitly only affects browsing contexts that were under
1767
+ automation in the first place.
1768
+
1769
+ 1. Perform implementation defined steps to clean up resources associated with
1770
+ the [=remote end=] under automation.
1771
+
1772
+ Note: For example this might include cleanly shutting down any OS-level
1773
+ processes associated with the browser under automation, removing temporary
1774
+ state, such as user profile data, created by the [=remote end=] while under
1775
+ automation, or shutting down the [=WebSocket Listener=] . Because of
1776
+ differences between browsers and operating systems it is not possible to
1777
+ specify in detail precise invariants [=local ends=] can depend on here.
1778
+
1779
+ </div>
1591
1780
1592
1781
## The browsingContext Module ## {#module-browsingContext}
1593
1782
0 commit comments