Skip to content

Commit 9eb3cd9

Browse files
committed
Capabilities: validate all capabilities when processing.
This will mean fast failure in intermediary nodes. Also fix up some typos Closes #701. Closes #716
1 parent e3d60e4 commit 9eb3cd9

File tree

1 file changed

+113
-86
lines changed

1 file changed

+113
-86
lines changed

webdriver-spec.html

Lines changed: 113 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ <h3>Algorithms</h3>
771771

772772
<p>When calling a fallible algorithm,
773773
the construct “Let <var>result</var> be the result
774-
of <dfn>trying</dfn> to call <var>algorithm</var>
774+
of <dfn data-lt="try">trying</dfn> to call <var>algorithm</var>
775775
is equivalent to
776776

777777
<ol>
@@ -2097,8 +2097,9 @@ <h3>Processing Capabilities</h3>
20972097
<li><p>If <var>required capabilities</var> is <a>undefined</a>,
20982098
set the value to an empty JSON <a>Object</a>.
20992099

2100-
<li><p>If <var>required capabilities</var> is not a JSON <a>Object</a>,
2101-
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2100+
<li><p>Let <var>required capabilities</var> be the result
2101+
of <a>trying</a> to <a>validate capabilities</a> with
2102+
argument <var>required capabilities</var>.
21022103
</ol>
21032104

21042105
<li><p>Let <var>all first match capabilities</var> be the result of <a>getting a property</a>
@@ -2112,13 +2113,13 @@ <h3>Processing Capabilities</h3>
21122113
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
21132114
</ol>
21142115

2116+
<!-- Validate all entries first so we fail as quickly as possible -->
21152117
<li><p>For each <var>first match capabilities</var> corresponding
21162118
to an indexed property in <var>all first match capabilities</var>:
2117-
21182119
<ol>
2119-
<li><p>If <var>first match capabilities</var> is not a
2120-
JSON <a>Object</a>, return <a>error</a> with <a>error
2121-
code</a> <a>invalid argument</a>.
2120+
<li><p>Let <var>first match capabilities</var> be the result
2121+
of <a>trying</a> to <a>validate capabilities</a> with argument
2122+
<var>first match capabilities</var>.
21222123

21232124
<li><p>Let <var>merged capabilities</var> be the result of
21242125
<a>trying</a> to <a data-lt="merging capabilities">merge
@@ -2138,6 +2139,79 @@ <h3>Processing Capabilities</h3>
21382139
<li><p>Return <a>success</a> with data <a><code>null</code></a>.
21392140
</ol>
21402141

2142+
<p>When required to <dfn>validate capabilities</dfn> with
2143+
argument <var>capability</var>:
2144+
2145+
<ol>
2146+
<li><p>If <var>capability</var> is not a JSON <a>Object</a> return
2147+
an <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2148+
2149+
<li><p>Let <var>result</var> be an empty JSON <a>Object</a>.
2150+
2151+
<li><p>For each enumerable <a>own property</a>
2152+
in <var>capability</var>, run the following substeps:
2153+
<ol>
2154+
<li><p>Let <var>name</var> be the name of the property.
2155+
2156+
<li><p>Let <var>value</var> be the result of <a>getting a
2157+
property</a> named <var>name</var> from <var>capability</var>.
2158+
2159+
<li><p>Run the substeps of the first matching condition:
2160+
<dl class=switch>
2161+
<dt><var>value</var> is <a><code>null</code></a>
2162+
<dd><p>Let <var>deserialized</var> be set to
2163+
<a><code>null</code></a>.
2164+
2165+
<dt><var>name</var> equals "<code>acceptInsecureCerts</code>"
2166+
<dd><p>If <var>value</var> is not a <a>boolean</a> return
2167+
an <a>error</a> with <a>error code</a> <a>invalid
2168+
argument</a>. Otherwise, let <var>deserialized</var> be
2169+
set to <var>value</var>
2170+
2171+
<dt><var>name</var> equals "<code>browserName</code>"
2172+
<dt><var>name</var> equals "<code>browserVersion</code>"
2173+
<dt><var>name</var> equals "<code>platformName</code>"
2174+
<dd><p>If <var>value</var> is not a <a>string</a> return
2175+
an <a>error</a> witha <a>error code</a> <a>invalid
2176+
argument</a>. Otherwise, let <var>deserialized</var> be
2177+
set to <var>value</var>.
2178+
2179+
<dt><var>name</var> equals "<code>pageLoadStrategy</code>"
2180+
<dd><p>Let <var>deserialized</var> be the result of <a>trying</a> to
2181+
<a>deserialize as a page load strategy</a> with argument
2182+
<var>value</var>.
2183+
2184+
<dt><var>name</var> equals "<code>proxy</code>"
2185+
<dd><p>Let <var>deserialized</var> be the result of <a>trying</a>
2186+
to <a>deserialize as a proxy</a> with argument <var>value</var>.
2187+
2188+
<dt><var>name</var> equals "<code>timeouts</code>"
2189+
<dd><p>Let <var>deserialized</var> be the result of <a>trying</a>
2190+
to <a>deserialize as a timeout</a> with argument <var>value</var>.
2191+
2192+
<dt><var>name</var> equals "<code>unhandledPromptBehavior</code>"
2193+
<dd><p>Let <var>deserialized</var> be the result of <a>trying</a>
2194+
to <a>deserialize as an unhandled prompt behavior</a> with argument
2195+
<var>value</var>.
2196+
2197+
<dt><var>name</var> is the key of an <a>extension capability</a>
2198+
<dd><p>Let <var>deserialized</var> be the result of <a>trying</a>
2199+
to deserialize <var>value</var> in an implementation-specific way.
2200+
2201+
<dt>The <a>remote end</a> is an <a>endpoint node</a>
2202+
<dd><p>Return an <a>error</a> with <a>error code</a>
2203+
<a>invalid argument</a>.
2204+
</dl>
2205+
2206+
<li><p>If <var>deserialized</var> is
2207+
not <a><code>null</code></a>, <a>set a property</a>
2208+
on <var>result</var> with name <var>name</var> and
2209+
value <var>deserialized</var>.
2210+
</ol>
2211+
2212+
<li>Return <a>success</a> with data <var>result</var>.
2213+
</ol><!-- /validating capabilities -->
2214+
21412215
<p>When <dfn>merging capabilities</dfn> with JSON <a>Object</a> arguments
21422216
<var>primary</var> and <var>secondary</var>,
21432217
an <a>endpoint node</a> must take the following steps:
@@ -2153,9 +2227,8 @@ <h3>Processing Capabilities</h3>
21532227
<li><p>Let <var>value</var> be the the result of <a>getting a
21542228
property</a> named <var>name</var> from <var>primary</var>.
21552229

2156-
<li><p>If <var>value</var> is not <a><code>null</code></a>
2157-
<a>set a property</a> on <var>result</var> with name
2158-
<var>name</var> and value <var>value</var>.
2230+
<li><a>Set a property</a> on <var>result</var> with
2231+
name <var>name</var> and value <var>value</var>.
21592232
</ol>
21602233

21612234
<li><p>If <var>secondary</var> is <a>undefined</a>, return <var>result</var>.
@@ -2172,19 +2245,12 @@ <h3>Processing Capabilities</h3>
21722245
<a>getting a property</a> named <var>name</var> from
21732246
<var>primary</var>.
21742247

2175-
<li><p>Run the substeps of the first matching condition:
2176-
<dl class=switch>
2177-
<dt><var>value</var> is <a><code>null</code></a>
2178-
<dd>Do nothing.
2248+
<li><p>If <var>primary value</var> is
2249+
not <a><code>undefined</code></a> return an <a>error</a>
2250+
with <a>error code</a> <a>invalid argument</a>.
21792251

2180-
<dt><var>primary value</var> is <a><code>undefined</code></a>
2181-
<dd><a>Set a property</a> on <var>result</var> with name
2252+
<li><a>Set a property</a> on <var>result</var> with name
21822253
<var>name</var> and value <var>value</var>.
2183-
2184-
<dt>Otherwise
2185-
<dd>Return an <a>error</a> with <a>error code</a>
2186-
<a>invalid argument</a>.
2187-
</dl>
21882254
</ol>
21892255

21902256
<li><p>Return <var>result</var>.
@@ -2252,71 +2318,25 @@ <h3>Processing Capabilities</h3>
22522318
<li><p>For each <var>name</var> and <var>value</var> corresponding
22532319
to <var>capability</var>'s <a>own properties</a>:
22542320
<ol>
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>
2302-
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-
23062321
<li><p>Run the substeps of the first matching <var>name</var>:
23072322

23082323
<dl class=switch>
23092324
<dt>"<code>browserName</code>"
2310-
<dd><p>If <var>capability value</var> is not a string equal to
2325+
<dd><p>If <var>value</var> is not a string equal to
23112326
the "<code>browserName</code>" entry in
23122327
<var>matched capabilities</var>, return <a>success</a> with
23132328
data <a><code>null</code></a>.
23142329

2330+
<p class=note>There is a chance the <a>remote end</a> will need
2331+
to start a browser process to correctly determine
2332+
the <code>browserName</code>. Lightweight checks are preferred
2333+
before this is done.
2334+
23152335
<dt>"<code>browserVersion</code>"
2316-
<dd><p>Compare <var>capability value</var>
2336+
<dd><p>Compare <var>value</var>
23172337
to the "<code>browserVersion</code>" entry in <var>matched capabilities</var>
23182338
using an implementation-defined comparison algorithm.
2319-
The comparison is to accept a <var>capability value</var>
2339+
The comparison is to accept a <var>value</var>
23202340
that places constraints on the version using
23212341
the "<code>&lt;</code>", "<code>&lt;=</code>", "<code>&gt;</code>",
23222342
and "<code>&gt;=</code>" operators.
@@ -2329,8 +2349,13 @@ <h3>Processing Capabilities</h3>
23292349
of encoding the user agent version,
23302350
and standardizing these schemes is beyond the scope of this standard.
23312351

2352+
<p class=note>There is a chance the <a>remote end</a> will need
2353+
to start a browser process to correctly determine
2354+
the <code>browserVersion</code>. Lightweight checks are preferred
2355+
before this is done.
2356+
23322357
<dt>"<code>platformName</code>"
2333-
<dd><p>If <var>capability value</var> is not a string equal
2358+
<dd><p>If <var>value</var> is not a string equal
23342359
to the "<code>platformName</code>" entry in <var>matched capabilities</var>,
23352360
return <a>success</a> with data <a><code>null</code></a>.
23362361

@@ -2354,33 +2379,35 @@ <h3>Processing Capabilities</h3>
23542379
</div>
23552380

23562381
<dt>"<code>acceptInsecureCerts</code>"
2357-
<dd><p>If <var>capability value</var> is not a boolean
2358-
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2359-
2360-
<p>If <var>capability value</var> is <code>true</code>
2382+
<dd><p>If <var>value</var> is <code>true</code>
23612383
and the <a>endpoint node</a> does not support <a>insecure TLS certificates</a>,
2362-
return <a>error</a> with <a>error code</a> <a>invalid argument</a>.
2384+
return <a>success</a> with data <a><code>null</code></a>.
2385+
2386+
<p class=note>If the <a>endpoint node</a> does not
2387+
support <a>insecure TLS certificates</a> and this is the reason
2388+
no match is ultimately made, it is useful to provide this
2389+
information to the <a>local end</a>.
23632390

23642391
<dt>"<code>proxy</code>"
23652392
<dd><p>If the <a>endpoint node</a> does not support the proxy
2366-
configuration defined in <var>capability value</var>,
2393+
configuration defined in <var>value</var>,
23672394
return <a>success</a> with data <a><code>null</code></a>.
23682395

23692396
<dt><strong>Otherwise</strong>
2370-
<dd><p>If <var>name</var> is not the name of an
2397+
<dd><p>If <var>name</var> is not the key of an
23712398
<a>extension capability</a> and the <a>remote end</a> is
23722399
an <a>endpoint node</a> return <a>success</a> with data
23732400
<code>null</code>.
23742401

2375-
<p>Let <var>matched value</var> be the result of <a>trying</a>
2402+
<p>Let <var>value</var> be the result of <a>trying</a>
23762403
implementation-specific steps to match on <var>name</var>
2377-
with <var>capability value</var>. If the match is not
2404+
with <var>value</var>. If the match is not
23782405
successful, return <a>success</a> with
23792406
data <a><code>null</code></a>.
23802407
</dl>
23812408

23822409
<li><p><a>Set a property</a> on <var>matched capability</var>
2383-
with name <var>name</var> and value <var>capability value</var>.
2410+
with name <var>name</var> and value <var>value</var>.
23842411
</ol>
23852412

23862413
<li><p>Return <a>success</a> with data <var>matched capabilities</var>.

0 commit comments

Comments
 (0)