15.2.3.6-4-7.js (1045B)
1 // Copyright (c) 2012 Ecma International. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 info: | 6 Step 4 of defineProperty calls the [[DefineOwnProperty]] internal method 7 of O to define the property. Step 7a of [[DefineOwnProperty]] rejects if 8 current.[[Configurable]] is false and desc.[[Configurable]] is true. 9 es5id: 15.2.3.6-4-7 10 description: > 11 Object.defineProperty throws TypeError when changing 12 [[Configurable]] from false to true 13 ---*/ 14 15 var o = {}; 16 17 // create a data valued property; all other attributes default to false. 18 var d1 = { 19 value: 101, 20 configurable: false 21 }; 22 Object.defineProperty(o, "foo", d1); 23 24 var desc = { 25 value: 101, 26 configurable: true 27 }; 28 assert.throws(TypeError, function() { 29 Object.defineProperty(o, "foo", desc); 30 }); 31 // the property should remain unchanged. 32 var d2 = Object.getOwnPropertyDescriptor(o, "foo"); 33 assert.sameValue(d2.value, 101, 'd2.value'); 34 assert.sameValue(d2.configurable, false, 'd2.configurable'); 35 36 reportCompare(0, 0);