mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-28 02:27:19 +02:00
Add support for WPT test variants, which allow a single test file to be run multiple times with different URL query parameters. Tests declare variants using `<meta name="variant" content="?param=value">` tags. When test-web encounters a test with variants, it expands that test into multiple runs, each with its own expectation file using the naming convention `testname@variant.txt` (e.g., `test@run_type=uri.txt`). Implementation details: - WebContent observes variant meta tags and communicates them to the test runner via a new `did_receive_test_variant_metadata` IPC call - test-web dynamically expands tests with variants during execution, waking idle views after each test completion to pick up new work - Use index-based test tracking to avoid dangling references when the test vector grows during variant expansion - Introduce TestRunContext to group test run state, and store a static pointer to it for signal handler access This enables proper testing of WPT tests that use variants, such as the html5lib parsing tests (which test uri, write, and write_single modes) and the editing/bold tests (which split across multiple ranges).
83 lines
1.6 KiB
C++
83 lines
1.6 KiB
C++
/*
|
|
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
|
* Copyright (c) 2025, Jelle Raaijmakers <jelle@ladybird.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "Fuzzy.h"
|
|
|
|
#include <AK/ByteString.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <AK/String.h>
|
|
#include <AK/Time.h>
|
|
#include <AK/Vector.h>
|
|
#include <LibCore/Forward.h>
|
|
#include <LibCore/Promise.h>
|
|
#include <LibGfx/Forward.h>
|
|
|
|
namespace TestWeb {
|
|
|
|
enum class TestMode {
|
|
Layout,
|
|
Text,
|
|
Ref,
|
|
Crash,
|
|
};
|
|
|
|
enum class TestResult {
|
|
Pass,
|
|
Fail,
|
|
Skipped,
|
|
Timeout,
|
|
Crashed,
|
|
Expanded,
|
|
};
|
|
|
|
enum class RefTestExpectationType {
|
|
Match,
|
|
Mismatch,
|
|
};
|
|
|
|
struct Test {
|
|
TestMode mode;
|
|
|
|
ByteString input_path {};
|
|
ByteString expectation_path {};
|
|
ByteString relative_path {};
|
|
ByteString safe_relative_path {};
|
|
Optional<String> variant {};
|
|
|
|
UnixDateTime start_time {};
|
|
UnixDateTime end_time {};
|
|
size_t index { 0 };
|
|
|
|
String text {};
|
|
bool did_finish_test { false };
|
|
bool did_finish_loading { false };
|
|
bool did_check_variants { false };
|
|
|
|
Optional<RefTestExpectationType> ref_test_expectation_type {};
|
|
Vector<FuzzyMatch> fuzzy_matches {};
|
|
|
|
RefPtr<Gfx::Bitmap const> actual_screenshot {};
|
|
RefPtr<Gfx::Bitmap const> expectation_screenshot {};
|
|
|
|
RefPtr<Core::Timer> timeout_timer {};
|
|
};
|
|
|
|
struct TestCompletion {
|
|
size_t test_index;
|
|
TestResult result;
|
|
};
|
|
|
|
using TestPromise = Core::Promise<TestCompletion>;
|
|
|
|
// Deferred warning system - buffers warnings during live display mode
|
|
void add_deferred_warning(ByteString message);
|
|
void print_deferred_warnings();
|
|
|
|
}
|