File tree Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Expand file tree Collapse file tree 4 files changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -100,6 +100,7 @@ pub fn do(
100100pub const State = struct {
101101 executionContextId : u32 = 0 ,
102102 contextID : ? []const u8 = null ,
103+ sessionID : ? []const u8 = null ,
103104 frameID : []const u8 = FrameID ,
104105 url : []const u8 = URLBase ,
105106 securityOrigin : []const u8 = URLBase ,
Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ fn sendInspector(
117117 }
118118 }
119119
120+ ctx .state .sessionID = msg .sessionId ;
121+
120122 // remove awaitPromise true params
121123 // TODO: delete when Promise are correctly handled by zig-js-runtime
122124 if (method == .callFunctionOn or method == .evaluate ) {
@@ -129,13 +131,11 @@ fn sendInspector(
129131 }
130132 }
131133
132- ctx .sendInspector (msg .json );
133-
134134 if (method == .enable ) {
135135 try executionContextCreated (
136136 alloc ,
137137 ctx ,
138- 0 ,
138+ 1 ,
139139 "://" ,
140140 "" ,
141141 // TODO: hard coded ID
@@ -147,10 +147,12 @@ fn sendInspector(
147147 .frameId = cdp .FrameID ,
148148 },
149149 // TODO: hard coded ID
150- target .BrowserContextID ,
150+ msg . sessionId orelse target .BrowserContextID ,
151151 );
152152 }
153153
154+ ctx .sendInspector (msg .json );
155+
154156 return "" ;
155157}
156158
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ fn attachToTarget(
156156 const attached = AttachToTarget {
157157 .sessionId = cdp .BrowserSessionID ,
158158 .targetInfo = .{
159- .targetId = PageTargetID ,
159+ .targetId = input . params . targetId ,
160160 .title = "New Incognito tab" ,
161161 .url = cdp .URLBase ,
162162 .browserContextId = BrowserContextID ,
@@ -327,15 +327,17 @@ fn createTarget(
327327 ctx .state .securityOrigin = "://" ;
328328 ctx .state .secureContextType = "InsecureScheme" ;
329329 ctx .state .loaderID = LoaderID ;
330+ ctx .state .sessionID = msg .sessionId ;
330331
331332 // send attachToTarget event
332333 const attached = AttachToTarget {
333334 .sessionId = cdp .ContextSessionID ,
334335 .targetInfo = .{
335336 .targetId = ctx .state .frameID ,
336- .title = "" ,
337+ .title = "New Incognito tab " ,
337338 .url = ctx .state .url ,
338339 .browserContextId = input .params .browserContextId orelse ContextID ,
340+ .attached = true ,
339341 },
340342 .waitingForDebugger = true ,
341343 };
Original file line number Diff line number Diff line change @@ -347,7 +347,7 @@ pub const Ctx = struct {
347347 const s = try std .fmt .allocPrint (
348348 allocator ,
349349 tpl ,
350- .{ msg_open , cdp .ContextSessionID },
350+ .{ msg_open , ctx . state . sessionID orelse cdp .ContextSessionID },
351351 );
352352
353353 try ctx .send (s );
You can’t perform that action at this time.
0 commit comments