From 004da61b32b813ece447e1ea5c044312f6c2c1d6 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Tue, 16 Mar 2021 01:30:42 +0100 Subject: [PATCH 1/2] Test if AbortController and AbortSignal perform brand checks --- dom/abort/event.any.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/dom/abort/event.any.js b/dom/abort/event.any.js index 2589ba1ce45091..022e3b9390d8a6 100644 --- a/dom/abort/event.any.js +++ b/dom/abort/event.any.js @@ -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(); From bd522334de53086bdb199c7c215285caac96e3a5 Mon Sep 17 00:00:00 2001 From: Mattias Buelens Date: Tue, 16 Mar 2021 01:47:34 +0100 Subject: [PATCH 2/2] Use consistent quote style --- dom/abort/event.any.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dom/abort/event.any.js b/dom/abort/event.any.js index 022e3b9390d8a6..3c2a70d2a8f6f6 100644 --- a/dom/abort/event.any.js +++ b/dom/abort/event.any.js @@ -70,22 +70,22 @@ test(t => { }, "the AbortSignal.abort() static returns an already aborted signal"); test(t => { - const acSignalGet = Object.getOwnPropertyDescriptor(AbortController.prototype, 'signal').get; + 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)]; + 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'); + 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 signalAbortedGet = Object.getOwnPropertyDescriptor(AbortSignal.prototype, "aborted").get; - const badAbortSignals = [null, undefined, 0, NaN, true, 'AbortSignal', Object.create(AbortSignal.prototype)]; + 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'); + assert_throws_js(TypeError, signalAbortedGet.bind(badSignal), "signal.aborted should throw"); } }, "AbortSignal should perform brand checks");