mirror of
https://github.com/nodejs/node.git
synced 2025-05-03 22:25:44 +00:00

V8 will soon support typed arrays as large as the maximum array buffer
length. This patch replaces hardcoded values related to
Buffer.kMaxLength with the actual constant.
It also fixes a test that was passing by accident.
Refs: 44b2995900
PR-URL: https://github.com/nodejs/node/pull/49876
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com>
25 lines
615 B
JavaScript
25 lines
615 B
JavaScript
// Flags: --no-warnings
|
|
'use strict';
|
|
|
|
const common = require('../common');
|
|
const assert = require('assert');
|
|
const { Blob, kMaxLength } = require('buffer');
|
|
|
|
if (common.isFreeBSD)
|
|
common.skip('Oversized buffer make the FreeBSD CI runner crash');
|
|
|
|
try {
|
|
new Blob([new Uint8Array(kMaxLength), [1]]);
|
|
} catch (e) {
|
|
if (
|
|
e.message === 'Array buffer allocation failed' ||
|
|
e.message === `Invalid typed array length: ${kMaxLength}`
|
|
) {
|
|
common.skip(
|
|
'Insufficient memory on this platform for oversized buffer test.'
|
|
);
|
|
} else {
|
|
assert.strictEqual(e.code, 'ERR_BUFFER_TOO_LARGE');
|
|
}
|
|
}
|