Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 // Define a test object
2 var test = {x:1,y:2};
4 // Put the object into dictionary mode by deleting
5 // a property that was not the last one added.
6 delete test.x;
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 });
20 // Add another property, so generateOwnShape does not replace the foo property.
21 test.other = 0;
23 // This line prints 1, as expected
24 assertEq(test.foo, 1);
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;
30 // Finally read the newly set value.
31 assertEq(test.foo, 33);
33 // Check that enumeration order is correct.
34 var arr = [];
35 for (var x in test) arr.push(x);
36 assertEq("" + arr, "y,other");