Skip to content

Commit 2e8912e

Browse files
authored
Allow test for module size limit to fail (#1653)
* Allow test for module size limit to fail Allocating a 1GB Uint8Array can fail. In particular, it will always fail on 32-bit systems in V8, where the maximum size of a TypedArray is 2^30-1, thus 1 byte too little.
1 parent fe35511 commit 2e8912e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

test/js-api/limits.any.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,16 @@ function testModuleSizeLimit(size, expectPass) {
250250

251251
// Define a WebAssembly module that consists of a single custom section which
252252
// has an empty name. The module size will be `size`.
253-
const buffer = new Uint8Array(size);
253+
let buffer;
254+
try {
255+
buffer = new Uint8Array(size);
256+
} catch (e) {
257+
if (e instanceof RangeError) {
258+
// Allocation of a big TypedArray may fail.
259+
return;
260+
}
261+
throw e;
262+
}
254263
const header = [
255264
kWasmH0, kWasmH1, kWasmH2, kWasmH3, // magic word
256265
kWasmV0, kWasmV1, kWasmV2, kWasmV3, // version

0 commit comments

Comments
 (0)