15.2.3.6-4-491.js (1267B)
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-491 6 description: > 7 ES5 Attributes - fail to update [[Enumerable]] attribute of 8 accessor property ([[Get]] is undefined, [[Set]] is a Function, 9 [[Enumerable]] is false, [[Configurable]] is false) to different 10 value 11 ---*/ 12 13 var obj = {}; 14 15 var verifySetFunc = "data"; 16 var setFunc = function(value) { 17 verifySetFunc = value; 18 }; 19 20 Object.defineProperty(obj, "prop", { 21 get: undefined, 22 set: setFunc, 23 enumerable: false, 24 configurable: false 25 }); 26 27 var result1 = false; 28 var desc1 = Object.getOwnPropertyDescriptor(obj, "prop"); 29 for (var p1 in obj) { 30 if (p1 === "prop") { 31 result1 = true; 32 } 33 } 34 assert.throws(TypeError, function() { 35 Object.defineProperty(obj, "prop", { 36 enumerable: true 37 }); 38 }); 39 var result2 = false; 40 var desc2 = Object.getOwnPropertyDescriptor(obj, "prop"); 41 for (var p2 in obj) { 42 if (p2 === "prop") { 43 result2 = true; 44 } 45 } 46 47 assert.sameValue(result1, false, 'result1'); 48 assert.sameValue(result2, false, 'result2'); 49 assert.sameValue(desc1.enumerable, false, 'desc1.enumerable'); 50 assert.sameValue(desc2.enumerable, false, 'desc2.enumerable'); 51 52 reportCompare(0, 0);