mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 10:15:07 +08:00
Apply Web IDL view conversion before checking the integer array type, including shared and resizable backing-buffer restrictions. Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66237 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Aviv Keller <me@aviv.sh>
21 lines
546 B
JavaScript
21 lines
546 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
if (!common.hasCrypto)
|
|
common.skip('missing crypto');
|
|
|
|
const assert = require('assert');
|
|
|
|
for (const buffer of [
|
|
new SharedArrayBuffer(8),
|
|
new SharedArrayBuffer(8, { maxByteLength: 16 }),
|
|
new ArrayBuffer(8, { maxByteLength: 16 }),
|
|
]) {
|
|
for (const Type of [Uint8Array, Float32Array, DataView]) {
|
|
assert.throws(() => crypto.getRandomValues(new Type(buffer)), TypeError);
|
|
}
|
|
}
|
|
|
|
assert.throws(() => crypto.getRandomValues(new Proxy(new Uint8Array(8), {})),
|
|
TypeError);
|