resultdesc-is-invalid-descriptor.js (841B)
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 and target property descriptors 7 are not compatible. 8 info: | 9 [[GetOwnProperty]] (P) 10 11 ... 12 20. Let valid be IsCompatiblePropertyDescriptor (extensibleTarget, 13 resultDesc, targetDesc). 14 21. If valid is false, throw a TypeError exception. 15 features: [Proxy] 16 ---*/ 17 18 var target = {}; 19 20 var p = new Proxy(target, { 21 getOwnPropertyDescriptor: function(t, prop) { 22 var foo = { 23 bar: 1 24 }; 25 26 return Object.getOwnPropertyDescriptor(foo, "bar"); 27 } 28 }); 29 30 Object.preventExtensions(target); 31 32 assert.throws(TypeError, function() { 33 Object.getOwnPropertyDescriptor(p, "bar"); 34 }); 35 36 reportCompare(0, 0);