node/test/parallel/test-webcrypto-getRandomValues.js
Antoine du Hamel 6ee4228498
crypto: validate this value for webcrypto.getRandomValues
PR-URL: https://github.com/nodejs/node/pull/41760
Reviewed-By: Mestery <mestery@protonmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
2022-02-26 17:12:48 +00:00

12 lines
288 B
JavaScript

'use strict';
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const { getRandomValues } = require('crypto').webcrypto;
assert.throws(() => getRandomValues(new Uint8Array()), { code: 'ERR_INVALID_THIS' });