Skip to content

Commit 3738e8e

Browse files
committed
cdp: add DOM.enable
1 parent 4b000e4 commit 3738e8e

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed

src/cdp/cdp.zig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ const performance = @import("performance.zig").performance;
3333
const IncomingMessage = @import("msg.zig").IncomingMessage;
3434
const Input = @import("msg.zig").Input;
3535
const inspector = @import("inspector.zig").inspector;
36+
const dom = @import("dom.zig").dom;
3637

3738
const log_cdp = std.log.scoped(.cdp);
3839

@@ -61,6 +62,7 @@ const Domains = enum {
6162
Log,
6263
Runtime,
6364
Network,
65+
DOM,
6466
Inspector,
6567
Emulation,
6668
Fetch,
@@ -102,6 +104,7 @@ pub fn dispatch(
102104
.Log => log(alloc, msg, action, ctx),
103105
.Runtime => runtime(alloc, msg, action, ctx),
104106
.Network => network(alloc, msg, action, ctx),
107+
.DOM => dom(alloc, msg, action, ctx),
105108
.Inspector => inspector(alloc, msg, action, ctx),
106109
.Emulation => emulation(alloc, msg, action, ctx),
107110
.Fetch => fetch(alloc, msg, action, ctx),

src/cdp/dom.zig

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright (C) 2023-2024 Lightpanda (Selecy SAS)
2+
//
3+
// Francis Bouvier <[email protected]>
4+
// Pierre Tachoire <[email protected]>
5+
//
6+
// This program is free software: you can redistribute it and/or modify
7+
// it under the terms of the GNU Affero General Public License as
8+
// published by the Free Software Foundation, either version 3 of the
9+
// License, or (at your option) any later version.
10+
//
11+
// This program is distributed in the hope that it will be useful,
12+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
// GNU Affero General Public License for more details.
15+
//
16+
// You should have received a copy of the GNU Affero General Public License
17+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
18+
19+
const std = @import("std");
20+
21+
const server = @import("../server.zig");
22+
const Ctx = server.Ctx;
23+
const cdp = @import("cdp.zig");
24+
const result = cdp.result;
25+
const IncomingMessage = @import("msg.zig").IncomingMessage;
26+
const Input = @import("msg.zig").Input;
27+
28+
const log = std.log.scoped(.cdp);
29+
30+
const Methods = enum {
31+
enable,
32+
};
33+
34+
pub fn dom(
35+
alloc: std.mem.Allocator,
36+
msg: *IncomingMessage,
37+
action: []const u8,
38+
ctx: *Ctx,
39+
) ![]const u8 {
40+
const method = std.meta.stringToEnum(Methods, action) orelse
41+
return error.UnknownMethod;
42+
43+
return switch (method) {
44+
.enable => enable(alloc, msg, ctx),
45+
};
46+
}
47+
48+
fn enable(
49+
alloc: std.mem.Allocator,
50+
msg: *IncomingMessage,
51+
_: *Ctx,
52+
) ![]const u8 {
53+
// input
54+
const input = try Input(void).get(alloc, msg);
55+
defer input.deinit();
56+
log.debug("Req > id {d}, method {s}", .{ input.id, "inspector.enable" });
57+
58+
return result(alloc, input.id, null, null, input.sessionId);
59+
}

0 commit comments

Comments
 (0)