@@ -598,6 +598,9 @@ with the following additional codes:
598
598
<dt> <dfn>no such storage partition</dfn>
599
599
<dd> Tried to access data in a non-existent storage partition.
600
600
601
+ <dt> <dfn>no such user context</dfn>
602
+ <dd> Tried to reference an unknown [=user context=] .
603
+
601
604
<dt> <dfn>unable to close browser</dfn>
602
605
<dd> Tried to close the browser, but failed to do so.
603
606
@@ -625,6 +628,7 @@ ErrorCode = "invalid argument" /
625
628
"no such request" /
626
629
"no such script" /
627
630
"no such storage partition" /
631
+ "no such user context" /
628
632
"session not created" /
629
633
"unable to capture screen" /
630
634
"unable to close browser" /
@@ -1291,6 +1295,77 @@ access to that data in a {{Window}} global.
1291
1295
1292
1296
Issue: Define how this works.
1293
1297
1298
+ # User Contexts # {#user-contexts}
1299
+
1300
+ A <dfn>user context</dfn> represents a collection of zero or more
1301
+ [=/top-level traversables=] within a [=remote end=] . Each [=user context=] has
1302
+ an associated [=storage partition=] , so that [=remote end=] data is not shared
1303
+ between different [=user contexts=] .
1304
+
1305
+ Issue: Unclear that this is the best way to formally define the concept of a
1306
+ user context or the interaction with storage.
1307
+
1308
+ Note: The infra spec uses the term "user agent" to refer to the same concept as
1309
+ [=user context|user contexts=] . However, this is not compatible with usage of
1310
+ the term "user agent" to mean the entire web client with multiple [=user
1311
+ context|user contexts=] . Although this difference is not visible to web content,
1312
+ it is observed via WebDriver, so we avoid using this terminology.
1313
+
1314
+ A [=user context=] has a <dfn>user context id</dfn> , which is a unique string
1315
+ set upon the user context creation.
1316
+
1317
+ A [=navigable=] has an <dfn>associated user context</dfn> , which is a
1318
+ [=user context=] .
1319
+
1320
+ When a new [=/top-level traversable=] is created its [=associated user context=]
1321
+ is set to a user context in the [=set of user contexts=] .
1322
+
1323
+ Note: In some cases the user context is set by specification when the
1324
+ [=/top-level traversable=] is created, however in cases where no such
1325
+ requirements are present, the [=associated user context=] for a [=/top-level
1326
+ traversable=] is implemenation-defined.
1327
+
1328
+ Issue: Should we specify that [=/top-level traversables=] with a non-null
1329
+ opener have the same [=associated user context=] as their opener?
1330
+ Need to check if this is something existing implementations enforce.
1331
+
1332
+ A [=child navigable=] 's [=associated user context=] is it' s
1333
+ [=navigable/parent=] 's [=associated user context=] .
1334
+
1335
+ A [=user context=] which isn't the [=associated user context=] for any
1336
+ [=/top-level traversable=] is an <dfn>empty user context</dfn> .
1337
+
1338
+ The <dfn>default user context</dfn> is a [=user context=] with [=user context
1339
+ id=] <code> "default"</code> .
1340
+
1341
+ An implementation has a <dfn>set of user contexts</dfn> , which is a [=/set=] of
1342
+ [=user contexts=] . Initially this contains the [=default user context=] .
1343
+
1344
+ Implementations may [=set/append=] new [=user contexts=] to the [=set of user
1345
+ contexts=] at any time, for example in response to user actions.
1346
+
1347
+ Note: "At any time" here includes during implementation startup, so a given
1348
+ implementation might always have multiple entries in the [=set of user contexts=] .
1349
+
1350
+ Implementations may [=set/remove=] any [=empty user context=] , with exception of
1351
+ the [=default user context=] , from the [=set of user contexts=] at any
1352
+ time. However they are not required to remove such [=user contexts=] . [=User
1353
+ contexts=] that are not [=empty user contexts=] must not be removed from the
1354
+ [=set of user contexts=] .
1355
+
1356
+ <div algorithm>
1357
+ To <dfn>get user context</dfn> given |user context id|:
1358
+
1359
+ 1. For each |user context| in the [=set of user contexts=] :
1360
+
1361
+ 1. If |user context|'s [=user context id=] equals |user context id|:
1362
+
1363
+ 1. Return |user context|.
1364
+
1365
+ 1. Return null.
1366
+
1367
+ </div>
1368
+
1294
1369
# Modules # {#modules}
1295
1370
1296
1371
## The session Module ## {#module-session}
@@ -1865,16 +1940,44 @@ managing the remote end browser process.
1865
1940
1866
1941
<pre class="cddl remote-cddl">
1867
1942
BrowserCommand = (
1868
- browser.Close
1943
+ browser.Close //
1944
+ browser.CreateUserContext //
1945
+ browser.GetUserContexts //
1946
+ browser.RemoveUserContext
1869
1947
)
1870
1948
</pre>
1871
1949
1872
1950
[=local end definition=]
1873
1951
1874
1952
<!-- Nothing yet -->
1875
1953
<pre class="cddl local-cddl">
1954
+ BrowserResult = (
1955
+ browser.CreateUserContextResult /
1956
+ browser.GetUserContextsResult
1957
+ )
1958
+ </pre>
1959
+
1960
+
1961
+ ### Types ### {#module-browser-types}
1962
+
1963
+ #### The browser.UserContext Type #### {#type-browser-UserContext}
1964
+
1965
+ <pre class="cddl remote-cddl local-cddl">
1966
+ browser.UserContext = text;
1967
+ </pre>
1968
+
1969
+ The <code> browser.UserContext</code> unique identifies a [=user context=] .
1970
+
1971
+ #### The browser.UserContextInfo Type #### {#type-browser-UserContextInfo}
1972
+
1973
+ <pre class="cddl remote-cddl local-cddl">
1974
+ browser.UserContextInfo = {
1975
+ userContext: browser.UserContext
1976
+ }
1876
1977
</pre>
1877
1978
1979
+ The <code> browser.UserContextInfo</code> type represents properties of a [=user
1980
+ context=] .
1878
1981
1879
1982
### Commands ### {#module-browser-commands}
1880
1983
@@ -1936,9 +2039,6 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
1936
2039
1937
2040
1. [=Close=] any [=top-level browsing contexts=] without [=prompting to unload=] .
1938
2041
1939
- Note: This implicitly only affects browsing contexts that were under
1940
- automation in the first place.
1941
-
1942
2042
1. Perform implementation defined steps to clean up resources associated with
1943
2043
the [=remote end=] under automation.
1944
2044
@@ -1951,6 +2051,145 @@ The [=remote end steps=] with |session| and <var ignore>command parameters</var>
1951
2051
1952
2052
</div>
1953
2053
2054
+ #### The browser.createUserContext Command #### {#command-browser-createUserContext}
2055
+
2056
+ The <dfn export for=commands>browser.createUserContext</dfn> command creates a
2057
+ [=user context=] .
2058
+
2059
+ <dl>
2060
+ <dt> Command Type</dt>
2061
+ <dd>
2062
+ <pre class="cddl remote-cddl">
2063
+ browser.CreateUserContext = (
2064
+ method: "browser.createUserContext",
2065
+ params: EmptyParams,
2066
+ )
2067
+ </pre>
2068
+ </dd>
2069
+ <dt> Return Type</dt>
2070
+ <dd>
2071
+ <pre class="cddl local-cddl">
2072
+ browser.CreateUserContextResult = browser.UserContextInfo
2073
+ </pre>
2074
+ </dd>
2075
+ </dl>
2076
+
2077
+ <div algorithm="remote end steps for browser.createUserContext">
2078
+
2079
+ The [=remote end steps=] are:
2080
+
2081
+ 1. Let |user context| be a new [=user context=] .
2082
+
2083
+ 1. [=set/Append=] |user context| to the [=set of user contexts=] .
2084
+
2085
+ 1. Let |user context info| be a [=/map=] matching the
2086
+ <code> browser.UserContextInfo</code> production with the
2087
+ <code> userContext</code> field set to |user context|'s [=user context id=] .
2088
+
2089
+ 1. Return [=success=] with data |user context info|.
2090
+
2091
+ </div>
2092
+
2093
+
2094
+ #### The browser.getUserContexts Command #### {#command-browser-getUserContexts}
2095
+
2096
+ The <dfn export for=commands>browser.getUserContexts</dfn> command returns a
2097
+ list of [=user context=] s.
2098
+
2099
+ <dl>
2100
+ <dt> Command Type</dt>
2101
+ <dd>
2102
+ <pre class="cddl remote-cddl">
2103
+ browser.GetUserContexts = (
2104
+ method: "browser.getUserContexts",
2105
+ params: EmptyParams,
2106
+ )
2107
+ </pre>
2108
+ </dd>
2109
+ <dt> Return Type</dt>
2110
+ <dd>
2111
+ <pre class="cddl local-cddl">
2112
+ browser.GetUserContextsResult = {
2113
+ userContexts: [ + browser.UserContextInfo]
2114
+ }
2115
+ </pre>
2116
+ </dd>
2117
+ </dl>
2118
+
2119
+ <div algorithm="remote end steps for browser.getUserContexts">
2120
+
2121
+ The [=remote end steps=] are:
2122
+
2123
+ 1. Let |user contexts| be an empty [=/list=] .
2124
+
2125
+ 1. For each |user context| in the [=set of user contexts=] :
2126
+
2127
+ 1. Let |user context info| be a [=/map=] matching the
2128
+ <code> browser.UserContextInfo</code> production with the
2129
+ <code> userContext</code> field set to |user context|'s [=user context id=] .
2130
+
2131
+ 1. [=list/Append=] |user context info| to |user contexts|.
2132
+
2133
+ 1. Let |result| be a [=/map=] matching the
2134
+ <code> browser.GetUserContextsResult</code> production with the
2135
+ <code> userContexts</code> field set to |user contexts|.
2136
+
2137
+ 1. Return [=success=] with data |result|.
2138
+
2139
+ </div>
2140
+
2141
+
2142
+ #### The browser.removeUserContext Command #### {#command-browser-removeUserContext}
2143
+
2144
+ The <dfn export for=commands>browser.removeUserContext</dfn> command closes a
2145
+ user context and all browsing contexts in it without running
2146
+ <code> beforeunload</code> handlers.
2147
+
2148
+ <dl>
2149
+ <dt> Command Type</dt>
2150
+ <dd>
2151
+ <pre class="cddl remote-cddl">
2152
+ browser.RemoveUserContext = (
2153
+ method: "browser.removeUserContext",
2154
+ params: {
2155
+ userContext: browser.UserContext
2156
+ },
2157
+ )
2158
+ </pre>
2159
+ </dd>
2160
+ <dt> Return Type</dt>
2161
+ <dd>
2162
+ <pre class="cddl">
2163
+ EmptyResult
2164
+ </pre>
2165
+ </dd>
2166
+ </dl>
2167
+
2168
+ <div algorithm="remote end steps for browser.removeUserContext">
2169
+
2170
+ The [=remote end steps=] with |command parameters| are:
2171
+
2172
+ 1. Let |user context id| be |command parameters|["<code>userContext</code>"] .
2173
+
2174
+ 1. If |user context id| is <code> "default"</code> , return [=error=] with [=error
2175
+ code=] [=invalid argument=] .
2176
+
2177
+ 1. Set |user context| to [=get user context=] with |user context id|.
2178
+
2179
+ 1. If |user context| is null, return [=error=] with [=error code=] [=no such user context=] .
2180
+
2181
+ 1. For each [=/top-level traversable=] |navigable|:
2182
+
2183
+ 1. If |navigable|'s [=associated user context=] is |user context|:
2184
+
2185
+ 1. [=Close=] |navigable| without [=prompting to unload=] .
2186
+
2187
+ 1. [=set/Remove=] |user context| for the [=set of user contexts=] .
2188
+
2189
+ 1. Return [=success=] with data null.
2190
+
2191
+ </div>
2192
+
1954
2193
## The browsingContext Module ## {#module-browsingContext}
1955
2194
1956
2195
The <dfn export for=modules>browsingContext</dfn> module contains commands and
@@ -2065,9 +2304,10 @@ To <dfn export>get a browsing context</dfn> given |context id|:
2065
2304
browsingContext.InfoList = [*browsingContext.Info]
2066
2305
2067
2306
browsingContext.Info = {
2307
+ children: browsingContext.InfoList / null,
2068
2308
context: browsingContext.BrowsingContext,
2069
2309
url: text,
2070
- children: browsingContext.InfoList / null
2310
+ userContext: browser.UserContext
2071
2311
? parent: browsingContext.BrowsingContext / null,
2072
2312
}
2073
2313
</pre>
@@ -2142,18 +2382,22 @@ To <dfn>get the browsing context info</dfn> given |context|,
2142
2382
2143
2383
1. Set |child infos| to an empty [=/list=] .
2144
2384
2145
- 1. For each |context| of |child contexts|:
2385
+ 1. For each |child context| of |child contexts|:
2146
2386
2147
2387
1. Let |info| be the result of [=get the browsing context info=] given
2148
- |context|, |child depth|, and false.
2388
+ |child context|, |child depth|, and false.
2149
2389
2150
2390
1. Append |info| to |child infos|
2151
2391
2392
+ 1. Let |user context| be |context|'s [=associated user context=] .
2393
+
2152
2394
1. Let |context info| be a [=/map=] matching the
2153
2395
<code> browsingContext.Info</code> production with the <code> context</code>
2154
2396
field set to |context id|, the <code> parent</code> field set to |parent id|
2155
2397
if |is root| is <code> true</code> , or unset otherwise, the <code> url</code>
2156
- field set to |url|, and the <code> children</code> field set to |child infos|.
2398
+ field set to |url|, the <code> userContext</code> field set to
2399
+ |user context|'s [=user context id=] , and the <code> children</code> field
2400
+ set to |child infos|.
2157
2401
2158
2402
1. Return |context info|.
2159
2403
@@ -2769,7 +3013,8 @@ The <dfn export for=commands>browsingContext.create</dfn> command creates a new
2769
3013
browsingContext.CreateParameters = {
2770
3014
type: browsingContext.CreateType,
2771
3015
? referenceContext: browsingContext.BrowsingContext,
2772
- ? background: bool .default false
3016
+ ? background: bool .default false,
3017
+ ? userContext: browser.UserContext / null
2773
3018
}
2774
3019
</pre>
2775
3020
</dd>
@@ -2802,13 +3047,28 @@ The [=remote end steps=] with |command parameters| are:
2802
3047
1. If the implementation is unable to create a new browsing context for any
2803
3048
reason then return [=error=] with [=error code=] [=unsupported operation=] .
2804
3049
3050
+ 1. Let |user context| be the [=default user context=] if |reference context|
3051
+ is null, and |reference context|' [=associated user context=] otherwise.
3052
+
3053
+ 1. If |command parameters|[<code>userContext</code>] is present and is not null:
3054
+
3055
+ 1. Set |user context| to [=get user context=] with |command parameters|["<code>userContext</code>"] .
3056
+
3057
+ 1. If |user context| is null, return [=error=] with [=error code=] [=no such user context=] .
3058
+
3059
+ 1. If the implementation is unable to create a new [=/top-level traversable=]
3060
+ with [=associated user context=] |user context| for any reason, return
3061
+ [=error=] with [=error code=] [=unsupported operation=] .
3062
+
2805
3063
<!-- This is based on step 5 of https://w3c.github.io/webdriver/#new-window,
2806
3064
but without using the "current browsing context" concept. -->
2807
3065
1. Create a new [=top-level browsing context=] by running the [=window open
2808
- steps=] with <var ignore> url</var> set to "<code> about:blank</code> ",
2809
- <var ignore> target</var> set to the empty string, and
2810
- <var ignore> features</var> set to "<code> noopener</code> ". Which OS window the new [=/browsing context=]
2811
- is created in depends on |type| and |reference context|:
3066
+ steps=] with <var ignore> url</var> set to "<code> about:blank</code> ", <var
3067
+ ignore> target</var> set to the empty string, and <var ignore> features</var>
3068
+ set to "<code> noopener</code> ", and setting the [=associated user context=]
3069
+ for the newly created [=/top-level traversable=] to |user context|. Which OS
3070
+ window the new [=/browsing context=] is created in depends on |type| and
3071
+ |reference context|:
2812
3072
2813
3073
* If |type| is "<code> tab</code> " and the implementation supports
2814
3074
multiple browsing contexts in the same OS window:
0 commit comments