mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-22 01:08:56 +00:00
test-web: Wait for crash tests with a test-wait
attribute
Similar to ref tests, we don't want to incorrectly pass a test that did not remove this attribute.
This commit is contained in:
parent
467c58eaf3
commit
98c7a011d4
Notes:
github-actions[bot]
2025-09-10 15:39:28 +00:00
Author: https://github.com/trflynn89
Commit: 98c7a011d4
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6148
Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 36 additions and 36 deletions
|
@ -159,6 +159,40 @@ static void clear_test_callbacks(TestWebView& view)
|
|||
view.on_web_content_crashed = {};
|
||||
}
|
||||
|
||||
static String generate_wait_for_test_string(StringView wait_class)
|
||||
{
|
||||
return MUST(String::formatted(R"(
|
||||
function hasTestWaitClass() {{
|
||||
return document.documentElement.classList.contains('{}');
|
||||
}}
|
||||
|
||||
if (!hasTestWaitClass()) {{
|
||||
document.fonts.ready.then(() => {{
|
||||
requestAnimationFrame(function() {{
|
||||
requestAnimationFrame(function() {{
|
||||
internals.signalTestIsDone("PASS");
|
||||
}});
|
||||
}});
|
||||
}});
|
||||
}} else {{
|
||||
const observer = new MutationObserver(() => {{
|
||||
if (!hasTestWaitClass()) {{
|
||||
internals.signalTestIsDone("PASS");
|
||||
}}
|
||||
}});
|
||||
|
||||
observer.observe(document.documentElement, {{
|
||||
attributes: true,
|
||||
attributeFilter: ['class'],
|
||||
}});
|
||||
}}
|
||||
)"sv,
|
||||
wait_class));
|
||||
}
|
||||
|
||||
static auto wait_for_crash_test_completion = generate_wait_for_test_string("test-wait"sv);
|
||||
static auto wait_for_reftest_completion = generate_wait_for_test_string("reftest-wait"sv);
|
||||
|
||||
static void run_dump_test(TestWebView& view, Test& test, URL::URL const& url, int timeout_in_milliseconds)
|
||||
{
|
||||
auto timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &test]() {
|
||||
|
@ -292,17 +326,10 @@ static void run_dump_test(TestWebView& view, Test& test, URL::URL const& url, in
|
|||
// 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;
|
||||
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();
|
||||
};
|
||||
|
@ -330,33 +357,6 @@ static void run_dump_test(TestWebView& view, Test& test, URL::URL const& url, in
|
|||
timer->start();
|
||||
}
|
||||
|
||||
static String wait_for_reftest_completion = R"(
|
||||
function hasReftestWaitClass() {
|
||||
return document.documentElement.classList.contains('reftest-wait');
|
||||
}
|
||||
|
||||
if (!hasReftestWaitClass()) {
|
||||
document.fonts.ready.then(() => {
|
||||
requestAnimationFrame(function() {
|
||||
requestAnimationFrame(function() {
|
||||
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(TestWebView& view, Test& test, URL::URL const& url, int timeout_in_milliseconds)
|
||||
{
|
||||
auto timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &test]() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue