cdp: add TargetCreated event on createTarget message

This commit is contained in:
Pierre Tachoire
2025-01-07 10:34:47 +01:00
parent 84614e903c
commit 5fc763a738

View File

@@ -95,6 +95,19 @@ const AttachToTarget = struct {
waitingForDebugger: bool = false, waitingForDebugger: bool = false,
}; };
const TargetCreated = struct {
sessionId: []const u8,
targetInfo: struct {
targetId: []const u8,
type: []const u8 = "page",
title: []const u8,
url: []const u8,
attached: bool = true,
canAccessOpener: bool = false,
browserContextId: []const u8,
},
};
const TargetFilter = struct { const TargetFilter = struct {
type: ?[]const u8 = null, type: ?[]const u8 = null,
exclude: ?bool = null, exclude: ?bool = null,
@@ -328,6 +341,19 @@ fn createTarget(
ctx.state.secureContextType = "InsecureScheme"; ctx.state.secureContextType = "InsecureScheme";
ctx.state.loaderID = LoaderID; ctx.state.loaderID = LoaderID;
// send targetCreated event
const created = TargetCreated{
.sessionId = cdp.ContextSessionID,
.targetInfo = .{
.targetId = ctx.state.frameID,
.title = "about:blank",
.url = ctx.state.url,
.browserContextId = input.params.browserContextId orelse ContextID,
.attached = true,
},
};
try cdp.sendEvent(alloc, ctx, "Target.targetCreated", TargetCreated, created, input.sessionId);
// send attachToTarget event // send attachToTarget event
const attached = AttachToTarget{ const attached = AttachToTarget{
.sessionId = cdp.ContextSessionID, .sessionId = cdp.ContextSessionID,