diff --git a/Tests/LibWeb/test-web/main.cpp b/Tests/LibWeb/test-web/main.cpp index e43c2d5a356..379e5ee3da1 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(); }; }