cdp: implement DOM.requestNode

This commit is contained in:
Pierre Tachoire
2025-12-05 13:49:02 +01:00
parent 00e18e24b9
commit ea757407f5

View File

@@ -43,6 +43,7 @@ pub fn processMessage(cmd: anytype) !void {
requestChildNodes,
getFrameOwner,
getOuterHTML,
requestNode,
}, cmd.input.action) orelse return error.UnknownMethod;
switch (action) {
@@ -61,6 +62,7 @@ pub fn processMessage(cmd: anytype) !void {
.requestChildNodes => return requestChildNodes(cmd),
.getFrameOwner => return getFrameOwner(cmd),
.getOuterHTML => return getOuterHTML(cmd),
.requestNode => return requestNode(cmd),
}
}
@@ -518,6 +520,17 @@ fn getOuterHTML(cmd: anytype) !void {
return cmd.sendResult(.{ .outerHTML = aw.written() }, .{});
}
fn requestNode(cmd: anytype) !void {
const params = (try cmd.params(struct {
objectId: []const u8,
})) orelse return error.InvalidParams;
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
const node = try getNode(cmd.arena, bc, null, null, params.objectId);
return cmd.sendResult(.{ .nodeId = node.id }, .{});
}
const testing = @import("../testing.zig");
test "cdp.dom: getSearchResults unknown search id" {