summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/pic/callname-eager-this2.js
blob: 86bd740d14c4ac54c99eb7ad9cdec6b367866e86 (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
this.name = "outer";

var sb = evalcx('');
sb.name = "inner";
sb.parent = this;

var res = 0;

function f() {
    assertEq(this.name, "outer");
    res++;
}

// ff is a property of the inner global object. Generate a CALLNAME IC, then
// change ff to a function on the outer global. It should get the inner this
// value.
evalcx('this.ff = function() {};' +
      '(function() { ' +
           'eval("");' +
           'for(var i=0; i<10; i++) {' +
               'ff();' +
               'if (i == 5) ff = parent.f;' +
           '}' +
      '})()', sb);
assertEq(res, 4);