mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 20:45:14 +00:00
UI/Headless: Wait for "reftest-wait" class removal before screenshotting
Resolves https://github.com/LadybirdBrowser/ladybird/issues/3984
This commit is contained in:
parent
394073f611
commit
259d39cbad
Notes:
github-actions[bot]
2025-03-18 19:10:48 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/259d39cbadd Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/3989 Reviewed-by: https://github.com/gmta ✅
1 changed files with 26 additions and 5 deletions
|
@ -286,6 +286,27 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t
|
|||
timer->start();
|
||||
}
|
||||
|
||||
static String wait_for_reftest_completion = R"(
|
||||
function hasReftestWaitClass() {
|
||||
return document.documentElement.classList.contains('reftest-wait');
|
||||
}
|
||||
|
||||
if (!hasReftestWaitClass()) {
|
||||
internals.signalTestIsDone("PASS");
|
||||
} else {
|
||||
const observer = new MutationObserver(() => {
|
||||
if (!hasReftestWaitClass()) {
|
||||
internals.signalTestIsDone("PASS");
|
||||
}
|
||||
});
|
||||
|
||||
observer.observe(document.documentElement, {
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
});
|
||||
}
|
||||
)"_string;
|
||||
|
||||
static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url, int timeout_in_milliseconds)
|
||||
{
|
||||
auto timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &test]() {
|
||||
|
@ -343,7 +364,11 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
|
|||
view.on_test_complete({ test, TestResult::Crashed });
|
||||
};
|
||||
|
||||
view.on_load_finish = [&view, &test, on_test_complete = move(on_test_complete)](auto const&) {
|
||||
view.on_load_finish = [&view](auto const&) {
|
||||
view.run_javascript(wait_for_reftest_completion);
|
||||
};
|
||||
|
||||
view.on_test_finish = [&view, &test, on_test_complete = move(on_test_complete)](auto const&) {
|
||||
if (test.actual_screenshot) {
|
||||
if (view.url().query().has_value() && view.url().query()->equals_ignoring_ascii_case("mismatch"sv)) {
|
||||
test.ref_test_expectation_type = RefTestExpectationType::Mismatch;
|
||||
|
@ -364,10 +389,6 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
|
|||
}
|
||||
};
|
||||
|
||||
view.on_test_finish = [&](auto const&) {
|
||||
dbgln("Unexpected text test finished during ref test for {}", url);
|
||||
};
|
||||
|
||||
view.on_set_test_timeout = [timer, timeout_in_milliseconds](double milliseconds) {
|
||||
if (milliseconds <= timeout_in_milliseconds)
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue