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/large-arraybuffers/shared-array-buffer.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/large-arraybuffers/shared-array-buffer.js')
-rw-r--r-- | js/src/jit-test/tests/large-arraybuffers/shared-array-buffer.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/large-arraybuffers/shared-array-buffer.js b/js/src/jit-test/tests/large-arraybuffers/shared-array-buffer.js new file mode 100644 index 0000000000..608744b392 --- /dev/null +++ b/js/src/jit-test/tests/large-arraybuffers/shared-array-buffer.js @@ -0,0 +1,40 @@ +// |jit-test| skip-if: !this.SharedArrayBuffer + +var gb = 1 * 1024 * 1024 * 1024; +var sab = new SharedArrayBuffer(4 * gb + 10); +var ta = new Uint8Array(sab); + +function testSlice() { + // Large |start| and |end|. + ta[4 * gb + 0] = 11; + ta[4 * gb + 1] = 22; + ta[4 * gb + 2] = 33; + ta[4 * gb + 3] = 44; + var ta2 = new Uint8Array(sab.slice(4 * gb, 4 * gb + 4)); + assertEq(ta2.toString(), "11,22,33,44"); + + // Large |start|. + ta[ta.length - 3] = 99; + ta[ta.length - 2] = 88; + ta[ta.length - 1] = 77; + ta2 = new Uint8Array(sab.slice(4 * gb + 8)); + assertEq(ta2.toString(), "88,77"); + + // Relative values. + ta2 = new Uint8Array(sab.slice(-3, -1)); + assertEq(ta2.toString(), "99,88"); + + // Large relative values. + ta[0] = 100; + ta[1] = 101; + ta[2] = 102; + ta2 = new Uint8Array(sab.slice(-ta.length, -ta.length + 3)); + assertEq(ta2.toString(), "100,101,102"); +} +testSlice(); + +function testSharedMailbox() { + setSharedObject(sab); + assertEq(getSharedObject().byteLength, 4 * gb + 10); +} +testSharedMailbox(); |