Debian Codegraph @

js/src/jit-test/tests/ion/bug998059.js

raw
1 // Test various ways of changing the behavior of |typedArray.length|.
2
3 function addLengthProperty() {
4 var x = new Uint16Array();
5 Object.defineProperty(x, "length", {value:1});
6 for (var i = 0; i < 5; i++)
7 assertEq(x.length, 1);
8 }
9 addLengthProperty();
10
11 function changePrototype() {
12 var x = new Uint16Array();
13 x.__proto__ = [0];
14 for (var i = 0; i < 5; i++)
15 assertEq(x.length, 1);
16 }
17 changePrototype();
18
19 function redefineLengthProperty() {
20 var x = new Uint16Array();
21 Object.defineProperty(Uint16Array.prototype, "length", {value:1});
22 for (var i = 0; i < 5; i++)
23 assertEq(x.length, 1);
24 }
25 redefineLengthProperty();