mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-09 19:16:02 +00:00
LibWeb: Implement AbortSignal.timeout()
This method returns a signal that will automatically abort after a given number of milliseconds.
This commit is contained in:
parent
3c288c96e6
commit
ae42c6ed80
Notes:
sideshowbarker
2024-07-16 20:21:48 +09:00
Author: https://github.com/tcl3
Commit: ae42c6ed80
Pull-request: https://github.com/SerenityOS/serenity/pull/23354
Reviewed-by: https://github.com/trflynn89
5 changed files with 48 additions and 1 deletions
15
Tests/LibWeb/Text/input/abortsignal-timeout.html
Normal file
15
Tests/LibWeb/Text/input/abortsignal-timeout.html
Normal file
|
@ -0,0 +1,15 @@
|
|||
<script src="include.js"></script>
|
||||
<script>
|
||||
asyncTest(done => {
|
||||
const timeout_milliseconds = 10;
|
||||
const test_start_time = performance.now();
|
||||
const signal = AbortSignal.timeout(timeout_milliseconds);
|
||||
signal.onabort = () => {
|
||||
const abort_event_time = performance.now();
|
||||
const time_taken_milliseconds = abort_event_time - test_start_time;
|
||||
println(`Time passed before abort event fired is at least ${timeout_milliseconds} milliseconds: ${time_taken_milliseconds >= timeout_milliseconds}`);
|
||||
println(`Reason type: ${signal.reason.name}`);
|
||||
done();
|
||||
};
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue