diff --git a/cli/rt/40_performance.js b/cli/rt/40_performance.js index 573fc8051f..3d8be60314 100644 --- a/cli/rt/40_performance.js +++ b/cli/rt/40_performance.js @@ -70,11 +70,11 @@ } constructor( - name, - entryType, - startTime, - duration, - key, + name = null, + entryType = null, + startTime = null, + duration = null, + key = null, ) { if (key != illegalConstructorKey) { throw new TypeError("Illegal constructor."); @@ -185,7 +185,7 @@ } class Performance { - constructor(key) { + constructor(key = null) { if (key != illegalConstructorKey) { throw new TypeError("Illegal constructor."); } diff --git a/cli/rt/40_permissions.js b/cli/rt/40_permissions.js index 982e4c842d..50d471b6a5 100644 --- a/cli/rt/40_permissions.js +++ b/cli/rt/40_permissions.js @@ -17,7 +17,7 @@ } class PermissionStatus { - constructor(state, key) { + constructor(state = null, key = null) { if (key != illegalConstructorKey) { throw new TypeError("Illegal constructor."); } diff --git a/cli/tests/unit/globals_test.ts b/cli/tests/unit/globals_test.ts index 422bd2aec4..4fd531b25f 100644 --- a/cli/tests/unit/globals_test.ts +++ b/cli/tests/unit/globals_test.ts @@ -40,6 +40,10 @@ unitTest(function globalThisInstanceofWindow(): void { assert(globalThis instanceof Window); }); +unitTest(function globalThisConstructorLength(): void { + assert(globalThis.constructor.length === 0); +}); + unitTest(function globalThisInstanceofEventTarget(): void { assert(globalThis instanceof EventTarget); }); diff --git a/cli/tests/unit/performance_test.ts b/cli/tests/unit/performance_test.ts index 1df46b1b23..122938b369 100644 --- a/cli/tests/unit/performance_test.ts +++ b/cli/tests/unit/performance_test.ts @@ -83,10 +83,12 @@ unitTest(function performanceMeasure() { unitTest(function performanceIllegalConstructor() { assertThrows(() => new Performance(), TypeError, "Illegal constructor."); + assertEquals(Performance.length, 0); }); unitTest(function performanceEntryIllegalConstructor() { assertThrows(() => new PerformanceEntry(), TypeError, "Illegal constructor."); + assertEquals(PerformanceEntry.length, 0); }); unitTest(function performanceMeasureIllegalConstructor() { diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts index eada8fe9a5..dee8aa195b 100644 --- a/cli/tests/unit/permissions_test.ts +++ b/cli/tests/unit/permissions_test.ts @@ -1,5 +1,10 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { assertThrows, assertThrowsAsync, unitTest } from "./test_util.ts"; +import { + assertEquals, + assertThrows, + assertThrowsAsync, + unitTest, +} from "./test_util.ts"; unitTest(async function permissionInvalidName(): Promise { await assertThrowsAsync(async () => { @@ -24,4 +29,5 @@ unitTest(function permissionStatusIllegalConstructor() { TypeError, "Illegal constructor.", ); + assertEquals(Deno.PermissionStatus.length, 0); }); diff --git a/op_crates/web/02_abort_signal.js b/op_crates/web/02_abort_signal.js index 354cd1fbf1..5ee047c360 100644 --- a/op_crates/web/02_abort_signal.js +++ b/op_crates/web/02_abort_signal.js @@ -31,7 +31,7 @@ this.#abortAlgorithms.delete(algorithm); } - constructor(key) { + constructor(key = null) { if (key != illegalConstructorKey) { throw new TypeError("Illegal constructor."); } diff --git a/op_crates/web/03_global_interfaces.js b/op_crates/web/03_global_interfaces.js index 3c6b5695b7..7ade64cc1a 100644 --- a/op_crates/web/03_global_interfaces.js +++ b/op_crates/web/03_global_interfaces.js @@ -4,7 +4,7 @@ const illegalConstructorKey = Symbol("illegalConstuctorKey"); class Window extends EventTarget { - constructor(key) { + constructor(key = null) { if (key !== illegalConstructorKey) { throw new TypeError("Illegal constructor."); } @@ -17,7 +17,7 @@ } class WorkerGlobalScope extends EventTarget { - constructor(key) { + constructor(key = null) { if (key != illegalConstructorKey) { throw new TypeError("Illegal constructor."); } @@ -30,7 +30,7 @@ } class DedicatedWorkerGlobalScope extends WorkerGlobalScope { - constructor(key) { + constructor(key = null) { if (key != illegalConstructorKey) { throw new TypeError("Illegal constructor."); } diff --git a/op_crates/web/abort_controller_test.js b/op_crates/web/abort_controller_test.js index a65bc69ff8..2f26ade285 100644 --- a/op_crates/web/abort_controller_test.js +++ b/op_crates/web/abort_controller_test.js @@ -118,6 +118,11 @@ function abortSignalHandlerLocation() { const abortHandler = Object.getOwnPropertyDescriptor(signal, "onabort"); assertEquals(abortHandler, undefined); } +function abortSignalLength() { + const controller = new AbortController(); + const { signal } = controller; + assertEquals(signal.constructor.length, 0); +} function main() { basicAbortController(); signalCallsOnabort(); @@ -128,6 +133,7 @@ function main() { abortSignalEventOrder(); abortSignalEventOrderComplex(); abortSignalHandlerLocation(); + abortSignalLength(); } main();