michael@0: /* michael@0: * Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/licenses/publicdomain/ michael@0: */ michael@0: michael@0: var gTestfile = 'arguments-caller-callee.js'; michael@0: var BUGNUMBER = 514563; michael@0: var summary = "arguments.caller and arguments.callee are poison pills in ES5"; michael@0: michael@0: print(BUGNUMBER + ": " + summary); michael@0: michael@0: /************** michael@0: * BEGIN TEST * michael@0: **************/ michael@0: michael@0: // behavior michael@0: michael@0: function expectTypeError(fun) michael@0: { michael@0: try michael@0: { michael@0: fun(); michael@0: throw new Error("didn't throw"); michael@0: } michael@0: catch (e) michael@0: { michael@0: assertEq(e instanceof TypeError, true, michael@0: "expected TypeError calling function" + michael@0: ("name" in fun ? " " + fun.name : "") + ", instead got: " + e); michael@0: } michael@0: } michael@0: michael@0: function bar() { "use strict"; return arguments; } michael@0: expectTypeError(function barCaller() { bar().caller; }); michael@0: expectTypeError(function barCallee() { bar().callee; }); michael@0: michael@0: function baz() { return arguments; } michael@0: assertEq(baz().callee, baz); michael@0: michael@0: michael@0: // accessor identity michael@0: michael@0: function strictMode() { "use strict"; return arguments; } michael@0: var canonicalTTE = Object.getOwnPropertyDescriptor(strictMode(), "caller").get; michael@0: michael@0: var args = strictMode(); michael@0: michael@0: var argsCaller = Object.getOwnPropertyDescriptor(args, "caller"); michael@0: assertEq("get" in argsCaller, true); michael@0: assertEq("set" in argsCaller, true); michael@0: assertEq(argsCaller.get, canonicalTTE); michael@0: assertEq(argsCaller.set, canonicalTTE); michael@0: michael@0: var argsCallee = Object.getOwnPropertyDescriptor(args, "callee"); michael@0: assertEq("get" in argsCallee, true); michael@0: assertEq("set" in argsCallee, true); michael@0: assertEq(argsCallee.get, canonicalTTE); michael@0: assertEq(argsCallee.set, canonicalTTE); michael@0: michael@0: michael@0: /******************************************************************************/ michael@0: michael@0: if (typeof reportCompare === "function") michael@0: reportCompare(true, true); michael@0: michael@0: print("All tests passed!");