Fix call to Runtime.executionContextCreated in Page.navigate

Signed-off-by: Francis Bouvier <francis@lightpanda.io>
This commit is contained in:
Francis Bouvier
2024-06-12 17:56:07 +02:00
parent 9120b9c1de
commit 7abb7277c9
2 changed files with 16 additions and 24 deletions

View File

@@ -94,6 +94,7 @@ pub fn do(
} }
pub const State = struct { pub const State = struct {
executionContextId: u8 = 0,
contextID: ?[]const u8 = null, contextID: ?[]const u8 = null,
frameID: []const u8 = FrameID, frameID: []const u8 = FrameID,
url: []const u8 = URLBase, url: []const u8 = URLBase,

View File

@@ -225,13 +225,26 @@ fn navigate(
std.log.debug("res {s}", .{res}); std.log.debug("res {s}", .{res});
try server.sendSync(ctx, res); try server.sendSync(ctx, res);
// Runtime.executionContextsCleared event // Send clear runtime contexts event (noop)
try sendEvent(alloc, ctx, "Runtime.executionContextsCleared", void, {}, msg.sessionID); try sendEvent(alloc, ctx, "Runtime.executionContextsCleared", void, {}, msg.sessionID);
// launch navigate // Launch navigate
var p = try ctx.browser.currentSession().createPage(); var p = try ctx.browser.currentSession().createPage();
_ = try p.navigate(params.url); _ = try p.navigate(params.url);
// Send create runtime context event
ctx.state.executionContextId += 1;
try Runtime.executionContextCreated(
alloc,
ctx,
ctx.state.executionContextId,
"http://127.0.0.1:1234", // TODO: real domain
"",
"7102379147004877974.3265385113993241162",
.{ .frameId = ctx.state.frameID },
msg.sessionID,
);
// frameNavigated event // frameNavigated event
const FrameNavigated = struct { const FrameNavigated = struct {
frame: Frame, frame: Frame,
@@ -267,28 +280,6 @@ fn navigate(
); );
} }
try Runtime.executionContextCreated(
alloc,
ctx,
3,
"http://127.0.0.1:1234",
"",
"7102379147004877974.3265385113993241162",
.{ .frameId = ctx.state.frameID },
msg.sessionID,
);
try Runtime.executionContextCreated(
alloc,
ctx,
4,
"://",
"__playwright_utility_world__",
"-4572718120346458707.6016875269626438350",
.{ .isDefault = false, .type = "isolated", .frameId = ctx.state.frameID },
msg.sessionID,
);
// domContentEventFired event // domContentEventFired event
ts_event = .{ .timestamp = 343721.803338 }; ts_event = .{ .timestamp = 343721.803338 };
try sendEvent( try sendEvent(