15.2.3.6-4-540-6.js (1578B)
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 es5id: 15.2.3.6-4-540-6 6 description: > 7 Object.defineProperty fails to update [[Get]] and [[Set]] 8 attributes of an indexed accessor property 'P' whose 9 [[Configurable]] attribute is false and throws TypeError 10 exception, 'O' is an Object object (8.12.9 step 11.a) 11 includes: [propertyHelper.js] 12 ---*/ 13 14 var obj = {}; 15 16 obj.verifySetFunction = "data"; 17 var getFunc = function() { 18 return obj.verifySetFunction; 19 }; 20 var setFunc = function(value) { 21 obj.verifySetFunction = value; 22 }; 23 Object.defineProperty(obj, "0", { 24 get: getFunc, 25 set: setFunc, 26 configurable: false 27 }); 28 29 var result = false; 30 try { 31 Object.defineProperty(obj, "0", { 32 get: function() { 33 return 100; 34 } 35 }); 36 } catch (e) { 37 result = e instanceof TypeError; 38 39 verifyEqualTo(obj, "0", getFunc()); 40 41 verifyWritable(obj, "0", "verifySetFunction"); 42 } 43 44 verifyProperty(obj, "0", { 45 enumerable: false, 46 configurable: false, 47 }); 48 49 try { 50 Object.defineProperty(obj, "0", { 51 set: function(value) { 52 obj.verifySetFunction1 = value; 53 } 54 }); 55 } catch (e) { 56 if (!result) { 57 throw new Test262Error('Expected result to be true, actually ' + result); 58 } 59 60 verifyEqualTo(obj, "0", getFunc()); 61 62 verifyWritable(obj, "0", "verifySetFunction"); 63 64 if (!(e instanceof TypeError)) { 65 throw new Test262Error("Expected TypeError, got " + e); 66 } 67 } 68 69 verifyProperty(obj, "0", { 70 enumerable: false, 71 configurable: false, 72 }); 73 74 reportCompare(0, 0);