@@ -2,12 +2,14 @@ const std = @import("std");
22
33const server = @import ("../server.zig" );
44const Ctx = server .Cmd ;
5- const result = @import ("cdp.zig" ).result ;
6- const getParams = @import ("cdp.zig" ).getParams ;
5+ const cdp = @import ("cdp.zig" );
6+ const result = cdp .result ;
7+ const getParams = cdp .getParams ;
78
89const BrowserMethods = enum {
910 getVersion ,
1011 setDownloadBehavior ,
12+ getWindowForTarget ,
1113};
1214
1315pub fn browser (
@@ -22,6 +24,7 @@ pub fn browser(
2224 return switch (method ) {
2325 .getVersion = > browserGetVersion (alloc , id , scanner , ctx ),
2426 .setDownloadBehavior = > browserSetDownloadBehavior (alloc , id , scanner , ctx ),
27+ .getWindowForTarget = > getWindowForTarget (alloc , id , scanner , ctx ),
2528 };
2629}
2730
@@ -70,3 +73,33 @@ fn browserSetDownloadBehavior(
7073 _ = try getParams (alloc , Params , scanner );
7174 return result (alloc , id , null , null , null );
7275}
76+
77+ const DevToolsWindowID = 1923710101 ;
78+
79+ fn getWindowForTarget (
80+ alloc : std.mem.Allocator ,
81+ id : u64 ,
82+ scanner : * std.json.Scanner ,
83+ _ : * Ctx ,
84+ ) ! []const u8 {
85+
86+ // input
87+ const Params = struct {
88+ targetId : ? []const u8 = null ,
89+ };
90+ const content = try cdp .getContent (alloc , ? Params , scanner );
91+ std .debug .assert (content .sessionID != null );
92+
93+ // output
94+ const Resp = struct {
95+ windowId : u64 = DevToolsWindowID ,
96+ bounds : struct {
97+ left : ? u64 = null ,
98+ top : ? u64 = null ,
99+ width : ? u64 = null ,
100+ height : ? u64 = null ,
101+ windowState : []const u8 = "normal" ,
102+ } = .{},
103+ };
104+ return result (alloc , id , Resp , Resp {}, content .sessionID .? );
105+ }
0 commit comments