Chromium Code Reviews| Index: test/mjsunit/object-define-property.js |
| diff --git a/test/mjsunit/object-define-property.js b/test/mjsunit/object-define-property.js |
| index fdaf82d105e4de50c2a0708c6b6e95ae053178ad..452cd74ead195691aba9c565fc4dab6ea3a4037a 100644 |
| --- a/test/mjsunit/object-define-property.js |
| +++ b/test/mjsunit/object-define-property.js |
| @@ -27,7 +27,7 @@ |
| // Tests the object.defineProperty method - ES 15.2.3.6 |
| -// Flags: --allow-natives-syntax |
| +// Flags: --allow-natives-syntax --es5-readonly |
| // Check that an exception is thrown when null is passed as object. |
| var exception = false; |
| @@ -1085,3 +1085,60 @@ assertEquals(undefined, objectWithGetter.__lookupSetter__('foo')); |
| var objectWithSetter = {}; |
| objectWithSetter.__defineSetter__('foo', function(x) {}); |
| assertEquals(undefined, objectWithSetter.__lookupGetter__('foo')); |
| + |
| +// An object with a getter on the prototype chain. |
| +function getter() { return 111; } |
| +function anotherGetter() { return 222; } |
| + |
| +function testGetterOnProto(expected, o) { |
| + assertEquals(expected, o.quebec); |
| +} |
| + |
| +obj1 = {}; |
| +Object.defineProperty(obj1, "quebec", { get: getter, configurable: true }); |
| +obj2 = Object.create(obj1); |
| +obj3 = Object.create(obj2); |
| + |
| +testGetterOnProto(111, obj3); |
| +testGetterOnProto(111, obj3); |
| +%OptimizeFunctionOnNextCall(testGetterOnProto); |
| +testGetterOnProto(111, obj3); |
| +testGetterOnProto(111, obj3); |
| + |
| +Object.defineProperty(obj1, "quebec", { get: anotherGetter }); |
| + |
| +testGetterOnProto(222, obj3); |
| +testGetterOnProto(222, obj3); |
| +%OptimizeFunctionOnNextCall(testGetterOnProto); |
| +testGetterOnProto(222, obj3); |
| +testGetterOnProto(222, obj3); |
| + |
| +// An object with a setter on the prototype chain. |
| +var modifyMe; |
| +function setter(x) { modifyMe = x+1; } |
| +function anotherSetter(x) { modifyMe = x+2; } |
| + |
| +function testSetterOnProto(expected, o) { |
| + modifyMe = 333; |
| + o.romeo = 444; |
| + assertEquals(expected, modifyMe); |
| +} |
| + |
| +obj1 = {}; |
| +Object.defineProperty(obj1, "romeo", { set: setter, configurable: true }); |
| +obj2 = Object.create(obj1); |
| +obj3 = Object.create(obj2); |
| + |
| +testSetterOnProto(445, obj3); |
| +testSetterOnProto(445, obj3); |
| +%OptimizeFunctionOnNextCall(testSetterOnProto); |
| +testSetterOnProto(445, obj3); |
| +testSetterOnProto(445, obj3); |
| + |
| +Object.defineProperty(obj1, "romeo", { set: anotherSetter }); |
| + |
| +testSetterOnProto(446, obj3); |
| +testSetterOnProto(446, obj3); |
| +%OptimizeFunctionOnNextCall(testSetterOnProto); |
| +testSetterOnProto(446, obj3); |
| +testSetterOnProto(446, obj3); |
|
rossberg
2012/07/04 10:34:09
Maybe you want some additional tests here where Lo
Sven Panne
2012/07/04 11:40:24
Done.
|