Skip to content

Lightpanda: the headless browser designed for AI and automation

extend time abort timing for slow CI

Karl Seguincca1fc1736eb
diff --git a/src/browser/tests/net/fetch.html b/src/browser/tests/net/fetch.html
index bac718972..a39452611 100644
--- a/src/browser/tests/net/fetch.html
+++ b/src/browser/tests/net/fetch.html
@@ -328,11 +328,11 @@
}
}
- // /xhr/slow takes 100ms: the abort must not wait for it
+ // /xhr/hang takes 2s: the abort must not wait for it
const c1 = new AbortController();
setTimeout(() => c1.abort(), 10);
const start = Date.now();
- const inflight = await rejection(fetch('http://127.0.0.1:9582/xhr/slow', { signal: c1.signal }));
+ const inflight = await rejection(fetch('http://127.0.0.1:9582/xhr/hang', { signal: c1.signal }));
const elapsed = Date.now() - start;
const c2 = new AbortController();
@@ -372,7 +372,7 @@
state.resolve();
await state.done(() => {
testing.expectEqual('AbortError', inflight.name);
- testing.expectTrue(elapsed < 100, 'abort waited for the response: ' + elapsed);
+ testing.expectTrue(elapsed < 1000, 'abort waited for the response: ' + elapsed);
testing.expectEqual(custom, custom_reason);
testing.expectEqual('TimeoutError', timeout.name);
testing.expectEqual('any', any);
diff --git a/src/testing.zig b/src/testing.zig
index 6554b9933..b48c4e68e 100644
--- a/src/testing.zig
+++ b/src/testing.zig
@@ -720,6 +720,16 @@ fn testHTTPHandler(req: *std.http.Server.Request) !void {
});
}
+ if (std.mem.eql(u8, path, "/xhr/hang")) {
+ // For asserting a request didn't wait for its response
+ lp.io.sleep(.fromMilliseconds(2000), .awake) catch {};
+ return req.respond("hang", .{
+ .extra_headers = &.{
+ .{ .name = "Content-Type", .value = "text/plain" },
+ },
+ });
+ }
+
if (std.mem.eql(u8, path, "/xhr_empty")) {
return req.respond("", .{
.extra_headers = &.{