@@ -83,7 +83,7 @@ pub const Page = struct {
8383
8484 // Our JavaScript context for this specific page. This is what we use to
8585 // execute any JavaScript
86- scope : * Env.Scope ,
86+ main_context : * Env.Context ,
8787
8888 // For a Page we only create one HandleScope and keep it alive for the duration of the page.
8989 // If needed JS Locals' lifetimes can be reduced by layering on additional Scopes.
@@ -112,22 +112,22 @@ pub const Page = struct {
112112 .microtask_node = .{ .func = microtaskCallback },
113113 .window_clicked_event_node = .{ .func = windowClicked },
114114 .request_factory = browser .http_client .requestFactory (browser .notification ),
115- .scope = undefined ,
115+ .main_context = undefined ,
116116 .handle_scope = undefined ,
117117 .module_map = .empty ,
118118 };
119119
120- self .scope = try session .executor .startScope (& self .window , self , self );
120+ self .main_context = try session .executor .createContext (& self .window , self , self );
121121
122122 // Start a scope (stackframe) for JS Local variables.
123123 Env .HandleScope .init (& self .handle_scope , browser .env .isolate );
124124 errdefer self .handle_scope .deinit ();
125125
126- self .scope .enter ();
127- errdefer self .scope .exit ();
126+ self .main_context .enter ();
127+ errdefer self .main_context .exit ();
128128
129129 // load polyfills
130- try polyfill .load (self .arena , self .scope );
130+ try polyfill .load (self .arena , self .main_context );
131131
132132 // _ = try session.browser.app.loop.timeout(1 * std.time.ns_per_ms, &self.microtask_node);
133133 }
@@ -169,7 +169,7 @@ pub const Page = struct {
169169
170170 pub fn wait (self : * Page ) ! void {
171171 var try_catch : Env.TryCatch = undefined ;
172- try_catch .init (self .scope );
172+ try_catch .init (self .main_context );
173173 defer try_catch .deinit ();
174174
175175 try self .session .browser .app .loop .run ();
@@ -664,14 +664,14 @@ const Script = struct {
664664
665665 fn eval (self : * const Script , page : * Page , body : []const u8 ) ! void {
666666 var try_catch : Env.TryCatch = undefined ;
667- try_catch .init (page .scope );
667+ try_catch .init (page .main_context ); // Sjors: Is this always the main context?
668668 defer try_catch .deinit ();
669669
670670 const src = self .src orelse "inline" ;
671671 const res = switch (self .kind ) {
672- .javascript = > page .scope .exec (body , src ),
672+ .javascript = > page .main_context .exec (body , src ),
673673 .module = > blk : {
674- switch (try page .scope .module (body , src )) {
674+ switch (try page .main_context .module (body , src )) {
675675 .value = > | v | break :blk v ,
676676 .exception = > | e | {
677677 log .warn (.page , "eval module" , .{ .src = src , .err = try e .exception (page .arena ) });
@@ -688,7 +688,7 @@ const Script = struct {
688688 _ = res ;
689689
690690 if (self .onload ) | onload | {
691- _ = page .scope .exec (onload , "script_on_load" ) catch {
691+ _ = page .main_context .exec (onload , "script_on_load" ) catch {
692692 if (try try_catch .err (page .arena )) | msg | {
693693 log .warn (.page , "eval onload" , .{ .src = src , .err = msg });
694694 }
0 commit comments