run tasks after microtasks

Also removes `page.tick`.
This commit is contained in:
Halil Durak
2025-12-29 11:04:10 +03:00
parent b28ac8ca19
commit abc89b7eae
2 changed files with 7 additions and 12 deletions

View File

@@ -947,16 +947,6 @@ fn printWaitAnalysis(self: *Page) void {
}
}
pub fn tick(self: *Page) void {
if (comptime IS_DEBUG) {
log.debug(.page, "tick", .{});
}
_ = self.scheduler.run() catch |err| {
log.err(.page, "tick", .{ .err = err });
};
self.js.runMicrotasks();
}
pub fn isGoingAway(self: *const Page) bool {
return self._queued_navigation != null;
}

View File

@@ -801,8 +801,13 @@ pub const Script = struct {
log.debug(.browser, "executed script", .{ .src = url, .success = success, .on_load = script_element._on_load != null });
}
defer {
// We should run microtasks even if script execution fails.
defer page.js.runMicrotasks();
page.js.runMicrotasks();
_ = page.scheduler.run() catch |err| {
log.err(.page, "scheduler", .{ .err = err });
};
}
if (success) {
self.executeCallback("load", script_element._on_load, page);