diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/typedarray/error-messages.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/typedarray/error-messages.js')
-rw-r--r-- | js/src/jit-test/tests/typedarray/error-messages.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/typedarray/error-messages.js b/js/src/jit-test/tests/typedarray/error-messages.js new file mode 100644 index 0000000000..f98e397dc7 --- /dev/null +++ b/js/src/jit-test/tests/typedarray/error-messages.js @@ -0,0 +1,40 @@ +// |jit-test| skip-if: getBuildConfiguration()['wasi'] + +function assertThrowsMessage(f, regexp) { + var threw = true; + var error = null; + try { + f(); + threw = false; + } catch (e) { + error = e; + } + // Make sure f threw + assertEq(threw, true); + // Make sure the message is as we expected + assertEq(regexp.test(error.message), true); +} + +var shared = new SharedArrayBuffer(4096); +assertThrowsMessage(() => new Int32Array(shared, 7), /start offset of Int32Array should be a multiple of 4/); + +var shared = new SharedArrayBuffer(4096); +assertThrowsMessage(() => new Float64Array(shared, 3), /start offset of Float64Array should be a multiple of 8/); + +var shared = new SharedArrayBuffer(1025); +assertThrowsMessage(() => new Float32Array(shared, 8), /buffer length for Float32Array should be a multiple of 4/); + +var shared = new SharedArrayBuffer(513); +assertThrowsMessage(() => new Int16Array(shared, 8), /buffer length for Int16Array should be a multiple of 2/); + +var shared = new SharedArrayBuffer(32); +assertThrowsMessage(() => new Int16Array(shared, 36), /size of buffer is too small for Int16Array with byteOffset/); + +var shared = new SharedArrayBuffer(2048); +assertThrowsMessage(() => new BigInt64Array(shared, 4096), /size of buffer is too small for BigInt64Array with byteOffset/); + +var shared = new SharedArrayBuffer(4096); +assertThrowsMessage(() => new Int32Array(shared, 4096, 4), /attempting to construct out-of-bounds Int32Array on ArrayBuffer/); + +var shared = new SharedArrayBuffer(1024); +assertThrowsMessage(() => new Float32Array(shared, 800, 300), /attempting to construct out-of-bounds Float32Array on ArrayBuffer/);
\ No newline at end of file |