mirror of
https://github.com/lightpanda-io/browser.git
synced 2025-10-29 15:13:28 +00:00
Reorganize v8 contexts and scope
- Pages within the same session have proper isolation - they have their own window - they have their own SessionState - they have their own v8.Context - Move inspector to CDP browser context - Browser now knows nothing about the inspector - Use notification to emit a context-created message - This is still a bit hacky, but again, it decouples browser from CDP
This commit is contained in:
@@ -112,15 +112,15 @@ fn createIsolatedWorld(cmd: anytype) !void {
|
||||
}
|
||||
const bc = cmd.browser_context orelse return error.BrowserContextNotLoaded;
|
||||
|
||||
try bc.createIsolatedWorld(params.worldName, params.grantUniveralAccess);
|
||||
const world = &bc.isolated_world.?;
|
||||
|
||||
world.name = try bc.arena.dupe(u8, params.worldName);
|
||||
world.grant_universal_access = params.grantUniveralAccess;
|
||||
// Create the auxdata json for the contextCreated event
|
||||
// Calling contextCreated will assign a Id to the context and send the contextCreated event
|
||||
const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId});
|
||||
bc.session.inspector.contextCreated(world.executor, world.name, "", aux_data, false);
|
||||
bc.inspector.contextCreated(world.scope, world.name, "", aux_data, false);
|
||||
|
||||
return cmd.sendResult(.{ .executionContextId = world.executor.context.debugContextId() }, .{});
|
||||
return cmd.sendResult(.{ .executionContextId = world.scope.context.debugContextId() }, .{});
|
||||
}
|
||||
|
||||
fn navigate(cmd: anytype) !void {
|
||||
@@ -222,8 +222,8 @@ pub fn pageNavigate(bc: anytype, event: *const Notification.PageNavigate) !void
|
||||
const aux_json = try std.fmt.bufPrint(&buffer, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{bc.target_id.?});
|
||||
|
||||
// Calling contextCreated will assign a new Id to the context and send the contextCreated event
|
||||
bc.session.inspector.contextCreated(
|
||||
isolated_world.executor,
|
||||
bc.inspector.contextCreated(
|
||||
isolated_world.scope,
|
||||
isolated_world.name,
|
||||
"://",
|
||||
aux_json,
|
||||
|
||||
Reference in New Issue
Block a user