Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit cd17759

Browse files
jasnellmoz-wptsync-bot
authored andcommitted
Bug 1744858 [wpt PR 31947] - Tests for abortSignal.throwIfAborted();, a=testonly
Automatic update from web-platform-tests Tests for abortSignal.throwIfAborted() Follows whatwg/dom#1034. -- wpt-commits: b03df354b93b285fe1764d567b7c1a074df4a808 wpt-pr: 31947
1 parent f4759fe commit cd17759

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

testing/web-platform/tests/dom/abort/event.any.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,4 +168,23 @@ test(t => {
168168
);
169169
}, "AbortController.signal.reason returns the same DOMException");
170170

171+
test(t => {
172+
const reason = new Error('boom');
173+
const signal = AbortSignal.abort(reason);
174+
assert_true(signal.aborted);
175+
assert_throws_exactly(reason, () => signal.throwIfAborted());
176+
}, "throwIfAborted() should throw abort.reason if signal aborted");
177+
178+
test(t => {
179+
const signal = AbortSignal.abort('hello');
180+
assert_true(signal.aborted);
181+
assert_throws_exactly('hello', () => signal.throwIfAborted());
182+
}, "throwIfAborted() should throw primitive abort.reason if signal aborted");
183+
184+
test(t => {
185+
const controller = new AbortController();
186+
assert_false(controller.signal.aborted);
187+
controller.signal.throwIfAborted();
188+
}, "throwIfAborted() should not throw if signal not aborted");
189+
171190
done();

0 commit comments

Comments
 (0)