js/src/jit-test/tests/pic/callname-eager-this2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/jit-test/tests/pic/callname-eager-this2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,25 @@
     1.4 +this.name = "outer";
     1.5 +
     1.6 +var sb = evalcx('');
     1.7 +sb.name = "inner";
     1.8 +sb.parent = this;
     1.9 +
    1.10 +var res = 0;
    1.11 +
    1.12 +function f() {
    1.13 +    assertEq(this.name, "outer");
    1.14 +    res++;
    1.15 +}
    1.16 +
    1.17 +// ff is a property of the inner global object. Generate a CALLNAME IC, then
    1.18 +// change ff to a function on the outer global. It should get the inner this
    1.19 +// value.
    1.20 +evalcx('this.ff = function() {};' +
    1.21 +      '(function() { ' +
    1.22 +           'eval("");' +
    1.23 +           'for(var i=0; i<10; i++) {' +
    1.24 +               'ff();' +
    1.25 +               'if (i == 5) ff = parent.f;' +
    1.26 +           '}' +
    1.27 +      '})()', sb);
    1.28 +assertEq(res, 4);

mercurial