| 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-147 |
| 6 |
description: > |
| 7 |
Object.defineProperties - 'O' is an Array, 'name' is the length |
| 8 |
property of 'O', test using inherited valueOf method when the |
| 9 |
[[Value]] field of 'desc' is an Objec with an own toString and |
| 10 |
inherited valueOf methods (15.4.5.1 step 3.c) |
| 11 |
---*/ |
| 12 |
|
| 13 |
var arr = []; |
| 14 |
var toStringAccessed = false; |
| 15 |
var valueOfAccessed = false; |
| 16 |
|
| 17 |
var proto = { |
| 18 |
value: { |
| 19 |
valueOf: function() { |
| 20 |
valueOfAccessed = true; |
| 21 |
return 2; |
| 22 |
} |
| 23 |
} |
| 24 |
}; |
| 25 |
|
| 26 |
var Con = function() {}; |
| 27 |
Con.prototype = proto; |
| 28 |
|
| 29 |
var child = new Con(); |
| 30 |
Object.defineProperty(child, "value", { |
| 31 |
value: { |
| 32 |
toString: function() { |
| 33 |
toStringAccessed = true; |
| 34 |
return 3; |
| 35 |
} |
| 36 |
} |
| 37 |
}); |
| 38 |
|
| 39 |
Object.defineProperties(arr, { |
| 40 |
length: child |
| 41 |
}); |
| 42 |
|
| 43 |
assert.sameValue(arr.length, 3, 'arr.length'); |
| 44 |
assert(toStringAccessed, 'toStringAccessed !== true'); |
| 45 |
assert.sameValue(valueOfAccessed, false, 'valueOfAccessed'); |