Skip to content

Lightpanda: the headless browser designed for AI and automation

test: trim CPU-heavy tests without losing coverage

Adrià Arrufat1c34b3c32505
diff --git a/src/browser/tests/xpath/xpath_evaluator.html b/src/browser/tests/xpath/xpath_evaluator.html
index d18d83d68..c045058bb 100644
--- a/src/browser/tests/xpath/xpath_evaluator.html
+++ b/src/browser/tests/xpath/xpath_evaluator.html
@@ -104,8 +104,9 @@
<script id=deep_nesting>
{
- // The descendant, following and preceding axes used to recurse per level.
- const depth = 100000;
+ // The descendant, following and preceding axes used to recurse per level,
+ // which overflowed an 8MB stack at a depth of about 35000 in debug builds.
+ const depth = 50000;
// Built bottom-up: appending under a deep parent walks its ancestors.
const chain = (prefix) => {
let top = document.createElement('div');
diff --git a/src/browser/webapi/IntersectionObserver.zig b/src/browser/webapi/IntersectionObserver.zig
index 4907702bb..8d08af8f4 100644
--- a/src/browser/webapi/IntersectionObserver.zig
+++ b/src/browser/webapi/IntersectionObserver.zig
@@ -426,7 +426,8 @@ const testing = @import("../../testing.zig");
// observer stays registered on the frame for as long as it is alive. `deferred`
// re-observes from a timer, one delivery per macrotask tick, the way a
// fetch-driven pager behaves; otherwise the chain never leaves the microtask
-// checkpoint.
+// checkpoint. New sentinels go first: an appended one would measure every
+// earlier sibling, making the chain quadratic.
fn observeSentinelChain(frame: *Frame, comptime deferred: bool) !void {
var ls: js.Local.Scope = undefined;
frame.js.localScope(&ls);
@@ -435,7 +436,7 @@ fn observeSentinelChain(frame: *Frame, comptime deferred: bool) !void {
try ls.local.eval(
\\(function(deferred) {
\\ const list = document.createElement('div');
- \\ const observe = () => io.observe(list.appendChild(document.createElement('div')));
+ \\ const observe = () => io.observe(list.insertBefore(document.createElement('div'), list.firstChild));
\\ const io = new IntersectionObserver((entries) => {
\\ for (const entry of entries) {
\\ if (!entry.isIntersecting) continue;
diff --git a/src/browser/webapi/cdata/Comment.zig b/src/browser/webapi/cdata/Comment.zig
index 703c15c4a..7d687147c 100644
--- a/src/browser/webapi/cdata/Comment.zig
+++ b/src/browser/webapi/cdata/Comment.zig
@@ -46,8 +46,3 @@ pub const JsApi = struct {
pub const constructor = bridge.constructor(Comment.init, .{});
};
-
-const testing = @import("../../../testing.zig");
-test "WebApi: CData.Text" {
- try testing.htmlRunner("cdata/comment.html", .{});
-}
diff --git a/src/network/header_parser.zig b/src/network/header_parser.zig
index fa5441d78..597293082 100644
--- a/src/network/header_parser.zig
+++ b/src/network/header_parser.zig
@@ -886,9 +886,11 @@ fn expectMatchesReference(bytes: []const u8) !void {
test "header_parser: match functions against scalar reference" {
// Exhaustive: place every possible byte at every position of an otherwise
- // valid buffer, across lengths covering the vector, SWAR and scalar paths.
+ // valid buffer. The lengths straddle each boundary of the 16/32-byte
+ // vector, 8-byte SWAR and scalar paths.
+ const lengths = [_]usize{ 1, 7, 8, 9, 15, 16, 17, 31, 32, 33, 39, 40, 41, 47, 48 };
var buf: [48]u8 = undefined;
- for (1..buf.len + 1) |len| {
+ for (lengths) |len| {
for (0..len) |pos| {
for (0..256) |c| {
@memset(buf[0..len], 'a');
@@ -901,7 +903,7 @@ test "header_parser: match functions against scalar reference" {
// HTAB is the one valid byte below space; pair it with every byte at
// every position to prove it never disturbs its neighbor's verdict
// (a cross-lane borrow in the SWAR path would).
- for (2..buf.len + 1) |len| {
+ for (lengths[1..]) |len| {
for (0..len - 1) |pos| {
for (0..256) |c| {
@memset(buf[0..len], 'a');