mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-05 09:06:08 +00:00
Tests: Implement fuzzy screenshot comparisons in test-web
We now read WPT's `<meta name="fuzzy">` tags if present in tests and apply them while comparing screenshots.
This commit is contained in:
parent
e4b2253b63
commit
0d856a8fa7
Notes:
github-actions[bot]
2025-07-17 12:00:27 +00:00
Author: https://github.com/gmta
Commit: 0d856a8fa7
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5470
Reviewed-by: https://github.com/tcl3 ✅
13 changed files with 260 additions and 3 deletions
|
@ -81,6 +81,26 @@ WebIDL::ExceptionOr<void> Internals::load_reference_test_metadata()
|
|||
metadata.set("match_references"sv, TRY(collect_references("match"sv)));
|
||||
metadata.set("mismatch_references"sv, TRY(collect_references("mismatch"sv)));
|
||||
|
||||
// Collect all <meta name="fuzzy" content=".."> values.
|
||||
JsonArray fuzzy_configurations;
|
||||
auto fuzzy_nodes = TRY(document->query_selector_all("meta[name=fuzzy]"sv));
|
||||
for (size_t i = 0; i < fuzzy_nodes->length(); ++i) {
|
||||
auto const* fuzzy_node = fuzzy_nodes->item(i);
|
||||
auto content = as<DOM::Element>(fuzzy_node)->get_attribute_value(HTML::AttributeNames::content);
|
||||
|
||||
JsonObject fuzzy_configuration;
|
||||
if (content.contains(':')) {
|
||||
auto content_parts = MUST(content.split_limit(':', 2));
|
||||
auto reference_url = document->encoding_parse_url(content_parts[0]);
|
||||
fuzzy_configuration.set("reference"sv, reference_url->to_string());
|
||||
content = content_parts[1];
|
||||
}
|
||||
fuzzy_configuration.set("content"sv, content);
|
||||
|
||||
fuzzy_configurations.must_append(fuzzy_configuration);
|
||||
}
|
||||
metadata.set("fuzzy"sv, fuzzy_configurations);
|
||||
|
||||
page.client().page_did_receive_reference_test_metadata(metadata);
|
||||
return {};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue