send Target.attachedToTarget after Target.setAutoAttach

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Francis Bouvier
2024-04-15 21:34:00 +02:00
parent ffbfd36502
commit 5e1fe656e8

View File

@@ -5,6 +5,7 @@ const Ctx = server.CmdContext;
const SendFn = server.SendFn;
const result = @import("cdp.zig").result;
const getParams = @import("cdp.zig").getParams;
const stringify = @import("cdp.zig").stringify;
const TargetMethods = enum {
setAutoAttach,
@@ -27,11 +28,15 @@ pub fn target(
};
}
const SessionID = "9559320D92474062597D9875C664CAC0";
const TargetID = "CFCD6EC01573CF29BB638E9DC0F52DDC";
const BrowserContextID = "65618675CB7D3585A95049E9DFE95EA9";
fn tagetSetAutoAttach(
alloc: std.mem.Allocator,
id: u64,
scanner: *std.json.Scanner,
_: *Ctx,
ctx: *Ctx,
) ![]const u8 {
const Params = struct {
autoAttach: bool,
@@ -40,11 +45,29 @@ fn tagetSetAutoAttach(
};
const params = try getParams(alloc, Params, scanner);
std.log.debug("params {any}", .{params});
const AttachToTarget = struct {
method: []const u8 = "Target.attachedToTarget",
params: struct {
sessionId: []const u8 = SessionID,
targetInfo: struct {
targetId: []const u8 = TargetID,
type: []const u8 = "page",
title: []const u8 = "New Incognito tab",
url: []const u8 = "chrome://newtab/",
attached: bool = true,
canAccessOpener: bool = false,
browserContextId: []const u8 = BrowserContextID,
} = .{},
waitingForDebugger: bool = false,
} = .{},
};
const attached = try stringify(alloc, AttachToTarget{});
try server.sendLater(ctx, attached, 0);
return result(alloc, id, null, null);
}
const TargetID = "CFCD6EC01573CF29BB638E9DC0F52DDC";
fn tagetGetTargetInfo(
alloc: std.mem.Allocator,
id: u64,