mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-09-18 18:05:28 -04:00
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.
This commit is contained in:
1 parent
fa1b9ab03d
commit
33b3b0ee47
1 file changed
+30
@@ -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});
|
||||
|
||||
|
||||
Reference in new issue
Block a user