Skip to content

Commit 53cb298

Browse files
joyeecheungtargos
authored andcommitted
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: #58414 Fixes: #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>
1 parent 7acac70 commit 53cb298

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

test/pummel/test-blob-slice-with-large-size.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
'use strict';
2+
3+
// This tests that Blob.prototype.slice() works correctly when the size of the
4+
// Blob is outside the range of 32-bit signed integers.
25
const common = require('../common');
36

47
// Buffer with size > INT32_MAX
@@ -14,8 +17,11 @@ try {
1417
const slicedBlob = blob.slice(size - 1, size);
1518
assert.strictEqual(slicedBlob.size, 1);
1619
} catch (e) {
17-
if (e.code !== 'ERR_MEMORY_ALLOCATION_FAILED') {
18-
throw e;
20+
if (e.code === 'ERR_MEMORY_ALLOCATION_FAILED') {
21+
common.skip('insufficient space for Buffer.allocUnsafe');
22+
}
23+
if (/Array buffer allocation failed/.test(e.message)) {
24+
common.skip('insufficient space for Blob.prototype.slice()');
1925
}
20-
common.skip('insufficient space for Buffer.allocUnsafe');
26+
throw e;
2127
}

0 commit comments

Comments
 (0)