blob: 1c9446bdc0b7d60b9c429eceb5b6439f1d65027e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
// Copyright (c) 2012 Ecma International. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es5id: 15.5.4.20-2-43
description: >
String.prototype.trim - 'this' is an object with an own valueOf
and inherited toString methods with hint string, verify inherited
toString method will be called first
---*/
var toStringAccessed = false;
var valueOfAccessed = false;
var proto = {
toString: function () {
toStringAccessed = true;
return "abc";
}
};
var Con = function () { };
Con.prototype = proto;
var child = new Con();
child.valueOf = function () {
valueOfAccessed = true;
return "efg";
};
assert.sameValue(String.prototype.trim.call(child), "abc", 'String.prototype.trim.call(child)');
assert(toStringAccessed, 'toStringAccessed !== true');
assert.sameValue(valueOfAccessed, false, 'valueOfAccessed');
|