diff --git a/UI/Headless/Test.cpp b/UI/Headless/Test.cpp index 18bef7dc361..81357f976df 100644 --- a/UI/Headless/Test.cpp +++ b/UI/Headless/Test.cpp @@ -146,10 +146,8 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t }); auto handle_completed_test = [&test, url]() -> ErrorOr { - if (test.expectation_path.is_empty()) { - outln("{}", test.text); + if (test.mode == TestMode::Crash) return TestResult::Pass; - } auto open_expectation_file = [&](auto mode) { auto expectation_file_or_error = Core::File::open(test.expectation_path, mode); @@ -234,24 +232,16 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t }); }); }; - } else if (test.mode == TestMode::Text || test.mode == TestMode::Crash) { - view.on_load_finish = [&view, &test, on_test_complete, url](auto const& loaded_url) { + } else if (test.mode == TestMode::Text) { + view.on_load_finish = [&test, on_test_complete, url](auto const& loaded_url) { // We don't want subframe loads to trigger the test finish. if (!url.equals(loaded_url, URL::ExcludeFragment::Yes)) return; test.did_finish_loading = true; - if (test.expectation_path.is_empty()) { - auto promise = view.request_internal_page_info(WebView::PageInfoType::Text); - - promise->when_resolved([&test, on_test_complete = move(on_test_complete)](auto const& text) { - test.text = text; - on_test_complete(); - }); - } else if (test.did_finish_test) { + if (test.did_finish_test) on_test_complete(); - } }; view.on_text_test_finish = [&test, on_test_complete](auto const& text) { @@ -261,6 +251,13 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t if (test.did_finish_loading) 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) { + // We don't want subframe loads to trigger the test finish. + if (!url.equals(loaded_url, URL::ExcludeFragment::Yes)) + return; + on_test_complete(); + }; } view.on_set_test_timeout = [timer, timeout_in_milliseconds](double milliseconds) { @@ -396,6 +393,7 @@ static void run_test(HeadlessWebView& view, Test& test, Application& app) auto url = URL::create_with_file_scheme(MUST(FileSystem::real_path(test.input_path))); switch (test.mode) { + case TestMode::Crash: case TestMode::Text: case TestMode::Layout: run_dump_test(view, test, url, app.per_test_timeout_in_seconds * 1000); @@ -403,9 +401,6 @@ static void run_test(HeadlessWebView& view, Test& test, Application& app) case TestMode::Ref: run_ref_test(view, test, url, app.per_test_timeout_in_seconds * 1000); return; - case TestMode::Crash: - run_dump_test(view, test, url, app.per_test_timeout_in_seconds * 1000); - return; } VERIFY_NOT_REACHED();