mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-06-11 01:25:53 -04:00
Fix Page.createIsolatedWorld
Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/170 Gets the correct executeContextId from the v8 inspector.
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
.minimum_zig_version = "0.15.2",
|
||||
.dependencies = .{
|
||||
.v8 = .{
|
||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/refs/tags/v0.3.9.tar.gz",
|
||||
.hash = "v8-0.0.0-xddH64iHBACfPm7oAqZerjmLLO6ftP4Yg5V7dtEGcD0i",
|
||||
.url = "https://github.com/lightpanda-io/zig-v8-fork/archive/0c56b7dc38c869d586272068755dadb4f2474264.tar.gz",
|
||||
.hash = "v8-0.0.0-xddH61yIBAD04dV4CHW0qIFiqbOGvkN_-amGdmgbQ3dU",
|
||||
},
|
||||
// .v8 = .{ .path = "../zig-v8-fork" },
|
||||
.brotli = .{
|
||||
|
||||
@@ -128,6 +128,10 @@ pub fn contextCreated(
|
||||
}
|
||||
}
|
||||
|
||||
pub fn getContextId(_: *const Inspector, local: *const js.Local) i32 {
|
||||
return v8.v8__inspector__executionContextId(local.handle);
|
||||
}
|
||||
|
||||
pub fn contextDestroyed(self: *Inspector, context: *const v8.Context) void {
|
||||
v8.v8_inspector__Inspector__ContextDestroyed(self.handle, context);
|
||||
|
||||
|
||||
@@ -257,7 +257,23 @@ fn createIsolatedWorld(cmd: *CDP.Command) !void {
|
||||
const page = bc.session.currentPage() orelse return error.PageNotLoaded;
|
||||
|
||||
const js_context = try world.createContext(page);
|
||||
return cmd.sendResult(.{ .executionContextId = js_context.id }, .{});
|
||||
|
||||
const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":true,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId});
|
||||
|
||||
var ls: js.Local.Scope = undefined;
|
||||
js_context.localScope(&ls);
|
||||
defer ls.deinit();
|
||||
|
||||
bc.inspector_session.inspector.contextCreated(
|
||||
&ls.local,
|
||||
"",
|
||||
page.origin orelse "",
|
||||
aux_data,
|
||||
true,
|
||||
);
|
||||
|
||||
const context_id = bc.inspector_session.inspector.getContextId(&ls.local);
|
||||
return cmd.sendResult(.{ .executionContextId = context_id }, .{});
|
||||
}
|
||||
|
||||
fn navigate(cmd: *CDP.Command) !void {
|
||||
|
||||
Reference in New Issue
Block a user