mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
headless-browser: Let tests set their own timeout duration
Some tests take longer than others, and so may want to set a custom timeout so that they pass, without increasing the timeout for all other tests. For example, this is done in WPT. Add an `internals.setTestTimeout(milliseconds)` method that overrides the test runner's default timeout for the currently-run test.
This commit is contained in:
parent
9164c9784d
commit
be6a9940ad
Notes:
github-actions[bot]
2024-12-19 17:28:47 +00:00
Author: https://github.com/AtkinsSJ
Commit: be6a9940ad
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2979
Reviewed-by: https://github.com/gmta ✅
11 changed files with 42 additions and 0 deletions
|
|
@ -112,6 +112,7 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t
|
|||
auto timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &test]() {
|
||||
view.on_load_finish = {};
|
||||
view.on_text_test_finish = {};
|
||||
view.on_set_test_timeout = {};
|
||||
|
||||
view.on_test_complete({ test, TestResult::Timeout });
|
||||
});
|
||||
|
|
@ -233,6 +234,13 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t
|
|||
};
|
||||
}
|
||||
|
||||
view.on_set_test_timeout = [timer, timeout_in_milliseconds](double milliseconds) {
|
||||
if (milliseconds <= timeout_in_milliseconds)
|
||||
return;
|
||||
timer->stop();
|
||||
timer->start(milliseconds);
|
||||
};
|
||||
|
||||
view.load(url);
|
||||
timer->start();
|
||||
}
|
||||
|
|
@ -242,6 +250,7 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
|
|||
auto timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &test]() {
|
||||
view.on_load_finish = {};
|
||||
view.on_text_test_finish = {};
|
||||
view.on_set_test_timeout = {};
|
||||
|
||||
view.on_test_complete({ test, TestResult::Timeout });
|
||||
});
|
||||
|
|
@ -315,6 +324,13 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
|
|||
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;
|
||||
timer->stop();
|
||||
timer->start(milliseconds);
|
||||
};
|
||||
|
||||
view.load(url);
|
||||
timer->start();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue