Skip to content

Commit eef5f3f

Browse files
committed
support null params to CDP DOM.getDocument
1 parent f199816 commit eef5f3f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/cdp/domains/dom.zig

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,19 @@ pub fn processMessage(cmd: anytype) !void {
6060

6161
// https://chromedevtools.github.io/devtools-protocol/tot/DOM/#method-getDocument
6262
fn getDocument(cmd: anytype) !void {
63-
const params = (try cmd.params(struct {
63+
const Params = struct {
6464
// CDP documentation implies that 0 isn't valid, but it _does_ work in Chrome
65-
depth: ?i32 = null,
66-
pierce: ?bool = null,
67-
})) orelse return error.InvalidParams;
65+
depth: i32 = 3,
66+
pierce: bool = false,
67+
};
68+
const params = try cmd.params(Params) orelse Params{};
6869

6970
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
7071
const page = bc.session.currentPage() orelse return error.PageNotLoaded;
7172
const doc = parser.documentHTMLToDocument(page.window.document);
7273

7374
const node = try bc.node_registry.register(parser.documentToNode(doc));
74-
return cmd.sendResult(.{ .root = bc.nodeWriter(node, .{ .depth = params.depth orelse 3 }) }, .{});
75+
return cmd.sendResult(.{ .root = bc.nodeWriter(node, .{ .depth = params.depth }) }, .{});
7576
}
7677

7778
// https://chromedevtools.github.io/devtools-protocol/tot/DOM/#method-performSearch
@@ -611,7 +612,6 @@ test "cdp.dom: getBoxModel" {
611612
try ctx.processMessage(.{ // Hacky way to make sure nodeId 0 exists in the registry
612613
.id = 3,
613614
.method = "DOM.getDocument",
614-
.params = .{ .depth = 3 },
615615
});
616616

617617
try ctx.processMessage(.{

0 commit comments

Comments
 (0)