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 89590ac8..ea0517b4 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/refs/tags/v0.4.0.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 02a899d1..ab7c8397 100644 --- a/src/cdp/domains/page.zig +++ b/src/cdp/domains/page.zig @@ -257,7 +257,22 @@ 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\":false,\"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, + params.worldName, + page.origin orelse "", + aux_data, + false, + ); + + const context_id = bc.inspector_session.inspector.getContextId(&ls.local); + return cmd.sendResult(.{ .executionContextId = context_id }, .{}); } fn navigate(cmd: *CDP.Command) !void {