Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for abortSignal.throwIfAborted(); #31947

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions dom/abort/event.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,4 +139,17 @@ test(t => {
assert_equals(signal.reason, reason, "signal.reason");
}, "static aborting signal with reason should set signal.reason");

test(t => {
const reason = new Error('boom');
const signal = AbortSignal.abort(reason);
assert_true(signal.aborted);
assert_throws_exactly(reason, () => signal.throwIfAborted());
}, "throwIfAborted() should throw abort.reason if signal aborted");

test(t => {
const controller = new AbortController();
assert_false(controller.signal.aborted);
controller.signal.throwIfAborted();
}, "throwIfAborted() should not throw if signal not aborted");

done();