Skip to content

Commit 2cdc9e9

Browse files
committed
cdp: use a polyfill loader per isolate
1 parent 13c6237 commit 2cdc9e9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/cdp/cdp.zig

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ const Inspector = @import("../browser/env.zig").Env.Inspector;
3030
const Incrementing = @import("../id.zig").Incrementing;
3131
const Notification = @import("../notification.zig").Notification;
3232

33+
const polyfill = @import("../browser/polyfill/polyfill.zig");
34+
3335
pub const URL_BASE = "chrome://newtab/";
3436
pub const LOADER_ID = "LOADERID24DD2FD56CF1EF33C965C79C";
3537

@@ -554,6 +556,10 @@ const IsolatedWorld = struct {
554556
executor: Env.ExecutionWorld,
555557
grant_universal_access: bool,
556558

559+
// Polyfill loader for the isolated world.
560+
// We want to load polyfill in the world's context.
561+
polyfill_loader: polyfill.Loader = .{},
562+
557563
pub fn deinit(self: *IsolatedWorld) void {
558564
self.executor.deinit();
559565
}
@@ -569,7 +575,13 @@ const IsolatedWorld = struct {
569575
// Currently we have only 1 page/frame and thus also only 1 state in the isolate world.
570576
pub fn createContext(self: *IsolatedWorld, page: *Page) !void {
571577
if (self.executor.js_context != null) return error.Only1IsolatedContextSupported;
572-
_ = try self.executor.createJsContext(&page.window, page, {}, false, null);
578+
_ = try self.executor.createJsContext(
579+
&page.window,
580+
page,
581+
{},
582+
false,
583+
Env.GlobalMissingCallback.init(&self.polyfill_loader),
584+
);
573585
}
574586
};
575587

0 commit comments

Comments
 (0)