mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-28 22:53:28 +00:00
send Target.attachedToTarget after Target.setAutoAttach
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user