Skip to content

Commit c57e50c

Browse files
Handle Runtime.evaluate (no-op)
Signed-off-by: Francis Bouvier <[email protected]>
1 parent bafdca3 commit c57e50c

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/cdp/runtime.zig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const stringify = cdp.stringify;
1010
const RuntimeMethods = enum {
1111
enable,
1212
runIfWaitingForDebugger,
13+
evaluate,
1314
};
1415

1516
pub fn runtime(
@@ -24,6 +25,7 @@ pub fn runtime(
2425
return switch (method) {
2526
.enable => enable(alloc, id, scanner, ctx),
2627
.runIfWaitingForDebugger => runIfWaitingForDebugger(alloc, id, scanner, ctx),
28+
.evaluate => evaluate(alloc, id, scanner, ctx),
2729
};
2830
}
2931

@@ -103,3 +105,25 @@ fn runIfWaitingForDebugger(
103105
const sessionID = try cdp.getSessionID(scanner);
104106
return result(alloc, id, null, null, sessionID);
105107
}
108+
109+
fn evaluate(
110+
alloc: std.mem.Allocator,
111+
_: u64,
112+
scanner: *std.json.Scanner,
113+
_: *Ctx,
114+
) ![]const u8 {
115+
116+
// input
117+
const Params = struct {
118+
expression: []const u8,
119+
contextId: ?u8,
120+
};
121+
122+
const input = try cdp.getContent(alloc, Params, scanner);
123+
const sessionID = input.sessionID;
124+
std.debug.assert(sessionID != null);
125+
126+
std.log.debug("expr: len {d}", .{input.params.expression.len});
127+
128+
return error.CDPNormal;
129+
}

src/server.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const Error = IOError || std.fmt.ParseIntError || cdp.Error || NoError;
1818
// I/O Recv
1919
// --------
2020

21-
const BufReadSize = 1024;
21+
const BufReadSize = 1024; // 1KB
2222

2323
pub const Cmd = struct {
2424

@@ -332,7 +332,7 @@ pub fn listen(browser: *Browser, socket: std.os.socket_t) anyerror!void {
332332
const loop = browser.currentSession().loop;
333333

334334
// MsgBuffer
335-
var msg_buf = try MsgBuffer.init(loop.alloc, BufReadSize);
335+
var msg_buf = try MsgBuffer.init(loop.alloc, BufReadSize * 256); // 256KB
336336
defer msg_buf.deinit(loop.alloc);
337337

338338
// create I/O contexts and callbacks

0 commit comments

Comments
 (0)