Commit 462df815 authored by Alice Boxhall's avatar Alice Boxhall Committed by Commit Bot

Devtools: Correctly add ancestors in a11y tree for nodes with no AXNode

Bug: 1015529
Change-Id: I59c9991f3fd50582553883d4d27668960b4a6481
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911064Reviewed-by: default avatarDominic Mazzoni <dmazzoni@chromium.org>
Commit-Queue: Alice Boxhall <aboxhall@chromium.org>
Cr-Commit-Position: refs/heads/master@{#715104}
parent 4c353446
......@@ -572,7 +572,10 @@ void InspectorAccessibilityAgent::AddAncestors(
std::unique_ptr<AXNode> parent_node_object = BuildProtocolAXObject(
*ancestor, inspected_ax_object, true, nodes, cache);
auto child_ids = std::make_unique<protocol::Array<AXNodeId>>();
if (child)
child_ids->emplace_back(String::Number(child->AXObjectID()));
else
child_ids->emplace_back(String::Number(kIDForInspectedNodeWithNoAXNode));
parent_node_object->setChildIds(std::move(child_ids));
nodes->emplace_back(std::move(parent_node_object));
child = ancestor;
......@@ -653,16 +656,7 @@ void InspectorAccessibilityAgent::PopulateDOMNodeAncestors(
return;
// Populate parent and ancestors.
std::unique_ptr<AXNode> parent_node_object =
BuildProtocolAXObject(*parent_ax_object, nullptr, true, nodes, cache);
auto child_ids = std::make_unique<protocol::Array<AXNodeId>>();
child_ids->emplace_back(String::Number(kIDForInspectedNodeWithNoAXNode));
parent_node_object->setChildIds(std::move(child_ids));
nodes->emplace_back(std::move(parent_node_object));
AXObject* grandparent_ax_object = parent_ax_object->ParentObjectUnignored();
if (grandparent_ax_object)
AddAncestors(*grandparent_ax_object, nullptr, nodes, cache);
AddAncestors(*parent_ax_object, nullptr, nodes, cache);
}
std::unique_ptr<AXNode> InspectorAccessibilityAgent::BuildProtocolAXObject(
......
Tests that fetching the tree for a node without an AXNode functions correctly.
WebArea
main
article
*Ignored
{
"nodeId": "<string>",
"ignored": true,
"ignoredReasons": [
{
"name": "notRendered",
"value": {
"type": "boolean",
"value": true
}
}
],
"role": {
"type": "internalRole",
"value": "Ignored"
},
"domNode": "div#hidden"
}
(async function(testRunner) {
var {page, session, dp} = await testRunner.startHTML(`
<main>
<article>
<div id="hidden" style="display: none">hidden div</div>
</article>
</main>
`, 'Tests that fetching the tree for a node without an AXNode functions correctly.');
var dumpAccessibilityNodesBySelectorAndCompleteTest =
(await testRunner.loadScript('../resources/accessibility-dumpAccessibilityNodes.js'))(testRunner, session);
var msg = await dp.DOM.getDocument();
dumpAccessibilityNodesBySelectorAndCompleteTest('#hidden', true, msg);
})
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment