accessor-get-is-undefined-throws.js (938B)
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.8 5 description: > 6 [[Get]] (P, Receiver) 7 8 if trap result is not undefined, then proxy must report the same value for a 9 non-configurable accessor property with an undefined get. 10 info: | 11 13. If targetDesc is not undefined, then 12 b. If IsAccessorDescriptor(targetDesc) and targetDesc.[[Configurable]] 13 is false and targetDesc.[[Get]] is undefined, then 14 i. If trapResult is not undefined, throw a TypeError exception. 15 16 features: [Proxy] 17 ---*/ 18 19 var target = {}; 20 var p = new Proxy(target, { 21 get: function() { 22 return 2; 23 } 24 }); 25 26 Object.defineProperty(target, 'attr', { 27 configurable: false, 28 get: undefined 29 }); 30 31 assert.throws(TypeError, function() { 32 p.attr; 33 }); 34 35 assert.throws(TypeError, function() { 36 p['attr']; 37 }); 38 39 reportCompare(0, 0);