@@ -39,10 +39,13 @@ pub const Document = @import("../testing.zig").Document;
3939const Browser = struct {
4040 session : ? * Session = null ,
4141 arena : std.heap.ArenaAllocator ,
42+ env : Env ,
43+ pub const EnvType = Env ;
4244
4345 pub fn init (app : * App ) ! Browser {
4446 return .{
4547 .arena = std .heap .ArenaAllocator .init (app .allocator ),
48+ .env = Env {},
4649 };
4750 }
4851
@@ -56,13 +59,14 @@ const Browser = struct {
5659 return error .MockBrowserSessionAlreadyExists ;
5760 }
5861 const arena = self .arena .allocator ();
59- const executor = arena .create (Executor ) catch unreachable ;
62+ const executor = arena .create (Env . Executor ) catch unreachable ;
6063 self .session = try arena .create (Session );
6164 self .session .?.* = .{
6265 .page = null ,
63- .arena = arena ,
66+ .arena = self . arena ,
6467 .executor = executor ,
6568 .inspector = .{},
69+ .state = 0 ,
6670 };
6771 return self .session .? ;
6872 }
@@ -77,9 +81,10 @@ const Browser = struct {
7781
7882const Session = struct {
7983 page : ? Page = null ,
80- arena : Allocator ,
81- executor : * Executor ,
84+ arena : std.heap.ArenaAllocator ,
85+ executor : * Env. Executor ,
8286 inspector : Inspector ,
87+ state : i32 ,
8388
8489 pub fn currentPage (self : * Session ) ? * Page {
8590 return &(self .page orelse return null );
@@ -92,7 +97,7 @@ const Session = struct {
9297 self .page = .{
9398 .session = self ,
9499 .url = URL .parse ("https://lightpanda.io/" , null ) catch unreachable ,
95- .aux_data = try self .arena .dupe (u8 , aux_data orelse "" ),
100+ .aux_data = try self .arena .allocator (). dupe (u8 , aux_data orelse "" ),
96101 };
97102 return & self .page .? ;
98103 }
@@ -107,12 +112,43 @@ const Session = struct {
107112 }
108113};
109114
110- const Executor = struct {};
115+ const Env = struct {
116+ pub const Executor = MockExecutor ;
117+ pub fn startExecutor (self : * Env , comptime Global : type , state : anytype , module_loader : anytype , kind : anytype ) ! * Executor {
118+ _ = self ;
119+ _ = Global ;
120+ _ = state ;
121+ _ = module_loader ;
122+ _ = kind ;
123+ return error .MockExecutor ;
124+ }
125+ pub fn stopExecutor (self : * Env , executor : * Executor ) void {
126+ _ = self ;
127+ _ = executor ;
128+ }
129+ };
130+ const MockExecutor = struct {
131+ context : Context ,
132+
133+ pub fn startScope (self : * MockExecutor , global : anytype ) ! void {
134+ _ = self ;
135+ _ = global ;
136+ }
137+ pub fn endScope (self : * MockExecutor ) void {
138+ _ = self ;
139+ }
140+ };
141+ const Context = struct {
142+ pub fn debugContextId (self : Context ) i32 {
143+ _ = self ;
144+ return 0 ;
145+ }
146+ };
111147
112148const Inspector = struct {
113149 pub fn getRemoteObject (
114150 self : * const Inspector ,
115- executor : * Executor ,
151+ executor : * Env. Executor ,
116152 group : []const u8 ,
117153 value : anytype ,
118154 ) ! RemoteObject {
@@ -127,6 +163,19 @@ const Inspector = struct {
127163 _ = object_id ;
128164 return try alloc .create (i32 );
129165 }
166+ pub fn contextCreated (self : * const Inspector ,
167+ executor : * const Env.Executor ,
168+ name : []const u8 ,
169+ origin : []const u8 ,
170+ aux_data : ? []const u8 ,
171+ is_default_context : bool ,) void {
172+ _ = self ;
173+ _ = executor ;
174+ _ = name ;
175+ _ = origin ;
176+ _ = aux_data ;
177+ _ = is_default_context ;
178+ }
130179};
131180
132181const RemoteObject = struct {
0 commit comments