From b43658eb3f35245a998d64ce57cb1785d7b1ab5d Mon Sep 17 00:00:00 2001 From: Pierre Tachoire Date: Thu, 20 Mar 2025 09:27:02 +0100 Subject: [PATCH] cdp: target: add test for #474 Can't attach to just created target --- src/cdp/target.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/cdp/target.zig b/src/cdp/target.zig index 283e14e0..70b4c4fc 100644 --- a/src/cdp/target.zig +++ b/src/cdp/target.zig @@ -608,3 +608,18 @@ test "cdp.target: getTargetInfo" { }, .{ .id = 11 }); } } + +test "cdp.target: issue#474: attach to just created target" { + var ctx = testing.context(); + defer ctx.deinit(); + const bc = try ctx.loadBrowserContext(.{ .id = "BID-9" }); + { + try ctx.processMessage(.{ .id = 10, .method = "Target.createTarget", .params = .{ .browserContextId = "BID-9" } }); + try testing.expectEqual(true, bc.target_id != null); + try ctx.expectSentResult(.{ .targetId = bc.target_id.? }, .{ .id = 10 }); + + try ctx.processMessage(.{ .id = 11, .method = "Target.attachToTarget", .params = .{ .targetId = bc.target_id.? } }); + const session_id = bc.session_id.?; + try ctx.expectSentResult(.{ .sessionId = session_id }, .{ .id = 11 }); + } +}