From b6c74aab240430fa70c057be825ce766d2314e02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 16 Aug 2024 00:30:06 +0100 Subject: [PATCH] Revert "test: run unit tests with DENO_FUTURE=1 (#24400)" (#25060) This reverts commit 22a834ff5b4b312b8f91be8991f2b495d49fad2f. Appears this commit might have broken tests on `main`. --- tests/integration/js_unit_tests.rs | 10 -- tests/integration/js_unit_tests_future.rs | 118 ---------------------- tests/integration/mod.rs | 2 - tests/unit/buffer_test.ts | 97 +++++++++--------- tests/unit/fetch_test.ts | 3 +- tests/unit/files_test.ts | 80 +++++++-------- tests/unit/flock_test.ts | 6 +- tests/unit/globals_test.ts | 31 ++---- tests/unit/io_test.ts | 35 +++---- tests/unit/net_test.ts | 25 ++--- tests/unit/process_test.ts | 14 +-- tests/unit/resources_test.ts | 79 +++++++-------- tests/unit/stat_test.ts | 55 +++++----- tests/unit/sync_test.ts | 10 +- tests/unit/test_util.ts | 2 - tests/unit/timers_test.ts | 59 +---------- tests/unit/tls_test.ts | 30 +++--- tests/unit/tty_test.ts | 17 ++-- tests/unit/utime_test.ts | 5 +- tests/unit/webcrypto_test.ts | 32 +++--- 20 files changed, 223 insertions(+), 487 deletions(-) delete mode 100644 tests/integration/js_unit_tests_future.rs diff --git a/tests/integration/js_unit_tests.rs b/tests/integration/js_unit_tests.rs index bc6c5bdae5..cbae4a0b8c 100644 --- a/tests/integration/js_unit_tests.rs +++ b/tests/integration/js_unit_tests.rs @@ -117,10 +117,6 @@ util::unit_test_factory!( ); fn js_unit_test(test: String) { - js_unit_test_inner(test, false); -} - -pub fn js_unit_test_inner(test: String, future: bool) { let _g = util::http_server(); let deno = util::deno_cmd() @@ -133,12 +129,6 @@ pub fn js_unit_test_inner(test: String, future: bool) { .arg("--location=http://127.0.0.1:4545/") .arg("--no-prompt"); - let deno = if future { - deno.env("DENO_FUTURE", "1") - } else { - deno - }; - // TODO(mmastrac): it would be better to just load a test CA for all tests let deno = if test == "websocket_test" || test == "tls_sni_test" { deno.arg("--unsafely-ignore-certificate-errors") diff --git a/tests/integration/js_unit_tests_future.rs b/tests/integration/js_unit_tests_future.rs deleted file mode 100644 index 1541ace992..0000000000 --- a/tests/integration/js_unit_tests_future.rs +++ /dev/null @@ -1,118 +0,0 @@ -// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. - -use super::js_unit_tests::js_unit_test_inner; -use test_util as util; - -util::unit_test_factory!( - js_unit_test_future, - "../tests/unit", - "*.ts", - [ - abort_controller_test, - blob_test, - body_test, - broadcast_channel_test, - buffer_test, - build_test, - cache_api_test, - chmod_test, - chown_test, - command_test, - console_test, - copy_file_test, - custom_event_test, - cron_test, - dir_test, - dom_exception_test, - error_stack_test, - error_test, - esnext_test, - event_source_test, - event_target_test, - event_test, - fetch_test, - ffi_test, - file_test, - filereader_test, - files_test, - flock_test, - fs_events_test, - get_random_values_test, - globals_test, - headers_test, - http_test, - image_bitmap_test, - image_data_test, - internals_test, - intl_test, - io_test, - jupyter_test, - kv_test, - kv_queue_test_no_db_close, - kv_queue_test, - kv_queue_undelivered_test, - link_test, - make_temp_test, - message_channel_test, - mkdir_test, - navigator_test, - net_test, - network_interfaces_test, - os_test, - ops_test, - path_from_url_test, - performance_test, - permissions_test, - process_test, - progressevent_test, - promise_hooks_test, - read_dir_test, - read_file_test, - read_link_test, - read_text_file_test, - real_path_test, - ref_unref_test, - remove_test, - rename_test, - request_test, - resources_test, - response_test, - serve_test, - signal_test, - stat_test, - stdio_test, - streams_test, - structured_clone_test, - symbol_test, - symlink_test, - sync_test, - test_util, - testing_test, - text_encoding_test, - timers_test, - tls_test, - tls_sni_test, - truncate_test, - tty_color_test, - tty_test, - umask_test, - url_search_params_test, - url_test, - urlpattern_test, - utime_test, - version_test, - wasm_test, - webcrypto_test, - webgpu_test, - websocket_test, - webstorage_test, - worker_permissions_test, - worker_test, - write_file_test, - write_text_file_test, - ] -); - -fn js_unit_test_future(test: String) { - js_unit_test_inner(test, true); -} diff --git a/tests/integration/mod.rs b/tests/integration/mod.rs index cfde985d48..d35fabc027 100644 --- a/tests/integration/mod.rs +++ b/tests/integration/mod.rs @@ -37,8 +37,6 @@ mod inspector; mod install; #[path = "js_unit_tests.rs"] mod js_unit_tests; -#[path = "js_unit_tests_future.rs"] -mod js_unit_tests_future; #[path = "jsr_tests.rs"] mod jsr; #[path = "jupyter_tests.rs"] diff --git a/tests/unit/buffer_test.ts b/tests/unit/buffer_test.ts index 2295aa5ae4..2215748825 100644 --- a/tests/unit/buffer_test.ts +++ b/tests/unit/buffer_test.ts @@ -10,7 +10,6 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; import { writeAllSync } from "@std/io/write-all"; @@ -88,7 +87,7 @@ function repeat(c: string, bytes: number): Uint8Array { return ui8; } -Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() { +Deno.test(function bufferNewBuffer() { init(); assert(testBytes); assert(testString); @@ -96,7 +95,7 @@ Deno.test({ ignore: DENO_FUTURE }, function bufferNewBuffer() { check(buf, testString); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() { +Deno.test(async function bufferBasicOperations() { init(); assert(testBytes); assert(testString); @@ -136,7 +135,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferBasicOperations() { } }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() { +Deno.test(async function bufferReadEmptyAtEOF() { // check that EOF of 'buf' is not reached (even though it's empty) if // results are written to buffer that has 0 length (ie. it can't store any data) const buf = new Deno.Buffer(); @@ -145,7 +144,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadEmptyAtEOF() { assertEquals(result, 0); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() { +Deno.test(async function bufferLargeByteWrites() { init(); const buf = new Deno.Buffer(); const limit = 9; @@ -156,7 +155,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteWrites() { check(buf, ""); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() { +Deno.test(async function bufferTooLargeByteWrites() { init(); const tmp = new Uint8Array(72); const growLen = Number.MAX_VALUE; @@ -174,7 +173,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferTooLargeByteWrites() { }); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, function bufferGrowWriteMaxBuffer() { const bufSize = 16 * 1024; const capacities = [MAX_SIZE, MAX_SIZE - 1]; @@ -196,7 +195,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, async function bufferGrowReadCloseMaxBufferPlus1() { const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1)); const buf = new Deno.Buffer(); @@ -212,7 +211,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, function bufferGrowReadSyncCloseMaxBufferPlus1() { const reader = new Deno.Buffer(new ArrayBuffer(MAX_SIZE + 1)); const buf = new Deno.Buffer(); @@ -228,7 +227,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, function bufferGrowReadSyncCloseToMaxBuffer() { const capacities = [MAX_SIZE, MAX_SIZE - 1]; for (const capacity of capacities) { @@ -242,7 +241,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, async function bufferGrowReadCloseToMaxBuffer() { const capacities = [MAX_SIZE, MAX_SIZE - 1]; for (const capacity of capacities) { @@ -255,7 +254,7 @@ Deno.test( ); Deno.test( - { ignore: ignoreMaxSizeTests || DENO_FUTURE }, + { ignore: ignoreMaxSizeTests }, async function bufferReadCloseToMaxBufferWithInitialGrow() { const capacities = [MAX_SIZE, MAX_SIZE - 1, MAX_SIZE - 512]; for (const capacity of capacities) { @@ -268,7 +267,7 @@ Deno.test( }, ); -Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() { +Deno.test(async function bufferLargeByteReads() { init(); assert(testBytes); assert(testString); @@ -281,12 +280,12 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferLargeByteReads() { check(buf, ""); }); -Deno.test({ ignore: DENO_FUTURE }, function bufferCapWithPreallocatedSlice() { +Deno.test(function bufferCapWithPreallocatedSlice() { const buf = new Deno.Buffer(new ArrayBuffer(10)); assertEquals(buf.capacity, 10); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() { +Deno.test(async function bufferReadFrom() { init(); assert(testBytes); assert(testString); @@ -308,7 +307,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFrom() { }); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() { +Deno.test(async function bufferReadFromSync() { init(); assert(testBytes); assert(testString); @@ -330,7 +329,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferReadFromSync() { }); }); -Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() { +Deno.test(async function bufferTestGrow() { const tmp = new Uint8Array(72); for (const startLen of [0, 100, 1000, 10000]) { const xBytes = repeat("x", startLen); @@ -354,7 +353,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function bufferTestGrow() { } }); -Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() { +Deno.test(async function testReadAll() { init(); assert(testBytes); const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); @@ -365,7 +364,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function testReadAll() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() { +Deno.test(function testReadAllSync() { init(); assert(testBytes); const reader = new Deno.Buffer(testBytes.buffer as ArrayBuffer); @@ -376,7 +375,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testReadAllSync() { } }); -Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() { +Deno.test(async function testWriteAll() { init(); assert(testBytes); const writer = new Deno.Buffer(); @@ -388,7 +387,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function testWriteAll() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() { +Deno.test(function testWriteAllSync() { init(); assert(testBytes); const writer = new Deno.Buffer(); @@ -400,7 +399,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testWriteAllSync() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() { +Deno.test(function testBufferBytesArrayBufferLength() { // defaults to copy const args = [{}, { copy: undefined }, undefined, { copy: true }]; for (const arg of args) { @@ -419,7 +418,7 @@ Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesArrayBufferLength() { } }); -Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() { +Deno.test(function testBufferBytesCopyFalse() { const bufSize = 64 * 1024; const bytes = new TextEncoder().encode("a".repeat(bufSize)); const reader = new Deno.Buffer(); @@ -434,36 +433,30 @@ Deno.test({ ignore: DENO_FUTURE }, function testBufferBytesCopyFalse() { assert(actualBytes.buffer.byteLength > actualBytes.byteLength); }); -Deno.test( - { ignore: DENO_FUTURE }, - function testBufferBytesCopyFalseGrowExactBytes() { - const bufSize = 64 * 1024; - const bytes = new TextEncoder().encode("a".repeat(bufSize)); - const reader = new Deno.Buffer(); - writeAllSync(reader, bytes); +Deno.test(function testBufferBytesCopyFalseGrowExactBytes() { + const bufSize = 64 * 1024; + const bytes = new TextEncoder().encode("a".repeat(bufSize)); + const reader = new Deno.Buffer(); + writeAllSync(reader, bytes); - const writer = new Deno.Buffer(); - writer.grow(bufSize); - writer.readFromSync(reader); - const actualBytes = writer.bytes({ copy: false }); + const writer = new Deno.Buffer(); + writer.grow(bufSize); + writer.readFromSync(reader); + const actualBytes = writer.bytes({ copy: false }); - assertEquals(actualBytes.byteLength, bufSize); - assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength); - }, -); + assertEquals(actualBytes.byteLength, bufSize); + assertEquals(actualBytes.buffer.byteLength, actualBytes.byteLength); +}); -Deno.test( - { ignore: DENO_FUTURE }, - function testThrowsErrorWhenBufferExceedsMaxLength() { - const kStringMaxLengthPlusOne = 536870888 + 1; - const bytes = new Uint8Array(kStringMaxLengthPlusOne); +Deno.test(function testThrowsErrorWhenBufferExceedsMaxLength() { + const kStringMaxLengthPlusOne = 536870888 + 1; + const bytes = new Uint8Array(kStringMaxLengthPlusOne); - assertThrows( - () => { - new TextDecoder().decode(bytes); - }, - TypeError, - "buffer exceeds maximum length", - ); - }, -); + assertThrows( + () => { + new TextDecoder().decode(bytes); + }, + TypeError, + "buffer exceeds maximum length", + ); +}); diff --git a/tests/unit/fetch_test.ts b/tests/unit/fetch_test.ts index 5dc9d417d5..9b2463bcc3 100644 --- a/tests/unit/fetch_test.ts +++ b/tests/unit/fetch_test.ts @@ -6,7 +6,6 @@ import { assertStringIncludes, assertThrows, delay, - DENO_FUTURE, fail, unimplemented, } from "./test_util.ts"; @@ -1356,7 +1355,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function fetchCustomClientPrivateKey(): Promise< void > { diff --git a/tests/unit/files_test.ts b/tests/unit/files_test.ts index 71c5a4561b..754c6fb155 100644 --- a/tests/unit/files_test.ts +++ b/tests/unit/files_test.ts @@ -7,7 +7,6 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; import { copy } from "@std/io/copy"; @@ -19,37 +18,31 @@ Deno.test(function filesStdioFileDescriptors() { assertEquals(Deno.stderr.rid, 2); }); -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - async function filesCopyToStdout() { - const filename = "tests/testdata/assets/fixture.json"; - using file = await Deno.open(filename); - assert(file instanceof Deno.File); - assert(file instanceof Deno.FsFile); - assert(file.rid > 2); - const bytesWritten = await copy(file, Deno.stdout); - const fileSize = Deno.statSync(filename).size; - assertEquals(bytesWritten, fileSize); - }, -); +Deno.test({ permissions: { read: true } }, async function filesCopyToStdout() { + const filename = "tests/testdata/assets/fixture.json"; + using file = await Deno.open(filename); + assert(file instanceof Deno.File); + assert(file instanceof Deno.FsFile); + assert(file.rid > 2); + const bytesWritten = await copy(file, Deno.stdout); + const fileSize = Deno.statSync(filename).size; + assertEquals(bytesWritten, fileSize); +}); + +Deno.test({ permissions: { read: true } }, async function filesIter() { + const filename = "tests/testdata/assets/hello.txt"; + using file = await Deno.open(filename); + + let totalSize = 0; + for await (const buf of Deno.iter(file)) { + totalSize += buf.byteLength; + } + + assertEquals(totalSize, 12); +}); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - async function filesIter() { - const filename = "tests/testdata/assets/hello.txt"; - using file = await Deno.open(filename); - - let totalSize = 0; - for await (const buf of Deno.iter(file)) { - totalSize += buf.byteLength; - } - - assertEquals(totalSize, 12); - }, -); - -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, + { permissions: { read: true } }, async function filesIterCustomBufSize() { const filename = "tests/testdata/assets/hello.txt"; using file = await Deno.open(filename); @@ -66,23 +59,20 @@ Deno.test( }, ); -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - function filesIterSync() { - const filename = "tests/testdata/assets/hello.txt"; - using file = Deno.openSync(filename); +Deno.test({ permissions: { read: true } }, function filesIterSync() { + const filename = "tests/testdata/assets/hello.txt"; + using file = Deno.openSync(filename); - let totalSize = 0; - for (const buf of Deno.iterSync(file)) { - totalSize += buf.byteLength; - } + let totalSize = 0; + for (const buf of Deno.iterSync(file)) { + totalSize += buf.byteLength; + } - assertEquals(totalSize, 12); - }, -); + assertEquals(totalSize, 12); +}); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, + { permissions: { read: true } }, function filesIterSyncCustomBufSize() { const filename = "tests/testdata/assets/hello.txt"; using file = Deno.openSync(filename); @@ -99,7 +89,7 @@ Deno.test( }, ); -Deno.test({ ignore: DENO_FUTURE }, async function readerIter() { +Deno.test(async function readerIter() { // ref: https://github.com/denoland/deno/issues/2330 const encoder = new TextEncoder(); @@ -134,7 +124,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function readerIter() { assertEquals(totalSize, 12); }); -Deno.test({ ignore: DENO_FUTURE }, async function readerIterSync() { +Deno.test(async function readerIterSync() { // ref: https://github.com/denoland/deno/issues/2330 const encoder = new TextEncoder(); diff --git a/tests/unit/flock_test.ts b/tests/unit/flock_test.ts index f2a75e5d47..4b194ce553 100644 --- a/tests/unit/flock_test.ts +++ b/tests/unit/flock_test.ts @@ -1,15 +1,15 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { assertEquals, DENO_FUTURE } from "./test_util.ts"; +import { assertEquals } from "./test_util.ts"; Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } }, + { permissions: { read: true, run: true, hrtime: true } }, async function flockFileSync() { await runFlockTests({ sync: true }); }, ); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, run: true, hrtime: true } }, + { permissions: { read: true, run: true, hrtime: true } }, async function flockFileAsync() { await runFlockTests({ sync: false }); }, diff --git a/tests/unit/globals_test.ts b/tests/unit/globals_test.ts index 7e648d38db..e4cbe7daf1 100644 --- a/tests/unit/globals_test.ts +++ b/tests/unit/globals_test.ts @@ -6,7 +6,6 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; Deno.test(function globalThisExists() { @@ -20,7 +19,7 @@ Deno.test(function noInternalGlobals() { } }); -Deno.test({ ignore: DENO_FUTURE }, function windowExists() { +Deno.test(function windowExists() { assert(window != null); }); @@ -28,15 +27,15 @@ Deno.test(function selfExists() { assert(self != null); }); -Deno.test({ ignore: DENO_FUTURE }, function windowWindowExists() { +Deno.test(function windowWindowExists() { assert(window.window === window); }); -Deno.test({ ignore: DENO_FUTURE }, function windowSelfExists() { +Deno.test(function windowSelfExists() { assert(window.self === window); }); -Deno.test({ ignore: DENO_FUTURE }, function globalThisEqualsWindow() { +Deno.test(function globalThisEqualsWindow() { assert(globalThis === window); }); @@ -44,7 +43,7 @@ Deno.test(function globalThisEqualsSelf() { assert(globalThis === self); }); -Deno.test({ ignore: DENO_FUTURE }, function globalThisInstanceofWindow() { +Deno.test(function globalThisInstanceofWindow() { assert(globalThis instanceof Window); }); @@ -66,7 +65,7 @@ Deno.test(function DenoNamespaceExists() { assert(Deno != null); }); -Deno.test({ ignore: DENO_FUTURE }, function DenoNamespaceEqualsWindowDeno() { +Deno.test(function DenoNamespaceEqualsWindowDeno() { assert(Deno === window.Deno); }); @@ -120,11 +119,7 @@ Deno.test(async function windowQueueMicrotask() { res(); }; }); - if (DENO_FUTURE) { - globalThis.queueMicrotask(resolve1!); - } else { - window.queueMicrotask(resolve1!); - } + window.queueMicrotask(resolve1!); setTimeout(resolve2!, 0); await p1; await p2; @@ -143,18 +138,12 @@ Deno.test(function webApiGlobalThis() { Deno.test(function windowNameIsDefined() { assertEquals(typeof globalThis.name, "string"); assertEquals(name, ""); - if (!DENO_FUTURE) { - assertEquals(window.name, name); - } + assertEquals(window.name, name); name = "foobar"; - if (!DENO_FUTURE) { - assertEquals(window.name, "foobar"); - } + assertEquals(window.name, "foobar"); assertEquals(name, "foobar"); name = ""; - if (!DENO_FUTURE) { - assertEquals(window.name, ""); - } + assertEquals(window.name, ""); assertEquals(name, ""); }); diff --git a/tests/unit/io_test.ts b/tests/unit/io_test.ts index 44a04698c9..5b55729dd7 100644 --- a/tests/unit/io_test.ts +++ b/tests/unit/io_test.ts @@ -1,5 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { assertEquals, DENO_FUTURE } from "./test_util.ts"; +import { assertEquals } from "./test_util.ts"; import { Buffer } from "@std/io/buffer"; const DEFAULT_BUF_SIZE = 32 * 1024; @@ -28,7 +28,7 @@ function spyRead(obj: Buffer): Spy { return spy; } -Deno.test({ ignore: DENO_FUTURE }, async function copyWithDefaultBufferSize() { +Deno.test(async function copyWithDefaultBufferSize() { const xBytes = repeat("b", DEFAULT_BUF_SIZE); const reader = new Buffer(xBytes.buffer as ArrayBuffer); const write = new Buffer(); @@ -43,7 +43,7 @@ Deno.test({ ignore: DENO_FUTURE }, async function copyWithDefaultBufferSize() { assertEquals(readSpy.calls, 2); // read with DEFAULT_BUF_SIZE bytes + read with 0 bytes }); -Deno.test({ ignore: DENO_FUTURE }, async function copyWithCustomBufferSize() { +Deno.test(async function copyWithCustomBufferSize() { const bufSize = 1024; const xBytes = repeat("b", DEFAULT_BUF_SIZE); const reader = new Buffer(xBytes.buffer as ArrayBuffer); @@ -59,22 +59,19 @@ Deno.test({ ignore: DENO_FUTURE }, async function copyWithCustomBufferSize() { assertEquals(readSpy.calls, DEFAULT_BUF_SIZE / bufSize + 1); }); -Deno.test( - { ignore: DENO_FUTURE, permissions: { write: true } }, - async function copyBufferToFile() { - const filePath = "test-file.txt"; - // bigger than max File possible buffer 16kb - const bufSize = 32 * 1024; - const xBytes = repeat("b", bufSize); - const reader = new Buffer(xBytes.buffer as ArrayBuffer); - const write = await Deno.open(filePath, { write: true, create: true }); +Deno.test({ permissions: { write: true } }, async function copyBufferToFile() { + const filePath = "test-file.txt"; + // bigger than max File possible buffer 16kb + const bufSize = 32 * 1024; + const xBytes = repeat("b", bufSize); + const reader = new Buffer(xBytes.buffer as ArrayBuffer); + const write = await Deno.open(filePath, { write: true, create: true }); - // deno-lint-ignore no-deprecated-deno-api - const n = await Deno.copy(reader, write, { bufSize }); + // deno-lint-ignore no-deprecated-deno-api + const n = await Deno.copy(reader, write, { bufSize }); - assertEquals(n, xBytes.length); + assertEquals(n, xBytes.length); - write.close(); - await Deno.remove(filePath); - }, -); + write.close(); + await Deno.remove(filePath); +}); diff --git a/tests/unit/net_test.ts b/tests/unit/net_test.ts index 9cd3094e52..ddc55b8c4e 100644 --- a/tests/unit/net_test.ts +++ b/tests/unit/net_test.ts @@ -6,7 +6,6 @@ import { assertRejects, assertThrows, delay, - DENO_FUTURE, execCode, execCode2, tmpUnixSocketPath, @@ -28,9 +27,7 @@ Deno.test({ permissions: { net: true } }, function netTcpListenClose() { assert(listener.addr.transport === "tcp"); assertEquals(listener.addr.hostname, "127.0.0.1"); assertEquals(listener.addr.port, listenPort); - if (!DENO_FUTURE) { - assertNotEquals(listener.rid, 0); - } + assertNotEquals(listener.rid, 0); listener.close(); }); @@ -236,9 +233,7 @@ Deno.test({ permissions: { net: true } }, async function netTcpDialListen() { assertEquals(1, buf[0]); assertEquals(2, buf[1]); assertEquals(3, buf[2]); - if (!DENO_FUTURE) { - assert(conn.rid > 0); - } + assert(conn.rid > 0); assert(readResult !== null); @@ -274,9 +269,7 @@ Deno.test({ permissions: { net: true } }, async function netTcpSetNoDelay() { assertEquals(1, buf[0]); assertEquals(2, buf[1]); assertEquals(3, buf[2]); - if (!DENO_FUTURE) { - assert(conn.rid > 0); - } + assert(conn.rid > 0); assert(readResult !== null); @@ -312,9 +305,7 @@ Deno.test({ permissions: { net: true } }, async function netTcpSetKeepAlive() { assertEquals(1, buf[0]); assertEquals(2, buf[1]); assertEquals(3, buf[2]); - if (!DENO_FUTURE) { - assert(conn.rid > 0); - } + assert(conn.rid > 0); assert(readResult !== null); @@ -352,9 +343,7 @@ Deno.test( assertEquals(1, buf[0]); assertEquals(2, buf[1]); assertEquals(3, buf[2]); - if (!DENO_FUTURE) { - assert(conn.rid > 0); - } + assert(conn.rid > 0); assert(readResult !== null); @@ -850,9 +839,7 @@ Deno.test( assertEquals(1, buf[0]); assertEquals(2, buf[1]); assertEquals(3, buf[2]); - if (!DENO_FUTURE) { - assert(conn.rid > 0); - } + assert(conn.rid > 0); assert(readResult !== null); diff --git a/tests/unit/process_test.ts b/tests/unit/process_test.ts index 111b18421d..040c6ee197 100644 --- a/tests/unit/process_test.ts +++ b/tests/unit/process_test.ts @@ -5,7 +5,6 @@ import { assertStrictEquals, assertStringIncludes, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; Deno.test( @@ -364,11 +363,7 @@ Deno.test( ); Deno.test( - { - // Ignoring because uses `file.rid` - ignore: DENO_FUTURE, - permissions: { run: true, write: true, read: true }, - }, + { permissions: { run: true, write: true, read: true } }, async function runRedirectStdoutStderr() { const tempDir = await Deno.makeTempDir(); const fileName = tempDir + "/redirected_stdio.txt"; @@ -397,16 +392,11 @@ Deno.test( assertStringIncludes(text, "error"); assertStringIncludes(text, "output"); - console.log("finished tgis test"); }, ); Deno.test( - { - // Ignoring because uses `file.rid` - ignore: DENO_FUTURE, - permissions: { run: true, write: true, read: true }, - }, + { permissions: { run: true, write: true, read: true } }, async function runRedirectStdin() { const tempDir = await Deno.makeTempDir(); const fileName = tempDir + "/redirected_stdio.txt"; diff --git a/tests/unit/resources_test.ts b/tests/unit/resources_test.ts index ec7f5bc5b2..921a8af8f9 100644 --- a/tests/unit/resources_test.ts +++ b/tests/unit/resources_test.ts @@ -2,12 +2,7 @@ // deno-lint-ignore-file no-deprecated-deno-api -import { - assert, - assertEquals, - assertThrows, - DENO_FUTURE, -} from "./test_util.ts"; +import { assert, assertEquals, assertThrows } from "./test_util.ts"; const listenPort = 4505; @@ -17,7 +12,7 @@ Deno.test(function resourcesCloseBadArgs() { }, TypeError); }); -Deno.test({ ignore: DENO_FUTURE }, function resourcesStdio() { +Deno.test(function resourcesStdio() { const res = Deno.resources(); assertEquals(res[0], "stdin"); @@ -25,45 +20,39 @@ Deno.test({ ignore: DENO_FUTURE }, function resourcesStdio() { assertEquals(res[2], "stderr"); }); -Deno.test( - { ignore: DENO_FUTURE, permissions: { net: true } }, - async function resourcesNet() { - const listener = Deno.listen({ port: listenPort }); - const dialerConn = await Deno.connect({ port: listenPort }); - const listenerConn = await listener.accept(); +Deno.test({ permissions: { net: true } }, async function resourcesNet() { + const listener = Deno.listen({ port: listenPort }); + const dialerConn = await Deno.connect({ port: listenPort }); + const listenerConn = await listener.accept(); - const res = Deno.resources(); - assertEquals( - Object.values(res).filter((r): boolean => r === "tcpListener").length, - 1, - ); - const tcpStreams = Object.values(res).filter( - (r): boolean => r === "tcpStream", - ); - assert(tcpStreams.length >= 2); + const res = Deno.resources(); + assertEquals( + Object.values(res).filter((r): boolean => r === "tcpListener").length, + 1, + ); + const tcpStreams = Object.values(res).filter( + (r): boolean => r === "tcpStream", + ); + assert(tcpStreams.length >= 2); - listenerConn.close(); - dialerConn.close(); - listener.close(); - }, -); + listenerConn.close(); + dialerConn.close(); + listener.close(); +}); -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - async function resourcesFile() { - const resourcesBefore = Deno.resources(); - const f = await Deno.open("tests/testdata/assets/hello.txt"); - const resourcesAfter = Deno.resources(); - f.close(); +Deno.test({ permissions: { read: true } }, async function resourcesFile() { + const resourcesBefore = Deno.resources(); + const f = await Deno.open("tests/testdata/assets/hello.txt"); + const resourcesAfter = Deno.resources(); + f.close(); - // check that exactly one new resource (file) was added - assertEquals( - Object.keys(resourcesAfter).length, - Object.keys(resourcesBefore).length + 1, - ); - const newRid = +Object.keys(resourcesAfter).find((rid): boolean => { - return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid); - })!; - assertEquals(resourcesAfter[newRid], "fsFile"); - }, -); + // check that exactly one new resource (file) was added + assertEquals( + Object.keys(resourcesAfter).length, + Object.keys(resourcesBefore).length + 1, + ); + const newRid = +Object.keys(resourcesAfter).find((rid): boolean => { + return !Object.prototype.hasOwnProperty.call(resourcesBefore, rid); + })!; + assertEquals(resourcesAfter[newRid], "fsFile"); +}); diff --git a/tests/unit/stat_test.ts b/tests/unit/stat_test.ts index f9d7800312..e64b47536e 100644 --- a/tests/unit/stat_test.ts +++ b/tests/unit/stat_test.ts @@ -7,41 +7,34 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, pathToAbsoluteFileUrl, } from "./test_util.ts"; -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - function fstatSyncSuccess() { - using file = Deno.openSync("README.md"); - const fileInfo = Deno.fstatSync(file.rid); - assert(fileInfo.isFile); - assert(!fileInfo.isSymlink); - assert(!fileInfo.isDirectory); - assert(fileInfo.size); - assert(fileInfo.atime); - assert(fileInfo.mtime); - // The `birthtime` field is not available on Linux before kernel version 4.11. - assert(fileInfo.birthtime || Deno.build.os === "linux"); - }, -); +Deno.test({ permissions: { read: true } }, function fstatSyncSuccess() { + using file = Deno.openSync("README.md"); + const fileInfo = Deno.fstatSync(file.rid); + assert(fileInfo.isFile); + assert(!fileInfo.isSymlink); + assert(!fileInfo.isDirectory); + assert(fileInfo.size); + assert(fileInfo.atime); + assert(fileInfo.mtime); + // The `birthtime` field is not available on Linux before kernel version 4.11. + assert(fileInfo.birthtime || Deno.build.os === "linux"); +}); -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - async function fstatSuccess() { - using file = await Deno.open("README.md"); - const fileInfo = await Deno.fstat(file.rid); - assert(fileInfo.isFile); - assert(!fileInfo.isSymlink); - assert(!fileInfo.isDirectory); - assert(fileInfo.size); - assert(fileInfo.atime); - assert(fileInfo.mtime); - // The `birthtime` field is not available on Linux before kernel version 4.11. - assert(fileInfo.birthtime || Deno.build.os === "linux"); - }, -); +Deno.test({ permissions: { read: true } }, async function fstatSuccess() { + using file = await Deno.open("README.md"); + const fileInfo = await Deno.fstat(file.rid); + assert(fileInfo.isFile); + assert(!fileInfo.isSymlink); + assert(!fileInfo.isDirectory); + assert(fileInfo.size); + assert(fileInfo.atime); + assert(fileInfo.mtime); + // The `birthtime` field is not available on Linux before kernel version 4.11. + assert(fileInfo.birthtime || Deno.build.os === "linux"); +}); Deno.test( { permissions: { read: true, write: true } }, diff --git a/tests/unit/sync_test.ts b/tests/unit/sync_test.ts index 6112f35204..93eb4f0b08 100644 --- a/tests/unit/sync_test.ts +++ b/tests/unit/sync_test.ts @@ -1,8 +1,8 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { assertEquals, DENO_FUTURE } from "./test_util.ts"; +import { assertEquals } from "./test_util.ts"; Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, write: true } }, + { permissions: { read: true, write: true } }, function fdatasyncSyncSuccess() { const filename = Deno.makeTempDirSync() + "/test_fdatasyncSync.txt"; using file = Deno.openSync(filename, { @@ -18,7 +18,7 @@ Deno.test( ); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, write: true } }, + { permissions: { read: true, write: true } }, async function fdatasyncSuccess() { const filename = (await Deno.makeTempDir()) + "/test_fdatasync.txt"; using file = await Deno.open(filename, { @@ -35,7 +35,7 @@ Deno.test( ); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, write: true } }, + { permissions: { read: true, write: true } }, function fsyncSyncSuccess() { const filename = Deno.makeTempDirSync() + "/test_fsyncSync.txt"; using file = Deno.openSync(filename, { @@ -52,7 +52,7 @@ Deno.test( ); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, write: true } }, + { permissions: { read: true, write: true } }, async function fsyncSuccess() { const filename = (await Deno.makeTempDir()) + "/test_fsync.txt"; using file = await Deno.open(filename, { diff --git a/tests/unit/test_util.ts b/tests/unit/test_util.ts index 16ca735ace..e45a963e9a 100644 --- a/tests/unit/test_util.ts +++ b/tests/unit/test_util.ts @@ -25,8 +25,6 @@ export { delay } from "@std/async/delay"; export { readLines } from "@std/io/read-lines"; export { parseArgs } from "@std/cli/parse-args"; -export const DENO_FUTURE = Deno.env.get("DENO_FUTURE") === "1"; - export function pathToAbsoluteFileUrl(path: string): URL { path = resolve(path); diff --git a/tests/unit/timers_test.ts b/tests/unit/timers_test.ts index 679e57df79..6e829c07fc 100644 --- a/tests/unit/timers_test.ts +++ b/tests/unit/timers_test.ts @@ -4,7 +4,6 @@ import { assertEquals, assertNotEquals, delay, - DENO_FUTURE, execCode, unreachable, } from "./test_util.ts"; @@ -309,63 +308,11 @@ Deno.test(async function timeoutCallbackThis() { }; setTimeout(obj.foo, 1); await promise; - if (!DENO_FUTURE) { - assertEquals(capturedThis, window); - } else { - assertEquals(capturedThis, globalThis); - } + assertEquals(capturedThis, window); }); -Deno.test({ ignore: DENO_FUTURE }, async function timeoutBindThis() { - const thisCheckPassed = [null, undefined, globalThis, window]; - - const thisCheckFailed = [ - 0, - "", - true, - false, - {}, - [], - "foo", - () => {}, - Object.prototype, - ]; - - for (const thisArg of thisCheckPassed) { - const { promise, resolve } = Promise.withResolvers(); - let hasThrown = 0; - try { - setTimeout.call(thisArg, () => resolve(), 1); - hasThrown = 1; - } catch (err) { - if (err instanceof TypeError) { - hasThrown = 2; - } else { - hasThrown = 3; - } - } - await promise; - assertEquals(hasThrown, 1); - } - - for (const thisArg of thisCheckFailed) { - let hasThrown = 0; - try { - setTimeout.call(thisArg, () => {}, 1); - hasThrown = 1; - } catch (err) { - if (err instanceof TypeError) { - hasThrown = 2; - } else { - hasThrown = 3; - } - } - assertEquals(hasThrown, 2); - } -}); - -Deno.test({ ignore: !DENO_FUTURE }, async function timeoutBindThis() { - const thisCheckPassed = [null, undefined, globalThis]; +Deno.test(async function timeoutBindThis() { + const thisCheckPassed = [null, undefined, window, globalThis]; const thisCheckFailed = [ 0, diff --git a/tests/unit/tls_test.ts b/tests/unit/tls_test.ts index 1facd0f984..34061bb21e 100644 --- a/tests/unit/tls_test.ts +++ b/tests/unit/tls_test.ts @@ -6,7 +6,6 @@ import { assertRejects, assertStrictEquals, assertThrows, - DENO_FUTURE, } from "./test_util.ts"; import { BufReader, BufWriter } from "@std/io"; import { readAll } from "@std/io/read-all"; @@ -68,7 +67,7 @@ Deno.test( ); Deno.test( - { permissions: { net: true, read: false }, ignore: DENO_FUTURE }, + { permissions: { net: true, read: false } }, async function connectTLSCertFileNoReadPerm() { await assertRejects(async () => { await Deno.connectTls({ @@ -81,7 +80,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, function listenTLSNonExistentCertKeyFiles() { const options = { hostname: "localhost", @@ -107,7 +106,7 @@ Deno.test( ); Deno.test( - { permissions: { net: true, read: false }, ignore: DENO_FUTURE }, + { permissions: { net: true, read: false } }, function listenTLSNoReadPerm() { assertThrows(() => { Deno.listenTls({ @@ -123,7 +122,6 @@ Deno.test( Deno.test( { permissions: { read: true, write: true, net: true }, - ignore: DENO_FUTURE, }, function listenTLSEmptyKeyFile() { const options = { @@ -221,7 +219,7 @@ Deno.test( ); const conn = await Deno.connectTls({ hostname, port, caCerts }); - assert(DENO_FUTURE || conn.rid > 0); + assert(conn.rid > 0); const w = new BufWriter(conn); const r = new BufReader(conn); const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`; @@ -273,7 +271,7 @@ Deno.test( ); const conn = await Deno.connectTls({ hostname, port, caCerts }); - assert(DENO_FUTURE || conn.rid > 0); + assert(conn.rid > 0); const w = new BufWriter(conn); const r = new BufReader(conn); const body = `GET / HTTP/1.1\r\nHost: ${hostname}:${port}\r\n\r\n`; @@ -1148,7 +1146,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSBadClientCertPrivateKey(): Promise { await assertRejects(async () => { await Deno.connectTls({ @@ -1164,7 +1162,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSBadCertKey(): Promise { await assertRejects(async () => { await Deno.connectTls({ @@ -1180,7 +1178,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSBadPrivateKey(): Promise { await assertRejects(async () => { await Deno.connectTls({ @@ -1212,7 +1210,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSNotPrivateKey(): Promise { await assertRejects(async () => { await Deno.connectTls({ @@ -1228,7 +1226,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTLSNotKey(): Promise { await assertRejects(async () => { await Deno.connectTls({ @@ -1244,7 +1242,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectWithClientCert() { // The test_server running on port 4552 responds with 'PASS' if client // authentication was successful. Try it by running test_server and @@ -1294,7 +1292,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTlsConflictingCertOptions(): Promise { await assertRejects( async () => { @@ -1319,7 +1317,7 @@ Deno.test( ); Deno.test( - { permissions: { read: true, net: true }, ignore: DENO_FUTURE }, + { permissions: { read: true, net: true } }, async function connectTlsConflictingKeyOptions(): Promise { await assertRejects( async () => { @@ -1637,7 +1635,7 @@ Deno.test( ); Deno.test( - { ignore: DENO_FUTURE, permissions: { net: true, read: true } }, + { permissions: { net: true, read: true } }, function listenTLSEcKey() { const listener = Deno.listenTls({ hostname: "localhost", diff --git a/tests/unit/tty_test.ts b/tests/unit/tty_test.ts index 35e7dd7831..0c1140804e 100644 --- a/tests/unit/tty_test.ts +++ b/tests/unit/tty_test.ts @@ -2,7 +2,7 @@ // deno-lint-ignore-file no-deprecated-deno-api -import { assert, DENO_FUTURE } from "./test_util.ts"; +import { assert } from "./test_util.ts"; // Note tests for Deno.stdin.setRaw is in integration tests. @@ -15,15 +15,12 @@ Deno.test(function consoleSize() { assert(typeof result.rows !== "undefined"); }); -Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true } }, - function isatty() { - // CI not under TTY, so cannot test stdin/stdout/stderr. - const f = Deno.openSync("tests/testdata/assets/hello.txt"); - assert(!Deno.isatty(f.rid)); - f.close(); - }, -); +Deno.test({ permissions: { read: true } }, function isatty() { + // CI not under TTY, so cannot test stdin/stdout/stderr. + const f = Deno.openSync("tests/testdata/assets/hello.txt"); + assert(!Deno.isatty(f.rid)); + f.close(); +}); Deno.test(function isattyError() { let caught = false; diff --git a/tests/unit/utime_test.ts b/tests/unit/utime_test.ts index d5b4b92699..49bc966230 100644 --- a/tests/unit/utime_test.ts +++ b/tests/unit/utime_test.ts @@ -6,12 +6,11 @@ import { assertEquals, assertRejects, assertThrows, - DENO_FUTURE, pathToAbsoluteFileUrl, } from "./test_util.ts"; Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, write: true } }, + { permissions: { read: true, write: true } }, async function futimeSyncSuccess() { const testDir = await Deno.makeTempDir(); const filename = testDir + "/file.txt"; @@ -53,7 +52,7 @@ Deno.test( ); Deno.test( - { ignore: DENO_FUTURE, permissions: { read: true, write: true } }, + { permissions: { read: true, write: true } }, function futimeSyncSuccess() { const testDir = Deno.makeTempDirSync(); const filename = testDir + "/file.txt"; diff --git a/tests/unit/webcrypto_test.ts b/tests/unit/webcrypto_test.ts index 57aa19eaee..58f59edc69 100644 --- a/tests/unit/webcrypto_test.ts +++ b/tests/unit/webcrypto_test.ts @@ -9,7 +9,7 @@ import { // https://github.com/denoland/deno/issues/11664 Deno.test(async function testImportArrayBufferKey() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); // deno-fmt-ignore @@ -29,7 +29,7 @@ Deno.test(async function testImportArrayBufferKey() { }); Deno.test(async function testSignVerify() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); for (const algorithm of ["RSA-PSS", "RSASSA-PKCS1-v1_5"]) { for ( @@ -101,7 +101,7 @@ const hashPlainTextVector = [ ]; Deno.test(async function testEncryptDecrypt() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); for ( const { hash, plainText } of hashPlainTextVector @@ -154,7 +154,7 @@ Deno.test(async function testEncryptDecrypt() { }); Deno.test(async function testGenerateRSAKey() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); const keyPair = await subtle.generateKey( @@ -175,7 +175,7 @@ Deno.test(async function testGenerateRSAKey() { }); Deno.test(async function testGenerateHMACKey() { - const key = await globalThis.crypto.subtle.generateKey( + const key = await window.crypto.subtle.generateKey( { name: "HMAC", hash: "SHA-512", @@ -190,7 +190,7 @@ Deno.test(async function testGenerateHMACKey() { }); Deno.test(async function testECDSASignVerify() { - const key = await globalThis.crypto.subtle.generateKey( + const key = await window.crypto.subtle.generateKey( { name: "ECDSA", namedCurve: "P-384", @@ -201,7 +201,7 @@ Deno.test(async function testECDSASignVerify() { const encoder = new TextEncoder(); const encoded = encoder.encode("Hello, World!"); - const signature = await globalThis.crypto.subtle.sign( + const signature = await window.crypto.subtle.sign( { name: "ECDSA", hash: "SHA-384" }, key.privateKey, encoded, @@ -210,7 +210,7 @@ Deno.test(async function testECDSASignVerify() { assert(signature); assert(signature instanceof ArrayBuffer); - const verified = await globalThis.crypto.subtle.verify( + const verified = await window.crypto.subtle.verify( { hash: { name: "SHA-384" }, name: "ECDSA" }, key.publicKey, signature, @@ -221,7 +221,7 @@ Deno.test(async function testECDSASignVerify() { // Tests the "bad paths" as a temporary replacement for sign_verify/ecdsa WPT. Deno.test(async function testECDSASignVerifyFail() { - const key = await globalThis.crypto.subtle.generateKey( + const key = await window.crypto.subtle.generateKey( { name: "ECDSA", namedCurve: "P-384", @@ -233,7 +233,7 @@ Deno.test(async function testECDSASignVerifyFail() { const encoded = new Uint8Array([1]); // Signing with a public key (InvalidAccessError) await assertRejects(async () => { - await globalThis.crypto.subtle.sign( + await window.crypto.subtle.sign( { name: "ECDSA", hash: "SHA-384" }, key.publicKey, new Uint8Array([1]), @@ -242,7 +242,7 @@ Deno.test(async function testECDSASignVerifyFail() { }, DOMException); // Do a valid sign for later verifying. - const signature = await globalThis.crypto.subtle.sign( + const signature = await window.crypto.subtle.sign( { name: "ECDSA", hash: "SHA-384" }, key.privateKey, encoded, @@ -250,7 +250,7 @@ Deno.test(async function testECDSASignVerifyFail() { // Verifying with a private key (InvalidAccessError) await assertRejects(async () => { - await globalThis.crypto.subtle.verify( + await window.crypto.subtle.verify( { hash: { name: "SHA-384" }, name: "ECDSA" }, key.privateKey, signature, @@ -262,7 +262,7 @@ Deno.test(async function testECDSASignVerifyFail() { // https://github.com/denoland/deno/issues/11313 Deno.test(async function testSignRSASSAKey() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); const keyPair = await subtle.generateKey( @@ -284,7 +284,7 @@ Deno.test(async function testSignRSASSAKey() { const encoder = new TextEncoder(); const encoded = encoder.encode("Hello, World!"); - const signature = await globalThis.crypto.subtle.sign( + const signature = await window.crypto.subtle.sign( { name: "RSASSA-PKCS1-v1_5" }, keyPair.privateKey, encoded, @@ -1056,7 +1056,7 @@ const jwtRSAKeys = { }; Deno.test(async function testImportRsaJwk() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); for (const [_key, jwkData] of Object.entries(jwtRSAKeys)) { @@ -1496,7 +1496,7 @@ const ecTestKeys = [ ]; Deno.test(async function testImportEcSpkiPkcs8() { - const subtle = globalThis.crypto.subtle; + const subtle = window.crypto.subtle; assert(subtle); for (