From e9d9c3fbb798b8038eda4401765b8d52915ea47c 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 31d4884d1f653f1..03d7560352b64f3 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); +}