1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_5/strict/this-for-function-expression-recursion.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* 1.5 + * Any copyright is dedicated to the Public Domain. 1.6 + * http://creativecommons.org/licenses/publicdomain/ 1.7 + */ 1.8 + 1.9 +var gTestfile = 'this-for-function-expression-recursion.js'; 1.10 +var BUGNUMBER = 611276; 1.11 +var summary = "JSOP_CALLEE should push undefined, not null, for this"; 1.12 + 1.13 +print(BUGNUMBER + ": " + summary); 1.14 + 1.15 +/************** 1.16 + * BEGIN TEST * 1.17 + **************/ 1.18 + 1.19 +// Calling a named function expression (not function statement) uses the 1.20 +// JSOP_CALLEE opcode. This opcode pushes its own |this|, distinct from the 1.21 +// normal call path; verify that that |this| value is properly |undefined|. 1.22 + 1.23 +var calleeThisFun = 1.24 + function calleeThisFun(recurring) 1.25 + { 1.26 + if (recurring) 1.27 + return this; 1.28 + return calleeThisFun(true); 1.29 + }; 1.30 +assertEq(calleeThisFun(false), this); 1.31 + 1.32 +var calleeThisStrictFun = 1.33 + function calleeThisStrictFun(recurring) 1.34 + { 1.35 + "use strict"; 1.36 + if (recurring) 1.37 + return this; 1.38 + return calleeThisStrictFun(true); 1.39 + }; 1.40 +assertEq(calleeThisStrictFun(false), undefined); 1.41 + 1.42 +/******************************************************************************/ 1.43 + 1.44 +if (typeof reportCompare === "function") 1.45 + reportCompare(true, true); 1.46 + 1.47 +print("All tests passed!");