mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
test: fix missing edge case in test-blob-slice-with-large-size
The test only cares about whether a size outside the range of the 32-bit signed integers works with Blob.prototype.slice(). If it fails due to allocation failure when the system does not have enough memory, the test should just be skipped. The test previously only skipped the test when the allocation failure happens during allocation of the buffer source, but it could also happen during Blob.prototype.slice(). PR-URL: https://github.com/nodejs/node/pull/58414 Fixes: https://github.com/nodejs/node/issues/57235 Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: LiviaMedeiros <livia@cirno.name> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
This commit is contained in:
1 parent
7acac70bce
commit
53cb29898b
1 file changed
+9
-3
@@ -1,4 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
// This tests that Blob.prototype.slice() works correctly when the size of the
|
||||
// Blob is outside the range of 32-bit signed integers.
|
||||
const common = require('../common');
|
||||
|
||||
// Buffer with size > INT32_MAX
|
||||
@@ -14,8 +17,11 @@ try {
|
||||
const slicedBlob = blob.slice(size - 1, size);
|
||||
assert.strictEqual(slicedBlob.size, 1);
|
||||
} catch (e) {
|
||||
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
|
||||
throw e;
|
||||
if (e.code === 'ERR_MEMORY_ALLOCATION_FAILED') {
|
||||
common.skip('insufficient space for Buffer.allocUnsafe');
|
||||
}
|
||||
common.skip('insufficient space for Buffer.allocUnsafe');
|
||||
if (/Array buffer allocation failed/.test(e.message)) {
|
||||
common.skip('insufficient space for Blob.prototype.slice()');
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
Reference in new issue
Block a user