Skip to content

Commit 88f2def

Browse files
OrKoNjugglinmikejgraham
authored
Add an ability to locate nodes using computed accessibility attributes (#660)
Co-authored-by: Mike Pennisi <[email protected]> Co-authored-by: jgraham <[email protected]>
1 parent a08c9c2 commit 88f2def

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

index.bs

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ spec: UNICODE; urlPrefix: https://www.unicode.org/versions/Unicode15.0.0/
269269
type: dfn
270270
text: Unicode Default Case Conversion algorithm; url: ch03.pdf#G34944
271271
text: toUppercase; url: ch03.pdf#G34078
272+
spec: ACCNAME; urlPrefix:https://www.w3.org/TR/accname-1.2
273+
type: dfn
274+
text: accessible name; url: /#dfn-accessible-name
275+
spec: CORE-AAM; urlPrefix:https://www.w3.org/TR/core-aam-1.2
276+
type: dfn
277+
text: computed role; url: /#roleMappingComputedRole
272278
</pre>
273279

274280
<pre class="biblio">
@@ -2499,11 +2505,20 @@ To <dfn>await a navigation</dfn> given |context|, |request|, |wait condition|, a
24992505

25002506
<pre class="cddl remote-cddl local-cddl">
25012507
browsingContext.Locator = (
2508+
browsingContext.AccessibilityLocator /
25022509
browsingContext.CssLocator /
25032510
browsingContext.InnerTextLocator /
25042511
browsingContext.XPathLocator
25052512
)
25062513

2514+
browsingContext.AccessibilityLocator = {
2515+
type: "accessibility",
2516+
value: {
2517+
? name: text,
2518+
? role: text,
2519+
}
2520+
}
2521+
25072522
browsingContext.CssLocator = {
25082523
type: "css",
25092524
value: text
@@ -3405,6 +3420,67 @@ To <dfn>locate nodes using inner text</dfn> with given |context nodes|,
34053420

34063421
</div>
34073422

3423+
<div algorithm="collect nodes using accessibility attributes">
3424+
To <dfn>collect nodes using accessibility attributes</dfn> with given |context nodes|, |selector|,
3425+
|maximum returned node count|, and |returned nodes|:
3426+
3427+
1. If |returned nodes| is null:
3428+
3429+
1. Set |returned nodes| to an empty [=/list=].
3430+
3431+
1. For each |context node| in |context nodes|:
3432+
3433+
1. Let |match| be true.
3434+
3435+
1. If |selector| [=map/contains=] "<code>role</code>":
3436+
3437+
1. Let |role| be the [=computed role=] of |context node|.
3438+
3439+
1. If |selector|["<code>role</code>"] [=is|is not=] |role|:
3440+
3441+
1. Set |match| to false.
3442+
3443+
1. If |selector| [=map/contains=] "<code>name</code>":
3444+
3445+
1. Let |name| be the [=accessible name=] of |context node|.
3446+
3447+
1. If |selector|["<code>name</code>"] [=is|is not=] |name|:
3448+
3449+
1. Set |match| to false.
3450+
3451+
1. If |match| is true:
3452+
3453+
1. If |maximum returned node count| is not null and [=list/size=] of |returned
3454+
nodes| is equal to |maximum returned node count|, [=break=].
3455+
3456+
1. [=list/Append=] |context node| to |returned nodes|.
3457+
3458+
1. Let |child nodes| be an empty [=/list=] and, for each node |child| in the
3459+
<a spec=dom>children</a> of |context node|:
3460+
3461+
1. If |child| implements {{Element}}, [=list/append=] |child| to |child nodes|.
3462+
3463+
1. [=Try=] to [=collect nodes using accessibility attributes=] with |child nodes|,
3464+
|selector|, |maximum returned node count|, and |returned nodes|.
3465+
3466+
1. Return |returned nodes|.
3467+
3468+
</div>
3469+
3470+
<div algorithm="locate nodes using accessibility attributes">
3471+
To <dfn>locate nodes using accessibility attributes</dfn> with given |context nodes|, |selector|, and
3472+
|maximum returned node count|:
3473+
3474+
1. If |selector| does not [=map/contain=] "<code>role</code>" and
3475+
|selector| does not [=map/contain=] "<code>name</code>", return
3476+
[=error=] with [=error code=]
3477+
[=invalid selector=].
3478+
3479+
1. Return the result of [=collect nodes using accessibility attributes=] with |context nodes|,
3480+
|selector|, |maximum returned node count|, and null.
3481+
3482+
</div>
3483+
34083484
<div algorithm="remote end steps for browsingContext.locateNodes">
34093485
The [=remote end steps=] with |session| and |command parameters| are:
34103486

@@ -3481,6 +3557,13 @@ The [=remote end steps=] with |session| and |command parameters| are:
34813557
given |context nodes|, |selector|, |max depth|, |match type|,
34823558
|ignore case| and |maximum returned node count|.
34833559

3560+
<dt>|type| is the string "<code>accessibility</code>"
3561+
<dd>
3562+
1. Let |selector| be |locator|["<code>value</code>"].
3563+
3564+
1. Let |result nodes| be [=locate nodes using accessibility attributes=]
3565+
given |context nodes|, |selector|, and |maximum returned node count|.
3566+
34843567
1. Assert: |maximum returned node count| is null or [=list/size=] of |result nodes| is less
34853568
than or equal to |maximum returned node count|.
34863569

0 commit comments

Comments
 (0)