mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
Tests: Replace load-reference-page debug action with internals method
WPT reference tests can add metadata to tests to instruct the test runner how to interpret the results. Because of this, it is not enough to have an action that starts loading the (mis)match reference: we need the test runner to receive the metadata so it can act accordingly. This sets our test runner up for potentially supporting multiple (mis)match references, and fuzzy rendering matches - the latter will be implemented in the following commit.
This commit is contained in:
parent
0f642ecb5c
commit
e4b2253b63
Notes:
github-actions[bot]
2025-07-17 12:00:33 +00:00
Author: https://github.com/gmta
Commit: e4b2253b63
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5470
Reviewed-by: https://github.com/tcl3 ✅
12 changed files with 87 additions and 44 deletions
|
|
@ -398,43 +398,6 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt
|
|||
return;
|
||||
}
|
||||
|
||||
if (request == "load-reference-page") {
|
||||
if (auto* document = page->page().top_level_browsing_context().active_document()) {
|
||||
auto has_mismatch_selector = false;
|
||||
|
||||
auto maybe_link = [&]() -> Web::WebIDL::ExceptionOr<GC::Ptr<Web::DOM::Element>> {
|
||||
auto maybe_link = document->query_selector("link[rel=match]"sv);
|
||||
if (maybe_link.is_error() || maybe_link.value())
|
||||
return maybe_link;
|
||||
|
||||
auto maybe_mismatch_link = document->query_selector("link[rel=mismatch]"sv);
|
||||
if (maybe_mismatch_link.is_error() || maybe_mismatch_link.value()) {
|
||||
has_mismatch_selector = maybe_mismatch_link.value();
|
||||
return maybe_mismatch_link;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}();
|
||||
|
||||
if (maybe_link.is_error() || !maybe_link.value()) {
|
||||
// To make sure that we fail the ref-test if the link is missing, load the error page->
|
||||
load_html(page_id, "<h1>Failed to find <link rel="match" /> or <link rel="mismatch" /> in ref test page!</h1> Make sure you added it.");
|
||||
} else {
|
||||
auto link = maybe_link.release_value();
|
||||
auto url = document->encoding_parse_url(link->get_attribute_value(Web::HTML::AttributeNames::href));
|
||||
if (url->query().has_value() && !url->query()->is_empty()) {
|
||||
load_html(page_id, "<h1>Invalid ref test link - query string must be empty</h1>");
|
||||
return;
|
||||
}
|
||||
if (has_mismatch_selector)
|
||||
url->set_query("mismatch"_string);
|
||||
|
||||
load_url(page_id, *url);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (request == "navigator-compatibility-mode") {
|
||||
Web::NavigatorCompatibilityMode compatibility_mode;
|
||||
if (argument == "chrome") {
|
||||
|
|
|
|||
|
|
@ -333,6 +333,11 @@ void PageClient::page_did_set_test_timeout(double milliseconds)
|
|||
client().async_did_set_test_timeout(m_id, milliseconds);
|
||||
}
|
||||
|
||||
void PageClient::page_did_receive_reference_test_metadata(JsonValue metadata)
|
||||
{
|
||||
client().async_did_receive_reference_test_metadata(m_id, metadata);
|
||||
}
|
||||
|
||||
void PageClient::page_did_set_browser_zoom(double factor)
|
||||
{
|
||||
auto traversable = page().top_level_traversable();
|
||||
|
|
|
|||
|
|
@ -164,6 +164,7 @@ private:
|
|||
virtual void page_did_request_select_dropdown(Web::CSSPixelPoint content_position, Web::CSSPixels minimum_width, Vector<Web::HTML::SelectItem> items) override;
|
||||
virtual void page_did_finish_test(String const& text) override;
|
||||
virtual void page_did_set_test_timeout(double milliseconds) override;
|
||||
virtual void page_did_receive_reference_test_metadata(JsonValue) override;
|
||||
virtual void page_did_set_browser_zoom(double factor) override;
|
||||
virtual void page_did_change_theme_color(Gfx::Color color) override;
|
||||
virtual void page_did_insert_clipboard_entry(Web::Clipboard::SystemClipboardRepresentation const&, StringView presentation_style) override;
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ endpoint WebContentClient
|
|||
|
||||
did_finish_test(u64 page_id, String text) =|
|
||||
did_set_test_timeout(u64 page_id, double milliseconds) =|
|
||||
did_receive_reference_test_metadata(u64 page_id, JsonValue result) =|
|
||||
|
||||
did_set_browser_zoom(u64 page_id, double factor) =|
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue