debug: limit macrotask runner to when we have a page

This is the only main change in this branch compared to main that could explain
the Debug check failed: isolate()->CurrentLocalHeap()->IsRunning() failure
being reported.
This commit is contained in:
Karl Seguin
2026-06-25 18:53:44 +08:00
parent bb15e5ff08
commit 93ff42b161

View File

@@ -215,7 +215,9 @@ fn _tick(self: *Runner, comptime is_cdp: bool, timeout_ms: u32, conditions: []Wa
return .{ .ok = 0 };
}
try browser.runMacrotasks();
if (hasRunnablePage(session)) {
try browser.runMacrotasks();
}
const http_active = http_client.http_active;
const http_next_tick = http_client.next_tick_count;
@@ -431,6 +433,17 @@ fn firstConditionError(conditions: []const WaitCondition) !void {
}
}
fn hasRunnablePage(session: *Session) bool {
for (session.pages.items) |page| {
const target = page.replacement orelse page;
switch (target.frame._parse_state) {
.html, .complete => return true,
else => {},
}
}
return false;
}
const testing = @import("../testing.zig");
test "Runner: waitForSelector timeout" {
const page = try testing.pageTest("runner/runner1.html", .{});