Skip to content

Commit 7abb727

Browse files
Fix call to Runtime.executionContextCreated in Page.navigate
Signed-off-by: Francis Bouvier <[email protected]>
1 parent 9120b9c commit 7abb727

File tree

2 files changed

+16
-24
lines changed

2 files changed

+16
-24
lines changed

src/cdp/cdp.zig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ pub fn do(
9494
}
9595

9696
pub const State = struct {
97+
executionContextId: u8 = 0,
9798
contextID: ?[]const u8 = null,
9899
frameID: []const u8 = FrameID,
99100
url: []const u8 = URLBase,

src/cdp/page.zig

Lines changed: 15 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -225,13 +225,26 @@ fn navigate(
225225
std.log.debug("res {s}", .{res});
226226
try server.sendSync(ctx, res);
227227

228-
// Runtime.executionContextsCleared event
228+
// Send clear runtime contexts event (noop)
229229
try sendEvent(alloc, ctx, "Runtime.executionContextsCleared", void, {}, msg.sessionID);
230230

231-
// launch navigate
231+
// Launch navigate
232232
var p = try ctx.browser.currentSession().createPage();
233233
_ = try p.navigate(params.url);
234234

235+
// Send create runtime context event
236+
ctx.state.executionContextId += 1;
237+
try Runtime.executionContextCreated(
238+
alloc,
239+
ctx,
240+
ctx.state.executionContextId,
241+
"http://127.0.0.1:1234", // TODO: real domain
242+
"",
243+
"7102379147004877974.3265385113993241162",
244+
.{ .frameId = ctx.state.frameID },
245+
msg.sessionID,
246+
);
247+
235248
// frameNavigated event
236249
const FrameNavigated = struct {
237250
frame: Frame,
@@ -267,28 +280,6 @@ fn navigate(
267280
);
268281
}
269282

270-
try Runtime.executionContextCreated(
271-
alloc,
272-
ctx,
273-
3,
274-
"http://127.0.0.1:1234",
275-
"",
276-
"7102379147004877974.3265385113993241162",
277-
.{ .frameId = ctx.state.frameID },
278-
msg.sessionID,
279-
);
280-
281-
try Runtime.executionContextCreated(
282-
alloc,
283-
ctx,
284-
4,
285-
"://",
286-
"__playwright_utility_world__",
287-
"-4572718120346458707.6016875269626438350",
288-
.{ .isDefault = false, .type = "isolated", .frameId = ctx.state.frameID },
289-
msg.sessionID,
290-
);
291-
292283
// domContentEventFired event
293284
ts_event = .{ .timestamp = 343721.803338 };
294285
try sendEvent(

0 commit comments

Comments
 (0)