not-extensible-new-keys-throws.js (720B)
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 esid: sec-proxy-object-internal-methods-and-internal-slots-ownpropertykeys 5 description: > 6 If target is not extensible, the result can't contain keys names not 7 contained in the target object. 8 info: | 9 [[OwnPropertyKeys]] ( ) 10 11 ... 12 20. If uncheckedResultKeys is not empty, throw a TypeError exception. 13 features: [Proxy] 14 ---*/ 15 16 var target = { 17 foo: 1 18 }; 19 20 var p = new Proxy(target, { 21 ownKeys: function() { 22 return ["foo", "bar"]; 23 } 24 }); 25 26 Object.preventExtensions(target); 27 28 assert.throws(TypeError, function() { 29 Object.keys(p); 30 }); 31 32 reportCompare(0, 0);