WebContent: Add "load-reference-page" debug request

This attempts to load the URL of the first `<link rel="match" href=""/>`
it finds. If that tag is missing, we load an error page to make sure
the ref-test fails. (And to provide some feedback if someone looks at
the screenshot somehow.) Wrong URLs will instead end up loading the
default 404 error page.
This commit is contained in:
Sam Atkins 2023-09-12 16:36:10 +01:00 committed by Andreas Kling
parent 7ba686dcb3
commit f3add3dd72
Notes: sideshowbarker 2024-07-16 22:24:48 +09:00

View File

@ -459,6 +459,21 @@ void ConnectionFromClient::debug_request(DeprecatedString const& request, Deprec
document->window().local_storage().release_value_but_fixme_should_propagate_errors()->dump();
return;
}
if (request == "load-reference-page") {
if (auto* document = page().top_level_browsing_context().active_document()) {
auto maybe_link = document->query_selector("link[rel=match]"sv);
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("<h1>Failed to find &lt;link rel=&quot;match&quot; /&gt; in ref test page!</h1> Make sure you added it.", "about:blank"sv);
} else {
auto link = maybe_link.release_value();
auto url = document->parse_url(link->get_attribute(Web::HTML::AttributeNames::href));
load_url(url);
}
}
return;
}
}
void ConnectionFromClient::get_source()