15.2.3.6-2-47.js (787B)
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-2-47 6 description: > 7 Object.defineProperty - TypeError exception is thrown when 'P' is 8 an object that neither toString nor valueOf returns a primitive 9 value 10 ---*/ 11 12 var obj = {}; 13 var toStringAccessed = false; 14 var valueOfAccessed = false; 15 16 var ownProp = { 17 toString: function() { 18 toStringAccessed = true; 19 return {}; 20 }, 21 valueOf: function() { 22 valueOfAccessed = true; 23 return {}; 24 } 25 }; 26 assert.throws(TypeError, function() { 27 Object.defineProperty(obj, ownProp, {}); 28 }); 29 assert(valueOfAccessed, 'valueOfAccessed !== true'); 30 assert(toStringAccessed, 'toStringAccessed !== true'); 31 32 reportCompare(0, 0);