mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 07:03:29 +00:00
Add target.getBrowserContexts
Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
@@ -10,6 +10,7 @@ const stringify = cdp.stringify;
|
||||
const TargetMethods = enum {
|
||||
setAutoAttach,
|
||||
getTargetInfo,
|
||||
getBrowserContexts,
|
||||
createBrowserContext,
|
||||
createTarget,
|
||||
};
|
||||
@@ -26,6 +27,7 @@ pub fn target(
|
||||
return switch (method) {
|
||||
.setAutoAttach => tagetSetAutoAttach(alloc, id, scanner, ctx),
|
||||
.getTargetInfo => tagetGetTargetInfo(alloc, id, scanner, ctx),
|
||||
.getBrowserContexts => getBrowserContexts(alloc, id, scanner, ctx),
|
||||
.createBrowserContext => createBrowserContext(alloc, id, scanner, ctx),
|
||||
.createTarget => createTarget(alloc, id, scanner, ctx),
|
||||
};
|
||||
@@ -118,6 +120,32 @@ fn tagetGetTargetInfo(
|
||||
return result(alloc, id orelse msg.id.?, TargetInfo, targetInfo, null);
|
||||
}
|
||||
|
||||
// Browser context are not handled and not in the roadmap for now
|
||||
// The following methods are "fake"
|
||||
|
||||
fn getBrowserContexts(
|
||||
alloc: std.mem.Allocator,
|
||||
id: ?u16,
|
||||
scanner: *std.json.Scanner,
|
||||
ctx: *Ctx,
|
||||
) ![]const u8 {
|
||||
const msg = try getMsg(alloc, void, scanner);
|
||||
|
||||
// ouptut
|
||||
const Resp = struct {
|
||||
browserContextIds: [][]const u8,
|
||||
};
|
||||
var resp: Resp = undefined;
|
||||
if (ctx.state.contextID) |contextID| {
|
||||
var contextIDs = [1][]const u8{contextID};
|
||||
resp = .{ .browserContextIds = &contextIDs };
|
||||
} else {
|
||||
const contextIDs = [0][]const u8{};
|
||||
resp = .{ .browserContextIds = &contextIDs };
|
||||
}
|
||||
return result(alloc, id orelse msg.id.?, Resp, resp, null);
|
||||
}
|
||||
|
||||
const ContextID = "22648B09EDCCDD11109E2D4FEFBE4F89";
|
||||
const ContextSessionID = "4FDC2CB760A23A220497A05C95417CF4";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user