js/src/tests/ecma_5/strict/this-for-function-expression-recursion.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /*
     2  * Any copyright is dedicated to the Public Domain.
     3  * http://creativecommons.org/licenses/publicdomain/
     4  */
     6 var gTestfile = 'this-for-function-expression-recursion.js';
     7 var BUGNUMBER = 611276;
     8 var summary = "JSOP_CALLEE should push undefined, not null, for this";
    10 print(BUGNUMBER + ": " + summary);
    12 /**************
    13  * BEGIN TEST *
    14  **************/
    16 // Calling a named function expression (not function statement) uses the
    17 // JSOP_CALLEE opcode.  This opcode pushes its own |this|, distinct from the
    18 // normal call path; verify that that |this| value is properly |undefined|.
    20 var calleeThisFun =
    21   function calleeThisFun(recurring)
    22   {
    23     if (recurring)
    24       return this;
    25     return calleeThisFun(true);
    26   };
    27 assertEq(calleeThisFun(false), this);
    29 var calleeThisStrictFun =
    30   function calleeThisStrictFun(recurring)
    31   {
    32     "use strict";
    33     if (recurring)
    34       return this;
    35     return calleeThisStrictFun(true);
    36   };
    37 assertEq(calleeThisStrictFun(false), undefined);
    39 /******************************************************************************/
    41 if (typeof reportCompare === "function")
    42   reportCompare(true, true);
    44 print("All tests passed!");

mercurial