From e1f0284fbac2683c53c77d745f70c250a3cc485c Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Mon, 14 Jul 2025 12:35:11 +0100 Subject: [PATCH] test-web: Wait longer before completing crash tests Previously, a lot of imported WPT crash tests wouldn't wait long enough for a crash to occur. --- Tests/LibWeb/test-web/main.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/Tests/LibWeb/test-web/main.cpp b/Tests/LibWeb/test-web/main.cpp index e43c2d5a35..379e5ee3da 100644 --- a/Tests/LibWeb/test-web/main.cpp +++ b/Tests/LibWeb/test-web/main.cpp @@ -285,11 +285,30 @@ static void run_dump_test(TestWebView& view, Test& test, URL::URL const& url, in on_test_complete(); }; } else if (test.mode == TestMode::Crash) { - view.on_load_finish = [on_test_complete = move(on_test_complete), url](auto const& loaded_url) { + view.on_load_finish = [on_test_complete, url, &view, &test](auto const& loaded_url) { // We don't want subframe loads to trigger the test finish. if (!url.equals(loaded_url, URL::ExcludeFragment::Yes)) return; - on_test_complete(); + test.did_finish_loading = true; + static String wait_for_crash_test_completion = R"( + document.fonts.ready.then(() => { + requestAnimationFrame(function() { + requestAnimationFrame(function() { + internals.signalTestIsDone("PASS"); + }); + }); + }); +)"_string; + view.run_javascript(wait_for_crash_test_completion); + if (test.did_finish_test) + on_test_complete(); + }; + + view.on_test_finish = [&test, on_test_complete](auto const&) { + test.did_finish_test = true; + + if (test.did_finish_loading) + on_test_complete(); }; }