Skip to content

Commit e3d60e4

Browse files
committed
Capabilities: provide and use deserialization strategies.
This provides stronger language about how to convert a given capability to something that can be used in the rest of the spec.
1 parent 5cac417 commit e3d60e4

File tree

1 file changed

+125
-89
lines changed

1 file changed

+125
-89
lines changed

webdriver-spec.html

Lines changed: 125 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -2101,39 +2101,41 @@ <h3>Processing Capabilities</h3>
21012101
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
21022102
</ol>
21032103

2104-
<li><p>Let <var>desired capabilities</var> be the result of <a>getting a property</a>
2104+
<li><p>Let <var>all first match capabilities</var> be the result of <a>getting a property</a>
21052105
named "<code>firstMatch</code>" from <var>capabilities request</var>.
21062106

21072107
<ol>
2108-
<li><p>If <var>desired capabilities</var> is <a>undefined</a>,
2108+
<li><p>If <var>all first match capabilities</var> is <a>undefined</a>,
21092109
set the value to a JSON <a>List</a> with a single entry of an empty JSON <a>Object</a>.
21102110

2111-
<li><p>If <var>desired capabilities</var> is not a JSON <a>List</a>,
2111+
<li><p>If <var>all first match capabilities</var> is not a JSON <a>List</a>,
21122112
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
21132113
</ol>
21142114

2115-
<li><p>For each <var>current desired capabilities</var> corresponding
2116-
to an indexed property in <var>desired capabilities</var>:
2115+
<li><p>For each <var>first match capabilities</var> corresponding
2116+
to an indexed property in <var>all first match capabilities</var>:
21172117

21182118
<ol>
2119-
<li><p>If <var>current desired capabilities</var> is not a
2119+
<li><p>If <var>first match capabilities</var> is not a
21202120
JSON <a>Object</a>, return <a>error</a> with <a>error
21212121
code</a> <a>invalid argument</a>.
21222122

21232123
<li><p>Let <var>merged capabilities</var> be the result of
21242124
<a>trying</a> to <a data-lt="merging capabilities">merge
21252125
capabilities</a> with <var>required capabilities</var>
2126-
and <var>current desired capabilities</var> as arguments.
2126+
and <var>first match capabilities</var> as arguments.
21272127

21282128
<li><p>Let <var>matched capabilities</var> be the result of
2129-
<a>matching capabilities</a> with <var>merged capabilities</var>
2130-
as an argument.
2129+
<a>trying</a> to <a data-lt="matching capabilities">match
2130+
capabilities</a> with <var>merged capabilities</var> as an
2131+
argument.
21312132

2132-
<li><p>Return <var>matched capabilities</var> if it is
2133-
not <code>null</code>.
2133+
<li><p>If <var>matched capabilities</var> is
2134+
not <a><code>null</code></a> return
2135+
<var>matched capabilities</var>.
21342136
</ol>
21352137

2136-
<li><p>Return <code>null</code>.
2138+
<li><p>Return <a>success</a> with data <a><code>null</code></a>.
21372139
</ol>
21382140

21392141
<p>When <dfn>merging capabilities</dfn> with JSON <a>Object</a> arguments
@@ -2152,8 +2154,8 @@ <h3>Processing Capabilities</h3>
21522154
property</a> named <var>name</var> from <var>primary</var>.
21532155

21542156
<li><p>If <var>value</var> is not <a><code>null</code></a>
2155-
<a>set a property</a> <var>name</var> to <var>value</var>
2156-
on <var>result</var>.
2157+
<a>set a property</a> on <var>result</var> with name
2158+
<var>name</var> and value <var>value</var>.
21572159
</ol>
21582160

21592161
<li><p>If <var>secondary</var> is <a>undefined</a>, return <var>result</var>.
@@ -2173,12 +2175,11 @@ <h3>Processing Capabilities</h3>
21732175
<li><p>Run the substeps of the first matching condition:
21742176
<dl class=switch>
21752177
<dt><var>value</var> is <a><code>null</code></a>
2176-
<dt><var>value</var> and <var>primary value</var> are equal.
21772178
<dd>Do nothing.
21782179

21792180
<dt><var>primary value</var> is <a><code>undefined</code></a>
2180-
<dd><a>Set a property</a> named <var>name</var>
2181-
to <var>value</var> on <var>result</var>.
2181+
<dd><a>Set a property</a> on <var>result</var> with name
2182+
<var>name</var> and value <var>value</var>.
21822183

21832184
<dt>Otherwise
21842185
<dd>Return an <a>error</a> with <a>error code</a>
@@ -2189,6 +2190,18 @@ <h3>Processing Capabilities</h3>
21892190
<li><p>Return <var>result</var>.
21902191
</ol>
21912192

2193+
<aside class=note>
2194+
<p>The algorithm outlined in <a>matching capabilities</a> blithely
2195+
ignores real-world problems that make implemention less than
2196+
perfectly straightforward, particularly since capbilities can
2197+
interact in unforeseen ways.
2198+
2199+
<p>As an example, an implementation could have a capbility that gives
2200+
the path to the browser binary to use. This could cause
2201+
both <code>browserName</code> and <code>browserVersion</code> to be
2202+
impossible to match against until the browser process is started.
2203+
</aside>
2204+
21922205
<p>When <dfn>matching capabilities</dfn>
21932206
with JSON <a>Object</a> argument <var>capabilities</var>,
21942207
an <a>endpoint node</a> must take the following steps:
@@ -2199,16 +2212,16 @@ <h3>Processing Capabilities</h3>
21992212

22002213
<dl>
22012214
<dt>"<code>browserName</code>"
2202-
<dd>Lowercase name of the user agent.
2215+
<dd>Lowercase name of the user agent as a <a>string</a>.
22032216

22042217
<dt>"<code>browserVersion</code>"
2205-
<dd>The user agent version, as a string.
2218+
<dd>The user agent version, as a <a>string</a>.
22062219

22072220
<dt>"<code>platformName</code>"
2208-
<dd>Lowercase name of the current platform.
2221+
<dd>Lowercase name of the current platform as a <a>string</a>.
22092222

22102223
<dt>"<code>acceptInsecureCerts</code>"
2211-
<dd>Boolean initially set to false,
2224+
<dd><a>Boolean</a> initially set to <code>false</code>,
22122225
indicating the session will not implicitly trust untrusted
22132226
or self-signed TLS certificates on <a data-lt=go>navigation</a>.
22142227

@@ -2217,40 +2230,99 @@ <h3>Processing Capabilities</h3>
22172230
<a>commands</a> in <a href=#h-resizing-and-positioning-windows>Resizing and Positioning Windows</a>.
22182231
</dl>
22192232

2220-
<li><p>Add any implementation-specific capabilities as entries
2221-
to <var>matched capabilities</var>
2233+
<li><p>Optionally add <a>extension capabilities</a> as entries
2234+
to <var>matched capabilities</var>. The values of these may be
2235+
ellided, and there is no requirement that all
2236+
<a>extension capabilities</a> be added.
22222237

2223-
<p class=note>
2238+
<aside class=note>
2239+
<p>
2240+
This allows a <a>remote end</a> to add information that might be
2241+
useful to a <a>local end</a> without unnecessarily bloating the
2242+
response sent back to the user with (e.g.) an entire browser
2243+
profile.
2244+
2245+
<p>
22242246
For example, an implementation could choose to indicate that a
22252247
screenshot will be taken when returning an error by setting the
22262248
capability <code>selenium.screenshot-on-error</code>
22272249
to <code>true</code>.
2228-
</p>
2229-
2230-
<li><p>For each <var>capability name</var> corresponding to a
2231-
property in <var>capabilities</var>:
2250+
</aside>
22322251

2252+
<li><p>For each <var>name</var> and <var>value</var> corresponding
2253+
to <var>capability</var>'s <a>own properties</a>:
22332254
<ol>
2234-
<li><p>Let <var>capability value</var> be the value of
2235-
property <var>capability name</var> in <var>capabilities</var>.
2255+
<li><p>Run the substeps of the first matching condition:
2256+
<dl class=switch>
2257+
<dt><var>name</var> equals "<code>acceptInsecureCerts</code>"
2258+
<dd><p>If <var>value</var> is not a <a>boolean</a> return
2259+
an <a>error</a> with <a>error code</a> <a>invalid
2260+
argument</a>. Otherwise, let <var>capability value</var> be set
2261+
to <var>value</var>.
2262+
2263+
<dt><var>name</var> equals "<code>browserName</code>"
2264+
<dt><var>name</var> equals "<code>browserVersion</code>"
2265+
<dt><var>name</var> equals "<code>platformName</code>"
2266+
<dd><p>If <var>value</var> is not a <a>string</a> return
2267+
an <a>error</a> with an <a>error code</a> <a>invalid
2268+
argument</a>. Otherwise, let <var>capability value</var> be set
2269+
to <var>value</var>. return <var>value</var>.
2270+
2271+
<dt><var>name</var> equals "<code>pageLoadStrategy</code>"
2272+
<dd><p>Let <var>capability value</var> be the result
2273+
of <a>trying</a> to <a>deserialize as a page load strategy</a>
2274+
<var>value</var>.
2275+
2276+
<dt><var>name</var> equals "<code>proxy</code>"
2277+
<dd><p>Let <var>capability value</var> be the result
2278+
of <a>trying</a> to <a>deserialize as a proxy</a>
2279+
<var>value</var>.
2280+
2281+
<dt><var>name</var> equals "<code>timeouts</code>"
2282+
<dd><p>Let <var>capability value</var> be the result
2283+
of <a>trying</a> to <a>deserialize as a timeout</a>
2284+
<var>value</var>.
2285+
2286+
<dt><var>name</var> equals "<code>unhandledPromptBehavior</code>"
2287+
<dd><p>Let <var>capability value</var> be the result
2288+
of <a>trying</a> to <a>deserialize as an unhandled prompt behavior</a>
2289+
<var>value</var>.
2290+
2291+
<dt><var>name</var> is the name of an <a>extension capability</a>
2292+
<dd><p>Let <var>capability value</var> be the result
2293+
of <a>trying</a> to deserialize <var>value</var> in an
2294+
implmentation-specific way.
2295+
2296+
<dt>The <a>remote end</a> is an <a>endpoint node</a>
2297+
<dd>Let <var>capability value</var> be <a><code>null</code></a>.
2298+
2299+
<dt>Otherwise
2300+
<dd>Let <var>capability value</var> be set to <var>value</var>.
2301+
</dl>
22362302

2237-
<li><p>Run the substeps of the first matching <var>capability name</var>:
2303+
<li><p>If <var>capability value</var> is <a><code>null</code></a>
2304+
return <a>success</a> with data <a><code>null</code></a>.
2305+
2306+
<li><p>Run the substeps of the first matching <var>name</var>:
22382307

22392308
<dl class=switch>
22402309
<dt>"<code>browserName</code>"
22412310
<dd><p>If <var>capability value</var> is not a string equal to
22422311
the "<code>browserName</code>" entry in
2243-
<var>matched capabilities</var>, return <code>null</code>.
2312+
<var>matched capabilities</var>, return <a>success</a> with
2313+
data <a><code>null</code></a>.
22442314

22452315
<dt>"<code>browserVersion</code>"
22462316
<dd><p>Compare <var>capability value</var>
22472317
to the "<code>browserVersion</code>" entry in <var>matched capabilities</var>
22482318
using an implementation-defined comparison algorithm.
22492319
The comparison is to accept a <var>capability value</var>
22502320
that places constraints on the version using
2251-
the "<code>&lt;</code>", "<code>&lt;=</code>", "<code>&gt;</code>", and "<code>&gt;=</code>" operators.
2321+
the "<code>&lt;</code>", "<code>&lt;=</code>", "<code>&gt;</code>",
2322+
and "<code>&gt;=</code>" operators.
22522323

2253-
<p>If the two values do not match, return <code>null</code>.
2324+
<p>If the two values do not match, return <a>success</a> with
2325+
data <a><code>null</code></a>.
22542326

22552327
<p class=note>Version comparison is left as an implementation detail
22562328
since each user agent will likely have conflicting methods
@@ -2260,7 +2332,7 @@ <h3>Processing Capabilities</h3>
22602332
<dt>"<code>platformName</code>"
22612333
<dd><p>If <var>capability value</var> is not a string equal
22622334
to the "<code>platformName</code>" entry in <var>matched capabilities</var>,
2263-
return <code>null</code>.
2335+
return <a>success</a> with data <a><code>null</code></a>.
22642336

22652337
<div class=note>
22662338
<p>The following platform names are in common usage with
@@ -2289,67 +2361,31 @@ <h3>Processing Capabilities</h3>
22892361
and the <a>endpoint node</a> does not support <a>insecure TLS certificates</a>,
22902362
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
22912363

2292-
<p>Otherwise, set the "<code>acceptInsecureCerts</code>" entry
2293-
in <var>matched capabilities</var> to <var>capability value</var>
2294-
with the <code>null</code> value being set to <code>false</code>.
2295-
2296-
<dt>"<code>pageLoadStrategy</code>"
2297-
<dd><p>If <var>capability value</var> is not a keyword in the
2298-
<a>table of page load strategies</a>, return <a>error</a> with
2299-
<a>error code</a> <a>invalid argument</a>.
2300-
2301-
<p>Otherwise, set the "<code>pageLoadStrategy</code>" entry
2302-
in <var>matched capabilities</var> to <var>capability value</var>.
2303-
23042364
<dt>"<code>proxy</code>"
2305-
<dd><p>If <var>capability value</var> is not a <a>proxy configuration</a>,
2306-
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2307-
2308-
<p>If the <a>endpoint node</a> does not support the proxy
2365+
<dd><p>If the <a>endpoint node</a> does not support the proxy
23092366
configuration defined in <var>capability value</var>,
2310-
return <code>null</code>.
2311-
2312-
<p>Otherwise, set the "<code>proxy</code>" entry
2313-
in <var>matched capabilities</var> to <var>capability value</var>.
2314-
2315-
<dt>"<code>setWindowRect</code>"
2316-
<dd><p>If <var>capability value</var> is not a boolean
2317-
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2318-
2319-
<p>If <var>capability value</var> is not equal to the
2320-
"<code>setWindowRect</code>" entry in
2321-
<var>matched capabilities</var>, return <code>null</code>.
2322-
2323-
<dt>"<code>timeouts</code>"
2324-
<dd><p>If <var>capability value</var>
2325-
is not a <a>session timeouts configuration</a> object,
2326-
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2327-
2328-
<p>Otherwise, set the "<code>timeouts</code>" entry
2329-
in <var>matched capabilities</var> to <var>capability value</var>.
2330-
2331-
<dt>"<code>unhandledPromptBehavior</code>"
2332-
<dd><p>If <var>capability value</var> is not a <a>user prompt handler</a>
2333-
keyword, return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2334-
2335-
<p>Otherwise, set the "<code>unhandledPromptBehavior</code>" entry in
2336-
<var>matched capabilities</var> to <var>capability value</var>.
2367+
return <a>success</a> with data <a><code>null</code></a>.
23372368

23382369
<dt><strong>Otherwise</strong>
2339-
<dd><p>If <var>capability name</var> is not recognized
2340-
by the <a>endpoint node</a>, return <code>null</code>.
2341-
2342-
<p>Let <var>processed value</var> be the result of <a>trying</a>
2343-
implementation-specific steps to match on
2344-
<var>capability name</var> with <var>capability value</var>.
2345-
2346-
<p>Create a new entry in <var>matched capabilities</var>
2347-
with name <var>capability name</var> and value <var>processed value</var>.
2370+
<dd><p>If <var>name</var> is not the name of an
2371+
<a>extension capability</a> and the <a>remote end</a> is
2372+
an <a>endpoint node</a> return <a>success</a> with data
2373+
<code>null</code>.
2374+
2375+
<p>Let <var>matched value</var> be the result of <a>trying</a>
2376+
implementation-specific steps to match on <var>name</var>
2377+
with <var>capability value</var>. If the match is not
2378+
successful, return <a>success</a> with
2379+
data <a><code>null</code></a>.
23482380
</dl>
2381+
2382+
<li><p><a>Set a property</a> on <var>matched capability</var>
2383+
with name <var>name</var> and value <var>capability value</var>.
23492384
</ol>
23502385

2351-
<li><p>Return <var>matched capabilities</var>.
2386+
<li><p>Return <a>success</a> with data <var>matched capabilities</var>.
23522387
</ol>
2388+
23532389
</section> <!-- /Processing Capabilities -->
23542390
</section> <!-- /Capabilities -->
23552391

@@ -2544,7 +2580,7 @@ <h3>New Session</h3>
25442580
return <a>error</a> with <a>error code</a> <a>session not created</a> and
25452581
the error data from <var>capabilities result</var>.
25462582

2547-
<li><p>If <var>capabilities result</var> is <a>null</a>,
2583+
<li><p>If <var>capabilities result</var>'s data is <a>null</a>,
25482584
return <a>error</a> with <a>error code</a> <a>session not created</a>.
25492585

25502586
<li><p>Let <var>capabilities</var> be <var>capabilities result</var>’s data.

0 commit comments

Comments
 (0)