Debian Codegraph @

js/src/jit-test/tests/sharedbuf/typedarray-from-sharedtypedarray-with-overridden-length.js

raw
1 // |jit-test| skip-if: !this.SharedArrayBuffer
2
3 // This would hit an assertion in debug builds due to an incorrect
4 // type guard in the code that copies data from STA to TA.
5
6 // Original test case
7
8 var sab = new SharedArrayBuffer(4);
9
10 var x = new Int32Array(sab);
11 x.__proto__ = (function(){});
12 new Uint8Array(x); // Would assert here
13
14 // Supposedly equivalent test case, provoking the error directly
15
16 var x = new Int32Array(sab);
17 Object.defineProperty(x, "length", { value: 0 });
18 new Uint8Array(x); // Would assert here
19
20 // Derived test case - would not tickle the bug, though.
21
22 var x = new Int32Array(sab);
23 Object.defineProperty(x, "length", { value: 1 << 20 });
24 new Uint8Array(x);