diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js')
-rw-r--r-- | js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js b/js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js new file mode 100644 index 0000000000..3ffb29cc3d --- /dev/null +++ b/js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js @@ -0,0 +1,40 @@ +// |jit-test| --enable-arraybuffer-resizable; skip-if: !this.SharedArrayBuffer?.prototype?.grow + +var gsab = new SharedArrayBuffer(4, {maxByteLength: 16}); + +// Test byte lengths are correct. +assertEq(gsab.byteLength, 4); +assertEq(gsab.maxByteLength, 16); + +// Pass |gsab| to the mailbox. +setSharedObject(gsab); + +// Retrieve again from the mailbox to create a new growable shared array buffer +// which points to the same memory. +var gsab2 = getSharedObject(); + +assertEq(gsab !== gsab2, true, "different objects expected"); + +// Byte lengths are correct for both objects. +assertEq(gsab.byteLength, 4); +assertEq(gsab.maxByteLength, 16); +assertEq(gsab2.byteLength, 4); +assertEq(gsab2.maxByteLength, 16); + +// Grow the original object. +gsab.grow(6); + +// Byte lengths are correct for both objects. +assertEq(gsab.byteLength, 6); +assertEq(gsab.maxByteLength, 16); +assertEq(gsab2.byteLength, 6); +assertEq(gsab2.maxByteLength, 16); + +// Grow the copy. +gsab2.grow(8); + +// Byte lengths are correct for both objects. +assertEq(gsab.byteLength, 8); +assertEq(gsab.maxByteLength, 16); +assertEq(gsab2.byteLength, 8); +assertEq(gsab2.maxByteLength, 16); |