diff --git a/src/browser/Runner.zig b/src/browser/Runner.zig
index e85dc09b4..5264accb9 100644
--- a/src/browser/Runner.zig
+++ b/src/browser/Runner.zig
@@ -20,6 +20,7 @@ const std = @import("std");
const lp = @import("lightpanda");
const js = @import("js/js.zig");
+const Frame = @import("Frame.zig");
const Browser = @import("Browser.zig");
const Session = @import("Session.zig");
const HttpClient = @import("../network/HttpClient.zig");
@@ -521,9 +522,16 @@ test "Runner: networkidle notifies child frames" {
// A `.networkidle` wait resolves via `is_done` once the page is fully
// idle, which can happen before the 500ms idle-notification hold. Keep
- // ticking (like the CDP serve loop does) until the notifications fire.
+ // ticking (like the CDP serve loop does) until the notifications fire,
+ // backdating each started hold so the test doesn't spend it.
+ const held_since = lp.datetime.milliTimestamp(.boot) -| 600;
var attempts: usize = 0;
while (frame._notified_network_idle != .done and attempts < 50) : (attempts += 1) {
+ const children = frame.child_frames.items;
+ for ([_]*Frame{ frame, children[0], children[1] }) |f| {
+ if (f._notified_network_idle == .triggered) f._notified_network_idle = .{ .triggered = held_since };
+ if (f._notified_network_almost_idle == .triggered) f._notified_network_almost_idle = .{ .triggered = held_since };
+ }
_ = try runner.tickForFrame(page.frame_id, 20, .{ .until = .networkidle });
lp.io.sleep(.fromMilliseconds(25), .awake) catch {};
}
@@ -611,9 +619,9 @@ test "Runner: waits out a throttled navigation" {
const http_client = &session.browser.http_client;
// Enable the per-host navigation throttle for this test only, and spend
- // 127.0.0.1's slot so the navigation below has to wait ~300ms.
+ // 127.0.0.1's slot so the navigation below has to wait ~100ms.
const network = http_client.network;
- network.rate_limiter = @import("../network/RateLimiter.zig").init(testing.allocator, 300, 1);
+ network.rate_limiter = @import("../network/RateLimiter.zig").init(testing.allocator, 100, 1);
defer {
network.rate_limiter.?.deinit();
network.rate_limiter = null;
@@ -631,7 +639,7 @@ test "Runner: waits out a throttled navigation" {
var runner = session.runner(.{});
try runner.waitForFrame(page.frame_id, 2000, .{ .until = .done });
const elapsed = lp.datetime.milliTimestamp(.boot) - start;
- try testing.expectEqual(true, elapsed >= 250);
+ try testing.expectEqual(true, elapsed >= 80);
try testing.expectEqual(0, http_client.delayed_count);
const el = try runner.waitForSelector(page.frame_id, "#sel1", 10);
diff --git a/src/browser/tests/runner/iframe_lazy.html b/src/browser/tests/runner/iframe_lazy.html
index 373beffb6..393462de6 100644
--- a/src/browser/tests/runner/iframe_lazy.html
+++ b/src/browser/tests/runner/iframe_lazy.html
@@ -1,4 +1,4 @@
-
+
diff --git a/src/crash_handler.zig b/src/crash_handler.zig
index 5ae1ec18c..781b1c1b8 100644
--- a/src/crash_handler.zig
+++ b/src/crash_handler.zig
@@ -474,9 +474,8 @@ fn testSignal(sig: std.posix.SIG, mode: SignalTestMode) !void {
return error.ForkFailed;
}
if (pid == 0) {
- // Keep a regression from hanging the runner or writing a large core.
- const limit: std.posix.rlimit = .{ .cur = 0, .max = 0 };
- _ = std.c.setrlimit(.CORE, &limit);
+ // Keep a regression from hanging the runner or writing a core.
+ _ = std.os.linux.prctl(@intFromEnum(std.os.linux.PR.SET_DUMPABLE), 0, 0, 0, 0);
const default: std.posix.Sigaction = .{ .handler = .{ .handler = std.posix.SIG.DFL }, .mask = std.posix.sigemptyset(), .flags = 0 };
std.posix.sigaction(.ALRM, &default, null);
std.posix.sigaction(.PIPE, &default, null);
diff --git a/src/testing.zig b/src/testing.zig
index 9dc0f0c42..4443489b7 100644
--- a/src/testing.zig
+++ b/src/testing.zig
@@ -465,7 +465,7 @@ fn runWebApiTest(test_file: [:0]const u8, timeout_ms: u32) !void {
return;
}
const sleep_ms: usize = switch (try runner.tickForFrame(page.frame_id, 20, .{ .until = .done })) {
- .done => 20,
+ .done => @min(test_session.browser.msToNextTask() orelse 20, 20), // could be at BLOCKING_NESTING, so wait a bit more
.ok => |next_ms| @min(next_ms, 20),
};
@@ -477,7 +477,14 @@ fn runWebApiTest(test_file: [:0]const u8, timeout_ms: u32) !void {
return error.TestTimedOut;
}
wait_ms -= @intCast(ms_elapsed);
- lp.io.sleep(.fromMilliseconds(@intCast(sleep_ms)), .awake) catch {};
+
+ // WebSocket connection doesn't count as pending work, but we much prefer
+ // waiting on on activity than a blind sleep.
+ const http_client = &test_session.browser.http_client;
+ const waited = http_client.activity().ws_conns > 0 and try http_client.tick(@intCast(sleep_ms));
+ if (waited == false) {
+ lp.io.sleep(.fromMilliseconds(@intCast(sleep_ms)), .awake) catch {};
+ }
}
}