have our js.Context directly hold a js handle

This commit is contained in:
Karl Seguin
2025-12-31 19:13:13 +08:00
parent 363b95bdef
commit 701de08e8a
13 changed files with 97 additions and 73 deletions

View File

@@ -23,6 +23,8 @@ const DOMNode = @import("../../browser/webapi/Node.zig");
const Selector = @import("../../browser/webapi/selector/Selector.zig");
const dump = @import("../../browser/dump.zig");
const js = @import("../../browser/js/js.zig");
const v8 = js.v8;
const Allocator = std.mem.Allocator;
@@ -273,10 +275,12 @@ fn resolveNode(cmd: anytype) !void {
var js_context = page.js;
if (params.executionContextId) |context_id| {
if (js_context.v8_context.debugContextId() != context_id) {
const v8_context = v8.Context{ .handle = js_context.handle };
if (v8_context.debugContextId() != context_id) {
for (bc.isolated_worlds.items) |*isolated_world| {
js_context = &(isolated_world.executor.context orelse return error.ContextNotFound);
if (js_context.v8_context.debugContextId() == context_id) {
const isolated_v8_context = v8.Context{ .handle = js_context.handle };
if (isolated_v8_context.debugContextId() == context_id) {
break;
}
} else return error.ContextNotFound;

View File

@@ -21,6 +21,8 @@ const Page = @import("../../browser/Page.zig");
const timestampF = @import("../../datetime.zig").timestamp;
const Notification = @import("../../Notification.zig");
const log = @import("../../log.zig");
const js = @import("../../browser/js/js.zig");
const v8 = js.v8;
const Allocator = std.mem.Allocator;
@@ -194,7 +196,8 @@ fn createIsolatedWorld(cmd: anytype) !void {
const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId});
bc.inspector.contextCreated(js_context, world.name, "", aux_data, false);
return cmd.sendResult(.{ .executionContextId = js_context.v8_context.debugContextId() }, .{});
const v8_context = v8.Context{ .handle = js_context.handle };
return cmd.sendResult(.{ .executionContextId = v8_context.debugContextId() }, .{});
}
fn navigate(cmd: anytype) !void {