page cleanup

This commit is contained in:
sjorsdonkers
2025-04-22 11:33:03 +02:00
committed by Sjors
parent 09850d7500
commit 9ae4d66194

View File

@@ -113,15 +113,14 @@ fn createIsolatedWorld(cmd: anytype) !void {
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded; const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
try bc.createIsolatedWorld(params.worldName, params.grantUniveralAccess); try bc.createIsolatedWorld(params.worldName, params.grantUniveralAccess);
const world = &bc.isolated_world.?;
// Create the auxdata json for the contextCreated event // Create the auxdata json for the contextCreated event
// Calling contextCreated will assign a Id to the context and send the contextCreated event // Calling contextCreated will assign a Id to the context and send the contextCreated event
const aux_json = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId}); const aux_json = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId});
bc.session.inspector.contextCreated(bc.isolated_world.?.executor, bc.isolated_world.?.name, "", aux_json, false); bc.session.inspector.contextCreated(world.executor, world.name, "", aux_json, false);
return cmd.sendResult(.{ return cmd.sendResult(.{ .executionContextId = world.executor.context.debugContextId() }, .{});
.executionContextId = bc.isolated_world.?.executor.context.debugContextId(),
}, .{});
} }
fn navigate(cmd: anytype) !void { fn navigate(cmd: anytype) !void {
@@ -221,17 +220,14 @@ pub fn pageNavigate(bc: anytype, event: *const Notification.PageNavigate) !void
// The client will expect us to send new contextCreated events, such that the client has new id's for the active contexts. // The client will expect us to send new contextCreated events, such that the client has new id's for the active contexts.
try cdp.sendEvent("Runtime.executionContextsCleared", null, .{ .session_id = session_id }); try cdp.sendEvent("Runtime.executionContextsCleared", null, .{ .session_id = session_id });
if (bc.isolated_world != null) { if (bc.isolated_world) |*isolated_world| {
const aux_json = try std.fmt.allocPrint( // TODO change the allocator
bc.session.arena.allocator(), // TODO change this const aux_json = try std.fmt.allocPrint(bc.session.arena.allocator(), "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{bc.target_id.?});
"{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}",
.{bc.target_id.?},
);
// Calling contextCreated will assign a new Id to the context and send the contextCreated event // Calling contextCreated will assign a new Id to the context and send the contextCreated event
bc.session.inspector.contextCreated( bc.session.inspector.contextCreated(
bc.isolated_world.?.executor, isolated_world.executor,
bc.isolated_world.?.name, isolated_world.name,
"://", "://",
aux_json, aux_json,
false, false,