targetdesc-not-compatible-descriptor-realm.js (1032B)
1 // Copyright (C) 2016 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-defineownproperty-p-desc 5 description: > 6 Throw a TypeError exception if Desc and target property descriptor are not 7 compatible and trap result is true (honoring the realm of the current 8 execution context). 9 info: | 10 [[DefineOwnProperty]] (P, Desc) 11 12 ... 13 20. Else targetDesc is not undefined, 14 a. If IsCompatiblePropertyDescriptor(extensibleTarget, Desc , 15 targetDesc) is false, throw a TypeError exception. 16 ... 17 features: [cross-realm, Proxy] 18 ---*/ 19 20 var OProxy = $262.createRealm().global.Proxy; 21 var target = Object.create(null); 22 var p = new OProxy(target, { 23 defineProperty: function() { 24 return true; 25 } 26 }); 27 28 Object.defineProperty(target, 'prop', { 29 value: 1 30 }); 31 32 assert.throws(TypeError, function() { 33 Object.defineProperty(p, 'prop', { 34 value: 2 35 }); 36 }); 37 38 reportCompare(0, 0);