From 0b72826cabf0dec2fe6f24716ef716bc0cd34b4b Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 15 Apr 2026 16:02:24 +0800 Subject: [PATCH 1/4] Fix Page.createIsolatedWorld Depends on https://github.com/lightpanda-io/zig-v8-fork/pull/170 Gets the correct executeContextId from the v8 inspector. --- build.zig.zon | 4 ++-- src/browser/js/Inspector.zig | 4 ++++ src/cdp/domains/page.zig | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 89590ac8..79f1e66a 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -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 = .{ diff --git a/src/browser/js/Inspector.zig b/src/browser/js/Inspector.zig index d956cc52..0bc81872 100644 --- a/src/browser/js/Inspector.zig +++ b/src/browser/js/Inspector.zig @@ -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); diff --git a/src/cdp/domains/page.zig b/src/cdp/domains/page.zig index 17455391..91af5287 100644 --- a/src/cdp/domains/page.zig +++ b/src/cdp/domains/page.zig @@ -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 { From dd7fbf17ed73c2bee1a38a5c12ff6c6da1c0e0b0 Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 15 Apr 2026 16:11:35 +0800 Subject: [PATCH 2/4] fix default-ness --- src/cdp/domains/page.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cdp/domains/page.zig b/src/cdp/domains/page.zig index 91af5287..80a93cc5 100644 --- a/src/cdp/domains/page.zig +++ b/src/cdp/domains/page.zig @@ -258,7 +258,7 @@ fn createIsolatedWorld(cmd: *CDP.Command) !void { const js_context = try world.createContext(page); - const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":true,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId}); + const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId}); var ls: js.Local.Scope = undefined; js_context.localScope(&ls); @@ -269,7 +269,7 @@ fn createIsolatedWorld(cmd: *CDP.Command) !void { "", page.origin orelse "", aux_data, - true, + false, ); const context_id = bc.inspector_session.inspector.getContextId(&ls.local); From 5dc059cbb3db3771c408852d239e67021cc4406a Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Wed, 15 Apr 2026 17:16:42 +0800 Subject: [PATCH 3/4] maintain isolated world name --- src/cdp/domains/page.zig | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/cdp/domains/page.zig b/src/cdp/domains/page.zig index 80a93cc5..641b2d80 100644 --- a/src/cdp/domains/page.zig +++ b/src/cdp/domains/page.zig @@ -257,7 +257,6 @@ fn createIsolatedWorld(cmd: *CDP.Command) !void { const page = bc.session.currentPage() orelse return error.PageNotLoaded; const js_context = try world.createContext(page); - const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":false,\"type\":\"isolated\",\"frameId\":\"{s}\"}}", .{params.frameId}); var ls: js.Local.Scope = undefined; @@ -266,7 +265,7 @@ fn createIsolatedWorld(cmd: *CDP.Command) !void { bc.inspector_session.inspector.contextCreated( &ls.local, - "", + params.worldName, page.origin orelse "", aux_data, false, From 0adb482bae07a7bf8c6718df9f2ff22bcea4b9cb Mon Sep 17 00:00:00 2001 From: Karl Seguin Date: Thu, 16 Apr 2026 15:02:58 +0800 Subject: [PATCH 4/4] update v8 dep --- .github/actions/install/action.yml | 2 +- Dockerfile | 2 +- build.zig.zon | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/actions/install/action.yml b/.github/actions/install/action.yml index f78b307c..cd3999e8 100644 --- a/.github/actions/install/action.yml +++ b/.github/actions/install/action.yml @@ -13,7 +13,7 @@ inputs: zig-v8: description: 'zig v8 version to install' required: false - default: 'v0.3.9' + default: 'v0.4.0' v8: description: 'v8 version to install' required: false diff --git a/Dockerfile b/Dockerfile index 715441a0..fd872c45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM debian:stable-slim ARG MINISIG=0.12 ARG ZIG_MINISIG=RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U ARG V8=14.0.365.4 -ARG ZIG_V8=v0.3.9 +ARG ZIG_V8=v0.4.0 ARG TARGETPLATFORM RUN apt-get update -yq && \ diff --git a/build.zig.zon b/build.zig.zon index 79f1e66a..ea0517b4 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,7 +5,7 @@ .minimum_zig_version = "0.15.2", .dependencies = .{ .v8 = .{ - .url = "https://github.com/lightpanda-io/zig-v8-fork/archive/0c56b7dc38c869d586272068755dadb4f2474264.tar.gz", + .url = "https://github.com/lightpanda-io/zig-v8-fork/archive/refs/tags/v0.4.0.tar.gz", .hash = "v8-0.0.0-xddH61yIBAD04dV4CHW0qIFiqbOGvkN_-amGdmgbQ3dU", }, // .v8 = .{ .path = "../zig-v8-fork" },