diff options
| author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2020-09-19 22:30:59 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-19 23:30:59 +0200 |
| commit | aaa5e6613a739f8e2ff7579b69c2504bcdc37d4f (patch) | |
| tree | d6c198b5bc222be4c097e7aa5e9504662c98a974 /cli/tests | |
| parent | 79e5b57663becad3614bce98e31c7d1d494cb50d (diff) | |
fix(cli/rt): make some web API constructors illegal at runtime (#7468)
Diffstat (limited to 'cli/tests')
| -rw-r--r-- | cli/tests/unit/performance_test.ts | 17 | ||||
| -rw-r--r-- | cli/tests/unit/permissions_test.ts | 14 |
2 files changed, 30 insertions, 1 deletions
diff --git a/cli/tests/unit/performance_test.ts b/cli/tests/unit/performance_test.ts index 3c98e4e40..7b2fa5cef 100644 --- a/cli/tests/unit/performance_test.ts +++ b/cli/tests/unit/performance_test.ts @@ -3,6 +3,7 @@ import { unitTest, assert, assertEquals, + assertThrows, createResolvable, } from "./test_util.ts"; @@ -64,3 +65,19 @@ unitTest(function performanceMeasure() { }, 100); }); }); + +unitTest(function performanceIllegalConstructor() { + assertThrows(() => new Performance(), TypeError, "Illegal constructor."); +}); + +unitTest(function performanceEntryIllegalConstructor() { + assertThrows(() => new PerformanceEntry(), TypeError, "Illegal constructor."); +}); + +unitTest(function performanceMeasureIllegalConstructor() { + assertThrows( + () => new PerformanceMeasure(), + TypeError, + "Illegal constructor.", + ); +}); diff --git a/cli/tests/unit/permissions_test.ts b/cli/tests/unit/permissions_test.ts index 005727721..21fa1d27b 100644 --- a/cli/tests/unit/permissions_test.ts +++ b/cli/tests/unit/permissions_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { unitTest, assertThrowsAsync } from "./test_util.ts"; +import { unitTest, assertThrows, assertThrowsAsync } from "./test_util.ts"; unitTest(async function permissionInvalidName(): Promise<void> { await assertThrowsAsync(async () => { @@ -13,3 +13,15 @@ unitTest(async function permissionNetInvalidUrl(): Promise<void> { await Deno.permissions.query({ name: "net", url: ":" }); }, URIError); }); + +unitTest(function permissionsIllegalConstructor() { + assertThrows(() => new Deno.Permissions(), TypeError, "Illegal constructor."); +}); + +unitTest(function permissionStatusIllegalConstructor() { + assertThrows( + () => new Deno.PermissionStatus(), + TypeError, + "Illegal constructor.", + ); +}); |
