Skip to content

Lightpanda: the headless browser designed for AI and automation

review: simplify ARIA access and clarify regression diagnostics

Robert McConnellccf52086b829
diff --git a/src/SemanticTree.zig b/src/SemanticTree.zig
index 5b5d20894..8db40d11b 100644
--- a/src/SemanticTree.zig
+++ b/src/SemanticTree.zig
@@ -634,7 +634,7 @@ fn visitNode(
.value = value,
.options = options,
.checked = checked,
- .aria = if (!invisible and node.is(Element) != null) AXNode.Writer.ariaProperties(node.is(Element).?, role) else .{},
+ .aria = if (invisible) .{} else if (node.is(Element)) |el| AXNode.Writer.ariaProperties(el, role) else .{},
.xpath = xpath,
.interactive = is_interactive,
.disabled = is_disabled,
@@ -1196,9 +1196,9 @@ test "SemanticTree: JSON exposes custom ARIA states without changing native chec
const generic = find(parsed.value, "Generic expanded") orelse return error.NodeNotFound;
try testing.expect(generic.object.get("ariaExpanded") == null);
const mixed = find(parsed.value, "Uppercase mixed") orelse return error.NodeNotFound;
- try std.testing.expectEqualStrings("mixed", mixed.object.get("ariaChecked").?.string);
+ try testing.expectString("mixed", mixed.object.get("ariaChecked").?.string);
const switch_mixed = find(parsed.value, "Switch mixed") orelse return error.NodeNotFound;
- try std.testing.expectEqualStrings("false", switch_mixed.object.get("ariaChecked").?.string);
+ try testing.expectString("false", switch_mixed.object.get("ariaChecked").?.string);
const invalid = find(parsed.value, "Invalid details") orelse return error.NodeNotFound;
try testing.expect(invalid.object.get("ariaExpanded") == null);
const native = find(parsed.value, "Native terms") orelse return error.NodeNotFound;
diff --git a/src/browser/tools.zig b/src/browser/tools.zig
index e0dc8ff9c..5858e08af 100644
--- a/src/browser/tools.zig
+++ b/src/browser/tools.zig
@@ -3075,7 +3075,10 @@ test "tools: tree exposes Chrome-matched custom ARIA states" {
"checkbox 'Checked terms' [checked]",
};
for (expected) |fragment| {
- if (std.mem.find(u8, result.text, fragment) == null) return error.MissingExpectedAriaState;
+ if (std.mem.find(u8, result.text, fragment) == null) {
+ std.debug.print("missing {s} in:\n{s}\n", .{ fragment, result.text });
+ return error.MissingExpectedAriaState;
+ }
}
// Unsupported roles and invalid tokens must not manufacture state.
diff --git a/src/server/cdp/AXNode.zig b/src/server/cdp/AXNode.zig
index 50fe5e19a..4a10af5e3 100644
--- a/src/server/cdp/AXNode.zig
+++ b/src/server/cdp/AXNode.zig
@@ -360,7 +360,6 @@ pub const Writer = struct {
return roles.get(std.ascii.lowerString(&buf, role)) orelse .{};
}
- // Share Chrome-matched role and token rules with the MCP semantic tree.
// Native input checked state remains owned by the input serializer.
pub const AriaProperties = struct {
expanded: ?bool = null,