From e088f3259fc8056883987783c1ca143c8cd936dc Mon Sep 17 00:00:00 2001 From: Jithil P Ponnan Date: Thu, 26 Jan 2023 14:46:00 +1100 Subject: [PATCH] test: add getRandomValues return length --- test/parallel/test-webcrypto-random.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/parallel/test-webcrypto-random.js b/test/parallel/test-webcrypto-random.js index 31d4884d1f653f..1aafc38c27b922 100644 --- a/test/parallel/test-webcrypto-random.js +++ b/test/parallel/test-webcrypto-random.js @@ -69,3 +69,11 @@ for (const ctor of intTypedConstructors) { ); } } + +{ + const uint8Array = new Uint8Array(32) + let results = globalThis.crypto.getRandomValues(uint8Array); + assert.strictEqual(results.length, uint8Array.length); + results = globalThis.crypto.getRandomValues(new Uint8Array()); + assert.strictEqual(results.length, 0); +}