mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:17:34 +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
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