Skip to content

Commit 94075e0

Browse files
committed
cdp: fix Target.getTargetInfo message
The getTargetInfo result must return a `targetInfo` key. Here is an example returned by Chrome: ```json { "id": 16, "result": { "targetInfo": { "targetId": "d93a1bbc-f906-4bbb-bb4d-a2285234b091", "type": "browser", "title": "", "url": "", "attached": true, "canAccessOpener": false } } } ```
1 parent 6ae4ed9 commit 94075e0

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

src/cdp/target.zig

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,14 @@ fn getTargetInfo(cmd: anytype) !void {
146146
// })) orelse return error.InvalidParams;
147147

148148
return cmd.sendResult(.{
149-
.targetId = BROWSER_TARGET_ID,
150-
.type = "browser",
151-
.title = "",
152-
.url = "",
153-
.attached = true,
154-
.canAccessOpener = false,
149+
.targetInfo = .{
150+
.targetId = BROWSER_TARGET_ID,
151+
.type = "browser",
152+
.title = "",
153+
.url = "",
154+
.attached = true,
155+
.canAccessOpener = false,
156+
},
155157
}, .{ .include_session_id = false });
156158
}
157159

@@ -368,3 +370,27 @@ fn sendMessageToTarget(cmd: anytype) !void {
368370
fn detachFromTarget(cmd: anytype) !void {
369371
return cmd.sendResult(null, .{});
370372
}
373+
374+
const testing = @import("testing.zig");
375+
test "cdp.target: getTargetInfo" {
376+
var ctx = testing.context();
377+
defer ctx.deinit();
378+
379+
try ctx.processMessage(.{
380+
.id = 32,
381+
.sessionID = "leto",
382+
.method = "Target.getTargetInfo",
383+
});
384+
385+
try ctx.expectSentCount(1);
386+
try ctx.expectSentResult(.{
387+
.targetInfo = .{
388+
.targetId = BROWSER_TARGET_ID,
389+
.type = "browser",
390+
.title = "",
391+
.url = "",
392+
.attached = true,
393+
.canAccessOpener = false,
394+
},
395+
}, .{ .id = 32, .index = 0 });
396+
}

0 commit comments

Comments
 (0)