Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add getAXNodeAndAncestors CDP command
This command takes a DOM node reference and retrieves the corresponding AXNode and its ancestors up to the root. We use this command in the The DevTools frontend lazily builds the accessibility tree. We use this command to map DOM nodes to AXNodes that lives in parts of the tree that has not been previously requested. Using the ancestor chain up to the root we can then stitch the returned subtree together with the already known part. Bug: 1226486 Change-Id: I374765908358a88aaf2d21bc17acf814207dfc9b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3253351 Commit-Queue: Johan Bay <jobay@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Nektarios Paisios <nektar@chromium.org> Cr-Commit-Position: refs/heads/main@{#939724}
- Loading branch information
Showing
5 changed files
with
273 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
176 changes: 176 additions & 0 deletions
176
...p/tests/inspector-protocol/accessibility/accessibility-getAXNodeAndAncestors-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,176 @@ | ||
Tests Accessibility.getAXNodeAndAncestors | ||
{ | ||
backendDOMNodeId : <number> | ||
childIds : <object> | ||
ignored : false | ||
name : { | ||
sources : [ | ||
[0] : { | ||
attribute : aria-labelledby | ||
type : relatedElement | ||
} | ||
[1] : { | ||
attribute : aria-label | ||
type : attribute | ||
} | ||
[2] : { | ||
attribute : title | ||
type : attribute | ||
} | ||
] | ||
type : computedString | ||
value : | ||
} | ||
nodeId : <string> | ||
parentId : <string> | ||
properties : [ | ||
] | ||
role : { | ||
type : role | ||
value : paragraph | ||
} | ||
} | ||
{ | ||
backendDOMNodeId : <number> | ||
childIds : <object> | ||
ignored : false | ||
name : { | ||
sources : [ | ||
[0] : { | ||
attribute : aria-labelledby | ||
type : relatedElement | ||
} | ||
[1] : { | ||
attribute : aria-label | ||
type : attribute | ||
} | ||
[2] : { | ||
attribute : title | ||
type : attribute | ||
} | ||
] | ||
type : computedString | ||
value : | ||
} | ||
nodeId : <string> | ||
parentId : <string> | ||
properties : [ | ||
] | ||
role : { | ||
type : role | ||
value : article | ||
} | ||
} | ||
{ | ||
backendDOMNodeId : <number> | ||
childIds : <object> | ||
ignored : false | ||
name : { | ||
sources : [ | ||
[0] : { | ||
attribute : aria-labelledby | ||
type : relatedElement | ||
} | ||
[1] : { | ||
attribute : aria-label | ||
type : attribute | ||
} | ||
[2] : { | ||
attribute : title | ||
type : attribute | ||
} | ||
] | ||
type : computedString | ||
value : | ||
} | ||
nodeId : <string> | ||
parentId : <string> | ||
properties : [ | ||
] | ||
role : { | ||
type : role | ||
value : main | ||
} | ||
} | ||
{ | ||
backendDOMNodeId : <number> | ||
childIds : <object> | ||
ignored : true | ||
ignoredReasons : [ | ||
[0] : { | ||
name : uninteresting | ||
value : { | ||
type : boolean | ||
value : true | ||
} | ||
} | ||
] | ||
nodeId : <string> | ||
parentId : <string> | ||
role : { | ||
type : role | ||
value : none | ||
} | ||
} | ||
{ | ||
backendDOMNodeId : <number> | ||
childIds : <object> | ||
ignored : true | ||
ignoredReasons : [ | ||
] | ||
nodeId : <string> | ||
parentId : <string> | ||
role : { | ||
type : role | ||
value : none | ||
} | ||
} | ||
{ | ||
backendDOMNodeId : <number> | ||
childIds : <object> | ||
frameId : <string> | ||
ignored : false | ||
name : { | ||
sources : [ | ||
[0] : { | ||
attribute : aria-labelledby | ||
type : relatedElement | ||
} | ||
[1] : { | ||
attribute : aria-label | ||
type : attribute | ||
} | ||
[2] : { | ||
attribute : aria-label | ||
superseded : true | ||
type : attribute | ||
} | ||
[3] : { | ||
nativeSource : title | ||
type : relatedElement | ||
} | ||
[4] : { | ||
attribute : title | ||
superseded : true | ||
type : attribute | ||
} | ||
] | ||
type : computedString | ||
value : | ||
} | ||
nodeId : <string> | ||
properties : [ | ||
[0] : { | ||
name : focusable | ||
value : { | ||
type : booleanOrUndefined | ||
value : true | ||
} | ||
} | ||
] | ||
role : { | ||
type : internalRole | ||
value : RootWebArea | ||
} | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
..._tests/http/tests/inspector-protocol/accessibility/accessibility-getAXNodeAndAncestors.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
(async function(testRunner) { | ||
var {page, session, dp} = await testRunner.startHTML(` | ||
<main> | ||
<article> | ||
<h1>Article</h1> | ||
<p>First paragraph</p> | ||
</article> | ||
</main> | ||
`, 'Tests Accessibility.getAXNodeAndAncestors'); | ||
await dp.Accessibility.enable(); | ||
|
||
function logNode(axnode) { | ||
testRunner.log(axnode, null, ['nodeId', 'backendDOMNodeId', 'childIds', 'frameId', 'parentId']); | ||
} | ||
|
||
const documentResp = await dp.DOM.getDocument(); | ||
const documentId = documentResp.result.root.nodeId; | ||
const paragraphResp = | ||
await dp.DOM.querySelector({nodeId: documentId, selector: 'p'}); | ||
const paragraphId = paragraphResp.result.nodeId; | ||
|
||
let {result} = await dp.Accessibility.getAXNodeAndAncestors({nodeId: paragraphId}); | ||
for (const node of result.nodes) { | ||
logNode(node); | ||
} | ||
|
||
testRunner.completeTest(); | ||
}); |