mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05: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: https://github.com/v8/v8/commit/44b299590083b888637c79fb5632806e607ab861 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');
|
|
}
|
|
}
|