Lightpanda: the headless browser designed for AI and automation
Merge branch 'main' into cdp-target-info-changed
Adrià Arrufatd90dcf108c68
diff --cc src/server/cdp/domains/target.zigindex d554913ac,655106889..a42663f5e--- a/src/server/cdp/domains/target.zig+++ b/src/server/cdp/domains/target.zig@@@ -1128,15 -1154,48 +1153,61 @@@ test "cdp.target: setAutoAttach false stry ctx.expectSentResult(null, .{ .id = 12 });}+test "cdp.target: targetInfoChanged reports the page's URL and title" {+ var ctx = try testing.context();+ defer ctx.deinit();++ const bc = try ctx.loadBrowserContext(.{ .id = "BID-TIC", .url = "cdp/accname.html", .target_id = "FID-000000000I".* });+ try ctx.expectSentEvent("Target.targetInfoChanged", .{ .targetInfo = .{+ .targetId = &bc.target_id.?,+ .url = bc.getURL().?,+ .title = "AccName Fixture",+ .browserContextId = "BID-TIC",+ } }, .{});+}+++ test "cdp.target: setAutoAttach with page-exclude filter sends no attachedToTarget" {+ var ctx = try testing.context();+ defer ctx.deinit();++ // Puppeteer's filter: exclude page targets, include the rest.+ try ctx.processMessage(.{+ .id = 1,+ .method = "Target.setAutoAttach",+ .params = .{+ .autoAttach = true,+ .waitForDebuggerOnStart = false,+ .filter = [_]TargetFilter{+ .{ .type = "page", .exclude = true },+ .{},+ },+ },+ });+ try ctx.expectSentResult(null, .{ .id = 1 });+ // The STARTUP placeholder is a page target: with pages+ // excluded, only the result may be sent.+ try ctx.expectSentCount(1);+ }++ test "cdp.target: setAutoAttach without filter still sends startup attachedToTarget" {+ var ctx = try testing.context();+ defer ctx.deinit();++ try ctx.processMessage(.{+ .id = 1,+ .method = "Target.setAutoAttach",+ .params = .{ .autoAttach = true, .waitForDebuggerOnStart = false },+ });+ try ctx.expectSentEvent("Target.attachedToTarget", .{+ .sessionId = "STARTUP",+ .targetInfo = .{+ .targetId = "TID-STARTUP",+ .type = "page",+ .title = "",+ .url = "about:blank",+ .browserContextId = "BID-STARTUP",+ },+ }, .{ .index = 0 });+ try ctx.expectSentResult(null, .{ .id = 1, .index = 1 });+ try ctx.expectSentCount(2);+ }