15.2.3.7-6-a-146.js (962B)
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.7-6-a-146 6 description: > 7 Object.defineProperties - 'O' is an Array, 'name' is the length 8 property of 'O', test TypeError is thrown when the [[Value]] field 9 of 'desc' is an Object that both toString and valueOf wouldn't 10 return primitive value (15.4.5.1 step 3.c) 11 ---*/ 12 13 var arr = []; 14 var toStringAccessed = false; 15 var valueOfAccessed = false; 16 assert.throws(TypeError, function() { 17 Object.defineProperties(arr, { 18 length: { 19 value: { 20 toString: function() { 21 toStringAccessed = true; 22 return {}; 23 }, 24 25 valueOf: function() { 26 valueOfAccessed = true; 27 return {}; 28 } 29 } 30 } 31 }); 32 }); 33 assert(toStringAccessed, 'toStringAccessed !== true'); 34 assert(valueOfAccessed, 'valueOfAccessed !== true'); 35 36 reportCompare(0, 0);