resultdesc-is-not-configurable-targetdesc-is-undefined.js (1381B)
1 // Copyright (C) 2015 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 /*--- 4 es6id: 9.5.5 5 description: > 6 Throws a TypeError exception if trap result is not configurable but target 7 property descriptor is undefined. 8 info: | 9 [[GetOwnProperty]] (P) 10 11 ... 12 2. Let handler be the value of the [[ProxyHandler]] internal slot of O. 13 ... 14 5. Let target be the value of the [[ProxyTarget]] internal slot of O. 15 6. Let trap be GetMethod(handler, "getOwnPropertyDescriptor"). 16 ... 17 9. Let trapResultObj be Call(trap, handler, «target, P»). 18 ... 19 12. Let targetDesc be target.[[GetOwnProperty]](P). 20 ... 21 17. Let resultDesc be ToPropertyDescriptor(trapResultObj). 22 ... 23 22. If resultDesc.[[Configurable]] is false, then 24 a. If targetDesc is undefined or targetDesc.[[Configurable]] is true, then 25 i. Throw a TypeError exception. 26 27 features: [Proxy] 28 ---*/ 29 30 var target = {}; 31 32 var p = new Proxy(target, { 33 getOwnPropertyDescriptor: function(t, prop) { 34 var foo = {}; 35 36 Object.defineProperty(foo, "bar", { 37 configurable: false, 38 enumerable: true, 39 value: 1 40 }); 41 42 return Object.getOwnPropertyDescriptor(foo, prop); 43 } 44 }); 45 46 assert.throws(TypeError, function() { 47 Object.getOwnPropertyDescriptor(p, "bar"); 48 }); 49 50 reportCompare(0, 0);