Commit graph

101 commits

Author SHA1 Message Date
Tim Ledbetter
a9261b9daf test-web: Don't include skipped tests in --dry-run output 2026-06-19 09:47:55 +02:00
Shannon Booth
a8cb98ccf7 Tests: Support WPT reftests with multiple references
Store reftest expectations as a list of match/mismatch reference URLs
and evaluate each reference in sequence.

This lets test-web run WPT reftests that specify multiple reference
relations, such as tests with both match and mismatch links.
2026-06-14 22:12:00 +02:00
Andreas Kling
0aaae1ac76 Tests/LibWeb: Cover UI-owned session history
Teach test-web to expose the UI-process history dump. Add focused
navigation tests for same-document traversal, fallback traversal, and
cross-document browser back and forward behavior. The expectations
assert document state and the UI-owned history snapshot.
2026-06-14 17:38:44 +02:00
Sam Atkins
dbe2ba74d7 test-web: Move test-collection code into its own files
No behaviour changes.
2026-06-10 13:40:42 +01:00
Sam Atkins
85d401d1f9 test-web: Move test-variant handling code into its own files
No behaviour changes.
2026-06-10 13:40:42 +01:00
Sam Atkins
10bca58c3d test-web: Stop runtime WPT variant discovery
After the previous commit, variant tests are already expanded out during
collection, so we no longer need to ask running tests if they have
variants.
2026-06-09 16:48:33 +02:00
Sam Atkins
69b457c993 test-web: Expand WPT variants before running tests
Scan sources of Text tests during collection to identify test variants,
using a very basic HTML parser. All tests with variants use the same
pattern for their meta tags, so even this is overkill for what we need,
but it should work for any future tests that happen to be arranged a
little differently.
2026-06-09 16:48:33 +02:00
Sam Atkins
3a5767809a test-web: Share variant path construction code 2026-06-09 16:48:33 +02:00
Shannon Booth
472b0a3baa Tests/LibWeb: Use unique localhost hosts for echo-served tests
Load tests that require the echo server through a per-test
*.localhost hostname instead of plain localhost. This prevents shared
per-host browser state, from leaking between parallel or repeated test
runs.

Update HTTPTestServer to create echo URLs on the current origin when a
test is already loaded from the echo server, preserving same-origin
behavior for tests that inspect echo-served iframes.
2026-06-06 13:48:43 +02:00
InvalidUsernameException
2635c334b0 test-web: Exit more gracefully if --test-path is not provided 2026-06-04 17:52:59 +02:00
InvalidUsernameException
8e21673577 test-web: Do not crash test runner on missing ref-test expectation file
Individual tests should not be able to crash the runner. Instead simply
fail the test in question.
2026-06-04 17:52:59 +02:00
sideshowbarker
ae2783e705 Tests: Stop dropping post-navigation load events in Text-mode tests
Problem: Text-mode tests that perform a top-level cross-document
navigation can hang forever — even when the target page reports PASS.
For example, the connect-src test in Tests/LibWeb/Text/input/navigation/
has been intermittently timing out on CI for months, and has its own
in-test workaround. But that’s a mitigation that just narrows the race.

Cause: The Text-mode on_load_finish handler in test-web/main.cpp filters
by URL and bails out if the loaded URL doesn’t match the test’s original
URL — to ignore subframe loads. But page_did_finish_loading is already
gated on navigable->is_traversable(). So, it’s top-level-only — and the
URL filter is actually rejecting load events from top-level navigations
away from the original test URL.

When the original page’s did_finish_loading IPC hasn’t reached test-web
by the time the navigation target loads and signals PASS, the target’s
did_finish_loading is the only surviving load notification — and the URL
filter masks it. So, did_finish_loading is never set test-side. And so
the test-finish handler then bails on the did_finish_loading &&
did_check_variants check — and the test hangs.

Fix: Drop the URL filter from the Text-mode on_load_finish handler. Any
top-level load (the original page, or any subsequent navigation) now
sets did_finish_loading. The variant-loading logic is unchanged: The
second variant-check just no-ops — because test.variant is already set
from the first response.
2026-05-30 11:20:01 +02:00
Andreas Kling
faf7e4c720 Tests: Support platform screenshot expectations
Look for screenshot expectations in an expected-<platform>
directory before using the shared expected directory. This lets tests
that cover system-derived rendering keep platform-specific baselines
without making other platforms use the same PNG.
2026-05-29 13:49:51 +02:00
Andreas Kling
a289601eb0 LibWeb: Expose content blocker test controls
Add internals helpers so text tests can install local blocker rules and
toggle content blocking without browser-process IPC. Clear installed
rules after each non-crashed test-web case so blocker state cannot leak
into the next test.
2026-05-21 21:16:56 +02:00
Andreas Kling
46e1a08742 LibWeb: Rename ContentFilter to ContentBlocker
Rename the local content blocking implementation and its tests from
ContentFilter to ContentBlocker while keeping the existing substring
matcher backend and behavior.

Update the WebContent IPC method, WebView option names, debug toggle,
and default config file name to use content blocker terminology.
2026-05-21 21:16:56 +02:00
Andreas Kling
ac8887e34d Tests: Preserve LibWeb harness diagnostics on early exits
Keep a small harness-status.txt file in the test-web results
directory and refresh it whenever tests start, finish, or the run stops
early. This leaves the last known active views, counts, and remaining
test count behind even if the harness does not reach its normal result
generation path.

Also report helper-process log write failures instead of treating them
as "no logs". That makes artifact gaps visible instead of silently
losing the only clue from a helper process failure.
2026-05-13 13:32:49 +02:00
Andreas Kling
b71d82645b test-web: Log why the test runner exits early
Log active views and tests when test-web stops before all tests have
completed. Reuse the same reporting for signal handling, and accept any
future signal registration without asserting while explaining shutdown.

Also log observed helper process exits with decoded Unix wait status so
CI logs show whether a process exited normally or died from a signal.
2026-05-12 20:57:08 +02:00
Andreas Kling
191bd46cb8 LibWeb: Add compositor scroll state snapshots
Record the scroll geometry that CompositorThread can safely reason about
while the main thread is painting. The snapshot contains stable scroll
node IDs, parent links, scroll bounds, sticky inputs, and wheel blocker
regions in display-list coordinate space.

Add AsyncScrollingState and AsyncScrollTree under LibWeb/Compositor. The
state is the immutable main-thread snapshot; the tree is the mutable
compositor-side copy that can replay scroll deltas and sticky offsets
without touching DOM, layout, or paintables.

Expose the state through internals and add text tests for tree shape,
parent links, sticky areas, blocker hit testing, nested scrollers, and
admission decisions. Keep the directory skipped unless the feature is
enabled with --enable-async-scrolling.
2026-05-12 20:57:08 +02:00
Tim Ledbetter
b116e42f3c test-web: Wait for PDF.js layers to render before signalling completion
Previously, we signalled completion of a PDF test once the
`pagesloaded` event fired. This fires once page metadata is initialized
but the text and annotation layers are rendered asynchronously after
that. We now wait for the text and annotation layers of the first page
to render. The test runner will currently fail for PDFs with more than
one page bceause pages are loaded lazily once they are visible and
there's no guarantee that anything beyond the first page will be loaded.
2026-05-07 11:23:46 +02:00
Johan Dahlin
f7499105dd LibWeb: Implement inline PDF viewing using the bundled pdf.js viewer 2026-04-30 07:46:12 +02:00
Jelle Raaijmakers
d8ad66d95d Tests/LibWeb: Dispatch TestRendered event when reftest-wait is present
This furthers our compatibility with WPT tests.
2026-04-29 20:28:15 +02:00
Ali Mohammad Pur
909013b972 LibWeb+LibTest: Move the progress bar/status printing stuff to LibTest 2026-04-23 18:48:56 +02:00
Tim Ledbetter
6f3833e857 test-web: Inject JS wait script into layout tests
This script waits until fonts have loaded and waits for 2 animation
frames before signalling test completion. This is the same mechanism
already used for ref and crash tests.
2026-04-22 15:35:07 +01:00
Jonathan Gamble
3ca76a42ec test-web: Break live display and terminal code out of main.cpp 2026-04-20 20:26:40 +02:00
Jonathan Gamble
e8ca424b13 test-web: Compensate live display for short terminals 2026-04-20 20:26:40 +02:00
Jonathan Gamble
7279917b5b test-web: Remove deferred warnings
Deferred warnings were originally  intended to suppress output during
live display, ostensibly to avoid glitch scrolls.

Then, 1af74d1a7c added log capture to the
test-web process. Suddenly, deferred warnings became deadly because
they're flushed during a tiny window after the capture notifier has
stopped draining the tee pipe but before stderr is restored.

This caused a deadlock at exit. The fix is to remove this system and
call warnln directly because display integrity is now protected by
other means.
2026-04-20 20:26:40 +02:00
Jonathan Gamble
778402640a test-web: Add run date and "copy run command" button to results header 2026-04-15 17:09:50 +02:00
Jonathan Gamble
1af74d1a7c test-web: Capture all browser and helper process output
This prevents glitches where stale test status lines can bleed above
the live display list. Log this additional captured output so it can
be reviewed if a main or helper process failure is suspected.
2026-04-15 17:09:50 +02:00
Jonathan Gamble
be7266326c test-web: Consolidate output capture handling
Use files instead of buffers. Consolidate stderr and stdout into one
view. Break handling out into TestRunCapture and CaptureFile helper
classes. We will use them to log output from ALL processes in the next
commit.
2026-04-15 17:09:50 +02:00
Jonathan Gamble
8b550f2a8b test-web: Remove --debug-timeouts
It's almost 100% useless in practice and not worth the noise.
2026-04-15 17:09:50 +02:00
Aliaksandr Kalenik
700026637d test-web: Add quiet mode for AI agent environments
When test-web runs inside Claude Code or Codex, per-test progress lines
are suppressed. These environments are non-interactive and the per-test
output (potentially thousands of lines) wastes the agent's context
window without adding value. The agent only needs the pass/fail summary
to decide next steps.

Quiet mode preserves: the "Running N tests..." line, the summary table,
non-passing test names, and the results URL.
2026-04-01 11:51:59 +02:00
Sam Atkins
cce85705f6 test-web: Prevent ref tests from injecting JS multiple times
This is a little more complicated than screenshot tests, because we deal
with two separate page loads, for the test and expectation pages. When
loading the expectation page, we clear the did_inject_js flag and also
store the URL so that we can compare that later.
2026-03-31 19:29:43 +01:00
Sam Atkins
84e72243d4 test-web: Prevent screenshot tests from injecting JS multiple times
Keep track of whether we've injected the JS, and avoid doing so again.

Also skip this entirely unless we're actually dealing with the test's
URL and not a subframe. This check is already done on dump tests.
2026-03-31 04:55:21 +01:00
Sam Atkins
fff3d76e55 test-web: Disconnect test-wait MutationObserver after firing
The MutationObserver was not disconnected after firing, so any other
modifications to the document's class attribute after that point would
signal the test completing again. This is unlikely to happen in
practice as we shouldn't be running any JS after completing a test, but
it's harmless to disconnect it.
2026-03-31 04:55:21 +01:00
Jelle Raaijmakers
e817b13c2a Tests/LibWeb: Centralize on_set_test_timeout logic
We don't need three copies of this.
2026-03-20 10:47:39 +01:00
Jelle Raaijmakers
fe5ffbce53 Tests/LibWeb: Centralize timeout logic and include about:blank load
We had three separate timeout timer sites in `test-web`, which are now
deduplicated into a single one. This single timeout timer is started
_before_ we start loading `about:blank`, which potentially catches more
timeouts when a WebContent process is left in a broken state by a
previous test.
2026-03-20 10:47:39 +01:00
Sam Atkins
898a69ba74 test-web: Clarify error when TestConfig.ini has a wrong test path
Previously, if you had a mistake in a test path, you'd get an unhelpful
error like this when running test-web:

> Runtime error: realpath: No such file or directory (errno=2)

This is quite confusing if other changes have been made, as the error
could have happened anywhere.

With this change, the same mistake now is first reported as:

> Unable to get real path for TestConfig.ini entry
> '/home/sam/ladybird/Tests/LibWeb/FLORB.html': realpath: No such file
> or directory (errno=2)

Then followed by the original error reported by LibMain. This makes it
immediately obvious what the issue is, and hopefully will save anyone
else going on a wild goose chase trying to find a build issue that isn't
there. 😅
2026-03-09 17:40:29 +01:00
Zaggy1024
856174b60e test-web: Allow TestConfig.ini to refer to entire directories
When a path in TestConfig.ini ends in a /, treat it as a directory and
recursively enumerate all tests within it to the requisite collection
of paths.

We can immediately use this to drop a bunch of lines from the config
that specify individual IndexedDB tests should use the HTTP server.
2026-03-05 17:12:55 -06:00
Zaggy1024
d77a0a2daf test-web: Convert ANSI control codes to HTML styling in dumped output
Instead of stripping all the control codes, let's use them to make our
test dumps more readable. :^)
2026-02-28 11:19:19 -06:00
Jelle Raaijmakers
a40a34f59a Tests/LibWeb: Run optipng after rebaselining screenshot tests 2026-02-28 10:16:13 +00:00
Zaggy1024
0b8650bff8 test-web: Actually create directories for test dumps
Regressed by 5911e8a527
2026-02-26 19:55:26 -06:00
Jonathan Gamble
472d6d4805 LibWeb+test-web: Add --fail-fast option
Offer to attach debugger if it's a timeout.
2026-02-25 12:33:35 -06:00
Jonathan Gamble
4cafb9b8bc LibWeb+test-web: Add --debug-timeouts option to capture backtraces 2026-02-25 12:33:35 -06:00
Jonathan Gamble
5911e8a527 LibWeb+test-web: Add --repeat flag
If provided, test-web batches & results will be partitioned in
multiple runs. Each run will execute the same set of tests, and
non-pass results will be stored in run1, run2, run6, etc directories.
2026-02-25 12:33:35 -06:00
Jonathan Gamble
e239ac88d9 LibWeb+test-web: Strip terminal escape codes from captured stderr 2026-02-25 12:33:35 -06:00
Zaggy1024
dc95107eb6 test-web: Use the output StringBuilder to measure the counter length
Formatting the counter into a separate string is an unnecessary
allocation.
2026-02-24 16:00:25 -06:00
Aliaksandr Kalenik
0c570dc6ed LibWeb: Only rebaseline screenshot tests when actual output differs
Previously, --rebaseline would unconditionally overwrite expected PNGs
before comparing, causing every screenshot test expectation to be
regenerated even when the actual screenshot already matched. Restructure
to load and compare first, only writing the new expectation on mismatch
or when the expected file doesn't exist yet.
2026-02-24 13:57:54 +01:00
Aliaksandr Kalenik
d2528dd5ce LibWeb: Compare Screenshot tests directly against expected PNGs
Instead of rendering a reference HTML page that wraps an <img> tag
pointing to a PNG, Screenshot tests now load the expected PNG directly
from disk and compare it against the rendered screenshot. This
eliminates the indirection of loading and rendering a second page just
to display a static image.

This also means --rebaseline now works for Screenshot tests, generating
the expected PNG automatically instead of requiring manual screenshot
capture and placement.

Changes:
- Add TestMode::Screenshot with its own collector and runner
- Move PNGs from Screenshot/images/ to Screenshot/expected/ with
  normalized names matching input filenames
- Remove all 92 reference HTML wrapper files and the images/
  directory
- Remove <link rel="match"> from all 94 Screenshot input HTML
  files
- Update add_libweb_test.py Screenshot boilerplate accordingly
- Add Screenshot mode to results viewer image comparison tabs
2026-02-24 09:55:14 +01:00
Luke Wilde
6491c6bb90 test-web: Reset viewport size after each test 2026-02-23 18:44:26 +00:00
Luke Wilde
66d5bff914 test-web: Skip invalid test names in Ref tests 2026-02-23 18:44:26 +00:00