-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This command takes a DOM node and a name and/or role to search for. It searches the accessibility subtree of the given node for the name and role. The command also includes ignored nodes in its result. The command is the underlying primitive for a new aria-based querying mechanism in Puppeteer. This CL is a follow-up to crrev.com/c/2366896. The feedback given there has been addressed in this CL. Doc: https://docs.google.com/document/d/1-BUEUgqAZlh26fv9oLfy1QRr0MF3ifnxGh7-NDucg9s/ Change-Id: Ibdcdb230b5d1287ab009f2dd9d25a53932072d6b Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2398547 Commit-Queue: Johan Bay <jobay@google.com> Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Reviewed-by: Mathias Bynens <mathias@chromium.org> Reviewed-by: Chris Hall <chrishall@chromium.org> Reviewed-by: Alice Boxhall <aboxhall@chromium.org> Reviewed-by: Alex Rudenko <alexrudenko@chromium.org> Reviewed-by: Andrey Kosyakov <caseq@chromium.org> Cr-Commit-Position: refs/heads/master@{#809251}
- Loading branch information
Showing
10 changed files
with
663 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
5 changes: 5 additions & 0 deletions
5
third_party/blink/web_tests/http/tests/inspector-protocol/query-axtree-oopif-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,5 @@ | ||
Tests that we cannot find elements inside OOPIF by accessible name | ||
|
||
Running test: testGetIdsForSubtreeByAccessibleNameOOPIF | ||
node1 | ||
|
47 changes: 47 additions & 0 deletions
47
third_party/blink/web_tests/http/tests/inspector-protocol/query-axtree-oopif.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,47 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
(async function(testRunner) { | ||
const {dp, session} = await testRunner.startHTML( | ||
` | ||
<h1 id="node1">accessible name</h1> | ||
`, | ||
'Tests that we cannot find elements inside OOPIF by accessible name'); | ||
session.evaluate(` | ||
const frame = document.createElement('iframe'); | ||
frame.setAttribute('src', 'http://devtools.oopif.test:8000/inspector-protocol/resources/iframe-accessible-name.html'); | ||
document.body.appendChild(frame); | ||
`); | ||
|
||
|
||
const documentResp = await dp.DOM.getDocument(); | ||
const documentId = documentResp.result.root.nodeId; | ||
|
||
const documentResp2 = await dp.DOM.resolveNode({nodeId: documentId}); | ||
const documentObjId = documentResp2.result.object.objectId; | ||
|
||
async function testGetIdsForSubtreeByAccessibleNameOOPIF() { | ||
const response = await dp.Accessibility.queryAXTree( | ||
{objectId: documentObjId, accessibleName: 'accessible name'}); | ||
await logNodes(response.result.nodes); | ||
} | ||
|
||
// copied from third_party/blink/web_tests/inspector-protocol/accessibility/accessibility-query-axtree.js | ||
async function logNodes(axNodes) { | ||
for (const axNode of axNodes) { | ||
const backendNodeId = axNode.backendDOMNodeId; | ||
const response = await dp.DOM.describeNode({backendNodeId}); | ||
const node = response.result.node; | ||
// we can only print ids for ELEMENT_NODEs, skip TEXT_NODEs | ||
if (node.nodeType !== Node.ELEMENT_NODE) { | ||
continue; | ||
} | ||
const nodeAttributes = node.attributes; | ||
const idIndex = nodeAttributes.indexOf('id') + 1; | ||
testRunner.log(nodeAttributes[idIndex]); | ||
} | ||
} | ||
|
||
testRunner.runTestSuite([testGetIdsForSubtreeByAccessibleNameOOPIF]); | ||
}); |
3 changes: 3 additions & 0 deletions
3
...party/blink/web_tests/http/tests/inspector-protocol/resources/iframe-accessible-name.html
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,3 @@ | ||
<!DOCTYPE html> | ||
<title>Iframe with accessible name</title> | ||
<h1 id="node2">accessible name</h1> |
34 changes: 34 additions & 0 deletions
34
...web_tests/inspector-protocol/accessibility/accessibility-query-axtree-errors-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,34 @@ | ||
Tests errors when finding DOM nodes by accessible name. | ||
{ | ||
error : { | ||
code : -32000 | ||
message : Either nodeId, backendNodeId or objectId must be specified | ||
} | ||
id : <number> | ||
sessionId : <string> | ||
} | ||
{ | ||
error : { | ||
code : -32000 | ||
message : Could not find node with given id | ||
} | ||
id : <number> | ||
sessionId : <string> | ||
} | ||
{ | ||
error : { | ||
code : -32000 | ||
message : No node found for given backend id | ||
} | ||
id : <number> | ||
sessionId : <string> | ||
} | ||
{ | ||
error : { | ||
code : -32000 | ||
message : Invalid remote object id | ||
} | ||
id : <number> | ||
sessionId : <string> | ||
} | ||
|
34 changes: 34 additions & 0 deletions
34
...rty/blink/web_tests/inspector-protocol/accessibility/accessibility-query-axtree-errors.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,34 @@ | ||
// Copyright 2020 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
(async function(testRunner) { | ||
const {dp} = await testRunner.startBlank( | ||
'Tests errors when finding DOM nodes by accessible name.'); | ||
|
||
const wrongObjectId = 'not-a-node'; | ||
const wrongNodeId = -1; | ||
|
||
// Expected: error because no node is specified | ||
testRunner.log(await dp.Accessibility.queryAXTree({ | ||
accessibleName: 'name', | ||
})); | ||
// Expected: error because nodeId is wrong. | ||
testRunner.log(await dp.Accessibility.queryAXTree({ | ||
nodeId: wrongNodeId, | ||
accessibleName: 'name', | ||
})); | ||
// Expected: error because backendNodeId is wrong. | ||
testRunner.log(await dp.Accessibility.queryAXTree({ | ||
backendNodeId: wrongNodeId, | ||
accessibleName: 'name', | ||
})); | ||
|
||
// Expected: error because object ID is wrong. | ||
testRunner.log(await dp.Accessibility.queryAXTree({ | ||
objectId: wrongObjectId, | ||
accessibleName: 'name', | ||
})); | ||
|
||
testRunner.completeTest(); | ||
}); |
Oops, something went wrong.