@@ -51,10 +51,6 @@ const polyfill = @import("polyfill/polyfill.zig");
5151pub const Page = struct {
5252 cookie_jar : * storage.CookieJar ,
5353
54- // Pre-configured http/cilent.zig used to make HTTP requests.
55- // @newhttp
56- // request_factory: RequestFactory,
57-
5854 session : * Session ,
5955
6056 // An arena with a lifetime for the entire duration of the page
@@ -146,12 +142,9 @@ pub const Page = struct {
146142 .scheduler = Scheduler .init (arena ),
147143 .keydown_event_node = .{ .func = keydownCallback },
148144 .window_clicked_event_node = .{ .func = windowClicked },
149- // @newhttp
150- // .request_factory = browser.http_client.requestFactory(.{
151- // .notification = browser.notification,
152- // }),
153145 .main_context = undefined ,
154146 };
147+
155148 self .main_context = try session .executor .createJsContext (& self .window , self , self , true , Env .GlobalMissingCallback .init (& self .polyfill_loader ));
156149 try polyfill .preload (self .arena , self .main_context );
157150
@@ -269,7 +262,7 @@ pub const Page = struct {
269262 return self .script_manager .blockingGet (src );
270263 }
271264
272- pub fn wait (self : * Page , wait_sec : usize ) void {
265+ pub fn wait (self : * Page , wait_sec : u16 ) void {
273266 self ._wait (wait_sec ) catch | err | switch (err ) {
274267 error .JsError = > {}, // already logged (with hopefully more context)
275268 else = > {
@@ -283,9 +276,9 @@ pub const Page = struct {
283276 };
284277 }
285278
286- fn _wait (self : * Page , wait_sec : usize ) ! void {
287- var ms_remaining = wait_sec * 1000 ;
279+ fn _wait (self : * Page , wait_sec : u16 ) ! void {
288280 var timer = try std .time .Timer .start ();
281+ var ms_remaining : i32 = @intCast (wait_sec * 1000 );
289282
290283 var try_catch : Env.TryCatch = undefined ;
291284 try_catch .init (self .main_context );
@@ -320,7 +313,7 @@ pub const Page = struct {
320313 }
321314
322315 // There should only be 1 active http transfer, the main page
323- try http_client .tick (ms_remaining );
316+ _ = try http_client .tick (.{ . timeout_ms = ms_remaining } );
324317 },
325318 .html , .parsed = > {
326319 // The HTML page was parsed. We now either have JS scripts to
@@ -381,7 +374,7 @@ pub const Page = struct {
381374 // inflight requests
382375 else @min (ms_remaining , ms_to_next_task orelse 1000 );
383376
384- try http_client .tick (ms_to_wait );
377+ _ = try http_client .tick (.{ . timeout_ms = ms_to_wait } );
385378
386379 if (request_intercepted ) {
387380 // Again, proritizing intercepted requests. Exit this
@@ -401,7 +394,7 @@ pub const Page = struct {
401394 if (ms_elapsed >= ms_remaining ) {
402395 return ;
403396 }
404- ms_remaining -= ms_elapsed ;
397+ ms_remaining -= @intCast ( ms_elapsed ) ;
405398 }
406399 }
407400
0 commit comments