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

Test if AbortController and AbortSignal perform brand checks #28092

Closed
Changes from all 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
20 changes: 20 additions & 0 deletions dom/abort/event.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,24 @@ test(t => {
assert_true(signal.aborted);
}, "the AbortSignal.abort() static returns an already aborted signal");

test(t => {
const acSignalGet = Object.getOwnPropertyDescriptor(AbortController.prototype, "signal").get;
const acAbort = AbortController.prototype.abort;

const badAbortControllers = [null, undefined, 0, NaN, true, "AbortController", Object.create(AbortController.prototype)];
for (const badController of badAbortControllers) {
assert_throws_js(TypeError, acSignalGet.bind(badController), "controller.signal should throw");
assert_throws_js(TypeError, acAbort.bind(badController), "controller.abort() should throw");
}
}, "AbortController should perform brand checks");

test(t => {
const signalAbortedGet = Object.getOwnPropertyDescriptor(AbortSignal.prototype, "aborted").get;

const badAbortSignals = [null, undefined, 0, NaN, true, "AbortSignal", Object.create(AbortSignal.prototype)];
for (const badSignal of badAbortSignals) {
assert_throws_js(TypeError, signalAbortedGet.bind(badSignal), "signal.aborted should throw");
}
}, "AbortSignal should perform brand checks");

done();