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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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

mercurial