Skip to content

Commit 5fc763a

Browse files
committed
cdp: add TargetCreated event on createTarget message
1 parent 84614e9 commit 5fc763a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/cdp/target.zig

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,19 @@ const AttachToTarget = struct {
9595
waitingForDebugger: bool = false,
9696
};
9797

98+
const TargetCreated = struct {
99+
sessionId: []const u8,
100+
targetInfo: struct {
101+
targetId: []const u8,
102+
type: []const u8 = "page",
103+
title: []const u8,
104+
url: []const u8,
105+
attached: bool = true,
106+
canAccessOpener: bool = false,
107+
browserContextId: []const u8,
108+
},
109+
};
110+
98111
const TargetFilter = struct {
99112
type: ?[]const u8 = null,
100113
exclude: ?bool = null,
@@ -328,6 +341,19 @@ fn createTarget(
328341
ctx.state.secureContextType = "InsecureScheme";
329342
ctx.state.loaderID = LoaderID;
330343

344+
// send targetCreated event
345+
const created = TargetCreated{
346+
.sessionId = cdp.ContextSessionID,
347+
.targetInfo = .{
348+
.targetId = ctx.state.frameID,
349+
.title = "about:blank",
350+
.url = ctx.state.url,
351+
.browserContextId = input.params.browserContextId orelse ContextID,
352+
.attached = true,
353+
},
354+
};
355+
try cdp.sendEvent(alloc, ctx, "Target.targetCreated", TargetCreated, created, input.sessionId);
356+
331357
// send attachToTarget event
332358
const attached = AttachToTarget{
333359
.sessionId = cdp.ContextSessionID,

0 commit comments

Comments
 (0)