Every feature or bug fix merged into LibWeb should be accompanied by a test. Ladybird’s test suite lives in theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ladybirdBrowser/ladybird/llms.txt
Use this file to discover all available pages before exploring further.
Tests/ directory, with Tests/LibWeb/ dedicated to browser-engine tests. The suite supports four test types — Text,
Layout, Ref, and Screenshot — and integrates with the Web Platform Tests (WPT) project for broad standards coverage.
This page explains how to run the existing tests, how to write new ones, and how to reproduce CI failures locally.
Running Tests
Using ladybird.py (Recommended)
TheMeta/ladybird.py script is the easiest way to run tests:
Using ctest Directly
You can also drive the build and tests entirely through CMake presets:LADYBIRD_SOURCE_DIR environment variable to point to the root of the Ladybird source tree:
CTEST_OUTPUT_ON_FAILURE:
Running with Sanitizers
CI runs all host tests with Address Sanitizer (ASAN) and Undefined Behaviour Sanitizer (UBSAN) enabled. To reproduce
a CI failure locally, use the
Sanitizer preset and set the same environment variables that CI uses.ccache.
Web Platform Tests (WPT)
The WPT integration is driven by theMeta/WPT.sh script.
Importing WPT Tests
When your code changes cause Ladybird to pass WPT tests it previously failed, you can import those tests directly into the repository:http://wpt.live/ URL. The script downloads the test and its JavaScript dependencies,
copies them to Tests/LibWeb/<test-type>/input/wpt-import/, runs the test, and writes the expected output to
Tests/LibWeb/<test-type>/expected/wpt-import/.
Writing Tests
Creating Test Files
Use the helper script to generate a new test with correct boilerplate:test_type are Text, Layout, Ref, and Screenshot. The script creates:
- An input HTML file at
Tests/LibWeb/<test_type>/input/your-new-test-name.html - A corresponding expectations file in
Tests/LibWeb/<test_type>/expected/
Test Types
- Text
- Layout
- Ref
- Screenshot
Text tests exercise Web APIs that have no visual representation. They run in a headless browser and are written
in JavaScript. Each test calls
println() to emit output lines, which are accumulated and compared against a
saved expected-output file.Tests can be synchronous or asynchronous. Async tests use a done callback to signal completion; the test
function itself can be async if an async context is needed.Rebaselining
After updating a Text or Layout test, regenerate its expectations file:Create the test file
Run
./Tests/LibWeb/add_libweb_test.py your-test-name test_type to generate the boilerplate input and
expectations files.Write the test
Replace the generated boilerplate in
Tests/LibWeb/<test_type>/input/your-test-name.html with your actual test
logic.Regenerate expectations
For Text and Layout tests, rebaseline:
./Meta/ladybird.py run test-web --rebaseline -f <type>/input/your-test-name.html.For Ref tests, write the equivalent-rendering HTML reference page manually.For Screenshot tests, generate the reference PNG using headless mode (see above).