LibWeb/DOM: Set missing JSON attributes for a11y text nodes

Firefox DevTools expects all nodes to have an ID and type, and for a
text node's name to be its text.
This commit is contained in:
Sam Atkins 2025-10-13 11:31:47 +01:00
commit c9811af3b5
Notes: github-actions[bot] 2025-10-20 09:52:31 +00:00

View file

@ -42,7 +42,6 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu
MUST(object.add("name"sv, name));
auto description = MUST(element->accessible_description(document));
MUST(object.add("description"sv, description));
MUST(object.add("id"sv, element->unique_id().value()));
if (has_role)
MUST(object.add("role"sv, ARIA::role_name(*role)));
@ -55,9 +54,12 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu
MUST(object.add("type"sv, "text"sv));
auto const* text_node = static_cast<DOM::Text const*>(value().ptr());
MUST(object.add("text"sv, text_node->data().to_utf8()));
MUST(object.add("name"sv, text_node->data().to_utf8()));
MUST(object.add("role"sv, "text leaf"sv));
}
MUST(object.add("id"sv, value()->unique_id().value()));
if (value()->has_child_nodes()) {
auto node_children = MUST(object.add_array("children"sv));
for (auto& child : children()) {