Lightpanda: the headless browser designed for AI and automation
test: keep short timeouts off the success paths
Adrià Arrufatc69adc4d0d4d
diff --git a/src/browser/tools.zig b/src/browser/tools.zigindex 91ebfcf34..65016e236 100644--- a/src/browser/tools.zig+++ b/src/browser/tools.zig@@ -2927,14 +2927,19 @@ test "goto: a navigation stuck waiting for a connection is an error" {defer if (session.primaryPage()) |page| page.close();const aa = testing.arena_allocator;- const args = try std.json.parseFromSliceLeaky(std.json.Value, aa,+ const stuck = try std.json.parseFromSliceLeaky(std.json.Value, aa,\\{"url":"http://localhost:9582/src/browser/tests/mcp_actions.html","timeout":50}, .{});- try std.testing.expectError(error.NavigationTimeout, call(aa, session, ®istry, "goto", args, .{ .source = .user }));+ try std.testing.expectError(error.NavigationTimeout, call(aa, session, ®istry, "goto", stuck, .{ .source = .user }));for (held.items) |conn| network.releaseConnection(conn);held.clearRetainingCapacity();+ // Short timeouts are for the stuck case only: slow builds (tsan) need+ // longer than that to actually load the page.+ const args = try std.json.parseFromSliceLeaky(std.json.Value, aa,+ \\{"url":"http://localhost:9582/src/browser/tests/mcp_actions.html","timeout":5000}+ , .{});const r = try call(aa, session, ®istry, "goto", args, .{ .source = .user });try std.testing.expectEqualStrings("Navigated. HTTP 200 OK.", r.text);}diff --git a/src/server/Server.zig b/src/server/Server.zigindex afc6b42e4..377c59c4f 100644--- a/src/server/Server.zig+++ b/src/server/Server.zig@@ -2518,9 +2518,9 @@ test "server: HTTP execute script" {// a script that never completes is answered by the script timeout{- try testing.expectEqual("{\"value\":null}", responseBody(try sessionCommand(&c, "POST", &session_id, "/timeouts", "{\"script\":20}")));+ try testing.expectEqual("{\"value\":null}", responseBody(try sessionCommand(&c, "POST", &session_id, "/timeouts", "{\"script\":50}")));try testing.expectEqual(- "{\"value\":{\"script\":20,\"pageLoad\":300000,\"implicit\":0}}",+ "{\"value\":{\"script\":50,\"pageLoad\":300000,\"implicit\":0}}",responseBody(try sessionCommand(&c, "GET", &session_id, "/timeouts", "")),);@@ -2539,7 +2539,7 @@ test "server: HTTP execute script" {// release build segfaults on, but the debug allocator here does not// trap, so this covers the path rather than proving the invariant.// selenium/http/demo.js in ../demo is what actually catches it.- const late = try executeRaw(&c, &session_id, "async", "var cb = arguments[0]; setTimeout(function() { window.__late = true; cb('way late'); }, 60);", "[]");+ const late = try executeRaw(&c, &session_id, "async", "var cb = arguments[0]; setTimeout(function() { window.__late = true; cb('way late'); }, 150);", "[]");try testing.expect(std.mem.find(u8, late, "\"error\":\"script timeout\"") != null);// the assertion only means anything if the stale resolve actually ranvar ran = false;