Debian Codegraph @

js/src/jit-test/tests/sharedbuf/growable-sab-over-mailbox.js

raw
1 var gsab = new SharedArrayBuffer(4, {maxByteLength: 16});
2
3 // Test byte lengths are correct.
4 assertEq(gsab.byteLength, 4);
5 assertEq(gsab.maxByteLength, 16);
6
7 // Pass |gsab| to the mailbox.
8 setSharedObject(gsab);
9
10 // Retrieve again from the mailbox to create a new growable shared array buffer
11 // which points to the same memory.
12 var gsab2 = getSharedObject();
13
14 assertEq(gsab !== gsab2, true, "different objects expected");
15
16 // Byte lengths are correct for both objects.
17 assertEq(gsab.byteLength, 4);
18 assertEq(gsab.maxByteLength, 16);
19 assertEq(gsab2.byteLength, 4);
20 assertEq(gsab2.maxByteLength, 16);
21
22 // Grow the original object.
23 gsab.grow(6);
24
25 // Byte lengths are correct for both objects.
26 assertEq(gsab.byteLength, 6);
27 assertEq(gsab.maxByteLength, 16);
28 assertEq(gsab2.byteLength, 6);
29 assertEq(gsab2.maxByteLength, 16);
30
31 // Grow the copy.
32 gsab2.grow(8);
33
34 // Byte lengths are correct for both objects.
35 assertEq(gsab.byteLength, 8);
36 assertEq(gsab.maxByteLength, 16);
37 assertEq(gsab2.byteLength, 8);
38 assertEq(gsab2.maxByteLength, 16);