@@ -321,8 +321,11 @@ fn _documentIsComplete(self: *Page) !void {
321321
322322 // dispatch window.load event
323323 const event = try Event .init ("load" , .{}, self );
324+ // this event is weird, it's dispatched directly on the window, but
325+ // with the document as the target
326+ event ._target = self .document .asEventTarget ();
324327 try self ._event_manager .dispatchWithFunction (
325- self .document .asEventTarget (),
328+ self .window .asEventTarget (),
326329 event ,
327330 self .window ._on_load ,
328331 .{ .inject_target = false , .context = "page load" },
@@ -336,6 +339,9 @@ fn pageHeaderDoneCallback(transfer: *Http.Transfer) !void {
336339 const header = & transfer .response_header .? ;
337340 self .url = try self .arena .dupeZ (u8 , std .mem .span (header .url ));
338341
342+ self .window ._location = try Location .init (self .url , self );
343+ self .document ._location = self .window ._location ;
344+
339345 log .debug (.http , "navigate header" , .{
340346 .url = self .url ,
341347 .status = header .status ,
@@ -413,7 +419,7 @@ fn pageDoneCallback(ctx: *anyopaque) !void {
413419 .html = > | buf | {
414420 var parser = Parser .init (self .arena , self .document .asNode (), self );
415421 parser .parse (buf .items );
416- self ._script_manager .pageIsLoaded ();
422+ self ._script_manager .staticScriptsDone ();
417423 if (self ._script_manager .isDone ()) {
418424 // No scripts, or just inline scripts that were already processed
419425 // we need to trigger this ourselves
@@ -629,7 +635,7 @@ fn _wait(self: *Page, wait_ms: u32) !Session.WaitResult {
629635}
630636
631637pub fn scriptAddedCallback (self : * Page , script : * HtmlScript ) ! void {
632- self ._script_manager .add (script , "parsing" ) catch | err | {
638+ self ._script_manager .addFromElement (script , "parsing" ) catch | err | {
633639 log .err (.page , "page.scriptAddedCallback" , .{
634640 .err = err ,
635641 .src = script .asElement ().getAttributeSafe ("src" ),
0 commit comments