mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-03-29 08:00:05 +00:00
42 lines
1.0 KiB
HTML
42 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<script src="../testing.js"></script>
|
|
|
|
<script id=abortController>
|
|
var a1 = new AbortController();
|
|
|
|
var s1 = a1.signal;
|
|
testing.expectEqual(undefined, s1.throwIfAborted());
|
|
testing.expectEqual(undefined, s1.reason);
|
|
|
|
let target;;
|
|
let called = 0;
|
|
s1.addEventListener('abort', (e) => {
|
|
called += 1;
|
|
target = e.target;
|
|
});
|
|
|
|
a1.abort();
|
|
testing.expectEqual(true, s1.aborted)
|
|
testing.expectEqual(s1, target)
|
|
testing.expectEqual('AbortError', s1.reason)
|
|
testing.expectEqual(1, called)
|
|
</script>
|
|
|
|
<script id=abort>
|
|
var s2 = AbortSignal.abort('over 9000');
|
|
testing.expectEqual(true, s2.aborted);
|
|
testing.expectEqual('over 9000', s2.reason);
|
|
testing.expectEqual('AbortError', AbortSignal.abort().reason);
|
|
</script>
|
|
|
|
<script id=timeout>
|
|
var s3 = AbortSignal.timeout(10);
|
|
testing.onload(() => {
|
|
testing.expectEqual(true, s3.aborted);
|
|
testing.expectEqual('TimeoutError', s3.reason);
|
|
testing.expectError('Error: TimeoutError', () => {
|
|
s3.throwIfAborted()
|
|
});
|
|
});
|
|
</script>
|