requestChildNode cannot have a depth of 0

This commit is contained in:
Karl Seguin
2025-07-17 10:36:20 +08:00
parent 09ca0e6ef0
commit 98b041e84a
2 changed files with 3 additions and 2 deletions

View File

@@ -213,7 +213,7 @@ pub const Writer = struct {
pub fn jsonStringify(self: *const Writer, w: anytype) !void {
if (self.exclude_root) {
_ = self.writeChildren(self.root, 0, w) catch |err| {
_ = self.writeChildren(self.root, 1, w) catch |err| {
log.err(.cdp, "node writeChildren", .{ .err = err });
return error.OutOfMemory;
};
@@ -467,7 +467,7 @@ test "cdp Node: Writer" {
const node = registry.lookup_by_id.get(1).?;
const json = try std.json.stringifyAlloc(testing.allocator, Writer{
.root = node,
.depth = 0,
.depth = 1,
.exclude_root = false,
.registry = &registry,
}, .{});

View File

@@ -442,6 +442,7 @@ fn requestChildNodes(cmd: anytype) !void {
pierce: bool = false,
})) orelse return error.InvalidParams;
if (params.depth == 0) return error.InvalidParams;
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
const session_id = bc.session_id orelse return error.SessionIdNotLoaded;
const node = bc.node_registry.lookup_by_id.get(params.nodeId) orelse {