From 4db80cb9e7eb024faa7ff5470d1c43065a724250 Mon Sep 17 00:00:00 2001 From: sjorsdonkers <72333389+sjorsdonkers@users.noreply.github.com> Date: Tue, 29 Apr 2025 18:10:55 +0200 Subject: [PATCH] Adopt state into the isolated world --- src/cdp/domains/target.zig | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cdp/domains/target.zig b/src/cdp/domains/target.zig index 17359866..ac5f8233 100644 --- a/src/cdp/domains/target.zig +++ b/src/cdp/domains/target.zig @@ -127,6 +127,13 @@ fn createTarget(cmd: anytype) !void { const page = try bc.session.createPage(); + // The isolate world must share at least some of the state with the related page, specifically the DocumentHTML + // (assuming grantUniveralAccess will be set to True!). + // We just created the world and the page. The page's state lives in the session, but is update on navigation. + // This also means this pointer becomes invalid after removePage untill a new page is created. + // Currently we have only 1 page/frame and thus also only 1 state in the isolate world. + bc.isolated_world.?.scope.state = &page.state; + { const aux_data = try std.fmt.allocPrint(cmd.arena, "{{\"isDefault\":true,\"type\":\"default\",\"frameId\":\"{s}\"}}", .{target_id}); bc.inspector.contextCreated(