@@ -10,6 +10,7 @@ const stringify = cdp.stringify;
1010const TargetMethods = enum {
1111 setAutoAttach ,
1212 getTargetInfo ,
13+ getBrowserContexts ,
1314 createBrowserContext ,
1415 createTarget ,
1516};
@@ -26,6 +27,7 @@ pub fn target(
2627 return switch (method ) {
2728 .setAutoAttach = > tagetSetAutoAttach (alloc , id , scanner , ctx ),
2829 .getTargetInfo = > tagetGetTargetInfo (alloc , id , scanner , ctx ),
30+ .getBrowserContexts = > getBrowserContexts (alloc , id , scanner , ctx ),
2931 .createBrowserContext = > createBrowserContext (alloc , id , scanner , ctx ),
3032 .createTarget = > createTarget (alloc , id , scanner , ctx ),
3133 };
@@ -118,6 +120,32 @@ fn tagetGetTargetInfo(
118120 return result (alloc , id orelse msg .id .? , TargetInfo , targetInfo , null );
119121}
120122
123+ // Browser context are not handled and not in the roadmap for now
124+ // The following methods are "fake"
125+
126+ fn getBrowserContexts (
127+ alloc : std.mem.Allocator ,
128+ id : ? u16 ,
129+ scanner : * std.json.Scanner ,
130+ ctx : * Ctx ,
131+ ) ! []const u8 {
132+ const msg = try getMsg (alloc , void , scanner );
133+
134+ // ouptut
135+ const Resp = struct {
136+ browserContextIds : [][]const u8 ,
137+ };
138+ var resp : Resp = undefined ;
139+ if (ctx .state .contextID ) | contextID | {
140+ var contextIDs = [1 ][]const u8 {contextID };
141+ resp = .{ .browserContextIds = & contextIDs };
142+ } else {
143+ const contextIDs = [0 ][]const u8 {};
144+ resp = .{ .browserContextIds = & contextIDs };
145+ }
146+ return result (alloc , id orelse msg .id .? , Resp , resp , null );
147+ }
148+
121149const ContextID = "22648B09EDCCDD11109E2D4FEFBE4F89" ;
122150const ContextSessionID = "4FDC2CB760A23A220497A05C95417CF4" ;
123151
0 commit comments