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.

     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");

mercurial