From aeba861d69c56912d28740fc0fe7ae5a1b46e07d Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Fri, 22 May 2026 20:16:09 +0800 Subject: [PATCH] Add WebDriver getComputedLabel Used by https://github.com/lightpanda-io/wpt/pull/68 Helps many /accname/ WPT tests pass --- src/browser/webapi/WebDriver.zig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/browser/webapi/WebDriver.zig b/src/browser/webapi/WebDriver.zig index 9b73d819..e21514d6 100644 --- a/src/browser/webapi/WebDriver.zig +++ b/src/browser/webapi/WebDriver.zig @@ -20,6 +20,9 @@ const std = @import("std"); const js = @import("../js/js.zig"); const Page = @import("../Page.zig"); +const Frame = @import("../Frame.zig"); + +const Element = @import("Element.zig"); // This type is only included when the binary is built with the -Dwpt_extensions flag const WebDriver = @This(); @@ -30,6 +33,12 @@ pub fn deleteAllCookies(_: *const WebDriver, page: *Page) void { page.session.cookie_jar.clearRetainingCapacity(); } +pub fn getComputedLabel(_: *const WebDriver, element: *Element, frame: *Frame) ![]const u8 { + const AXNode = @import("../../cdp/AXNode.zig"); + const axnode = AXNode.fromNode(element.asNode()); + return (try axnode.getName(frame, frame.call_arena)) orelse ""; +} + pub const JsApi = struct { pub const bridge = js.Bridge(WebDriver); @@ -40,4 +49,5 @@ pub const JsApi = struct { pub const empty_with_no_proto = true; }; pub const deleteAllCookies = bridge.function(WebDriver.deleteAllCookies, .{}); + pub const getComputedLabel = bridge.function(WebDriver.getComputedLabel, .{}); };