js/src/jit-test/tests/basic/bug703157.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:c9411899926a
1 // Define a test object
2 var test = {x:1,y:2};
3
4 // Put the object into dictionary mode by deleting
5 // a property that was not the last one added.
6 delete test.x;
7
8 // Define a an accessor property with a setter that
9 // itself calls Object.defineProperty
10 Object.defineProperty(test, "foo", {
11 get: function() { return 1; },
12 set: function(v) {
13 Object.defineProperty(this, "foo", { value: v });
14 // Prints the correct object descriptor
15 assertEq(this.foo, 33);
16 },
17 configurable: true
18 });
19
20 // Add another property, so generateOwnShape does not replace the foo property.
21 test.other = 0;
22
23 // This line prints 1, as expected
24 assertEq(test.foo, 1);
25
26 // Now set the property. This calls the setter method above.
27 // And the setter method prints the expected value and property descriptor.
28 test.foo = 33;
29
30 // Finally read the newly set value.
31 assertEq(test.foo, 33);
32
33 // Check that enumeration order is correct.
34 var arr = [];
35 for (var x in test) arr.push(x);
36 assertEq("" + arr, "y,other");

mercurial