target-property-is-not-configurable-not-writable-not-equal-to-v.js (1033B)
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.9 5 description: > 6 [[Set]] ( P, V, Receiver) 7 8 Throws a TypeError when target property is not configurable neither writable 9 and its value is not strictly equal to V. 10 info: | 11 14. If targetDesc is not undefined, then 12 a. If IsDataDescriptor(targetDesc) and targetDesc.[[Configurable]] is 13 false and targetDesc.[[Writable]] is false, then 14 i. If SameValue(V, targetDesc.[[Value]]) is false, throw a TypeError 15 exception. 16 features: [Proxy] 17 ---*/ 18 19 var target = {}; 20 var handler = { 21 set: function(t, prop, value, receiver) { 22 return true; 23 } 24 }; 25 var p = new Proxy(target, handler); 26 27 Object.defineProperty(target, 'attr', { 28 configurable: false, 29 writable: false, 30 value: 'foo' 31 }); 32 33 assert.throws(TypeError, function() { 34 p.attr = 'bar'; 35 }); 36 37 assert.throws(TypeError, function() { 38 p['attr'] = 'bar'; 39 }); 40 41 reportCompare(0, 0);