blob: d572aaf243a169b7787b36cabf7ceb7166f193b4 (
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
Function.prototype.callX = Function.prototype.call;
var x;
function f() {
x = f.caller;
return x;
}
function g() {
return f.callX(null);
}
function h1() {
// native
return ([0].map(f))[0];
}
function h2() {
// self-hosted
x = null;
[0].forEach(f);
return x;
}
function k() {
x = null;
[0, 1].sort(f);
return x;
}
function l() {
return f();
}
assertEq(g(), g);
assertEq(h1(), h1);
assertEq(h2(), h2);
assertEq(k(), k);
assertEq(l(), l);
var baz;
var foo = {callX: function() { return "m"; }};
function bar() {
return baz.caller;
}
function m() {
return baz.callX(null);
}
baz = foo;
assertEq(m(), "m");
baz = bar;
assertEq(m(), m);
assertEq(m(), m);
|