blob: e2bd7f076d3b2515407ccfd2a7477caf83ae37f4 (
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
|
// Test that the generic call tramponline handles cross-realm calls.
function foo(f) {
return f(1);
}
function foo_call(f) {
return f.call({}, 1);
}
with ({}) {}
var g = newGlobal({sameCompartmentAs: this});
g.eval(`
function f1(x) { return x; }
var f2 = f1.bind({});
var f3 = Math.log;
`);
var f1 = g.f1;
var f2 = g.f2;
var f3 = g.f3;
var f4 = f1.bind({});
var f5 = f2.bind({});
var f6 = f3.bind({});
for (var i = 0; i < 500; i++) {
assertEq(foo(f1), 1);
assertEq(foo(f2), 1);
assertEq(foo(f3), 0);
assertEq(foo(f4), 1);
assertEq(foo(f5), 1);
assertEq(foo(f6), 0);
assertEq(foo_call(f1), 1);
assertEq(foo_call(f2), 1);
assertEq(foo_call(f3), 0);
assertEq(foo_call(f4), 1);
assertEq(foo_call(f5), 1);
assertEq(foo_call(f6), 0);
}
|