From 33b3b0ee47dba3a7cd5aecbd36dc19a4d762d9ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Fri, 28 Aug 2026 10:35:36 +0200 Subject: [PATCH] cdp: pass more Runtime methods through to the inspector The whitelist rejected methods the V8 inspector already implements, notably releaseObjectGroup, which Puppeteer sends on handle disposal. Bookkeeping methods that cannot observe or change the page's global skip the main_world_touched mark. --- src/cdp/domains/runtime.zig | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/cdp/domains/runtime.zig b/src/cdp/domains/runtime.zig index 0942594b0..7e8774aa9 100644 --- a/src/cdp/domains/runtime.zig +++ b/src/cdp/domains/runtime.zig @@ -35,12 +35,28 @@ pub fn processMessage(cmd: *CDP.Command) !void { callFunctionOn, releaseObject, getProperties, + releaseObjectGroup, + awaitPromise, + compileScript, + runScript, + queryObjects, + globalLexicalScopeNames, + removeBinding, + terminateExecution, + getExceptionDetails, + discardConsoleEntries, + getHeapUsage, + getIsolateId, + setCustomObjectFormatterEnabled, + setMaxCallStackSizeToCapture, }, cmd.input.action) orelse return error.UnknownMethod; switch (action) { .runIfWaitingForDebugger => return cmd.sendResult(null, .{}), .enable => return enable(cmd), .disable => return disable(cmd), + // Bookkeeping that can neither observe nor change the page's global. + .releaseObjectGroup, .discardConsoleEntries, .getHeapUsage, .getIsolateId, .setCustomObjectFormatterEnabled, .setMaxCallStackSizeToCapture => return sendInspector(cmd, action), else => { const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded; bc.main_world_touched = true; @@ -171,6 +187,20 @@ pub fn consoleMessage(arena: Allocator, bc: *CDP.BrowserContext, event: *const N const testing = @import("../testing.zig"); +test "cdp.runtime: inspector-handled methods pass through" { + var ctx = try testing.context(); + defer ctx.deinit(); + + _ = try ctx.loadBrowserContext(.{ .id = "BID-RT", .url = "hi.html", .target_id = "FID-0000000RTP".* }); + try ctx.processMessage(.{ .id = 50, .method = "Runtime.enable" }); + + try ctx.processMessage(.{ .id = 51, .method = "Runtime.releaseObjectGroup", .params = .{ .objectGroup = "handles" } }); + try ctx.expectSentResult(null, .{ .id = 51 }); + + try ctx.processMessage(.{ .id = 52, .method = "Runtime.discardConsoleEntries" }); + try ctx.expectSentResult(null, .{ .id = 52 }); +} + test "cdp.runtime: consoleAPICalled type matches the console method" { testing.silenceLog(&.{.js});