2
* Any copyright is dedicated to the Public Domain.
3
* http://creativecommons.org/licenses/publicdomain/
6
var gTestfile = 'arguments-caller-callee.js';
7
var BUGNUMBER = 514563;
8
var summary = "arguments.caller and arguments.callee are poison pills in ES5";
10
print(BUGNUMBER + ": " + summary);
18
function expectTypeError(fun)
23
throw new Error("didn't throw");
27
assertEq(e instanceof TypeError, true,
28
"expected TypeError calling function" +
29
("name" in fun ? " " + fun.name : "") + ", instead got: " + e);
33
function bar() { "use strict"; return arguments; }
34
expectTypeError(function barCaller() { bar().caller; });
35
expectTypeError(function barCallee() { bar().callee; });
37
function baz() { return arguments; }
38
assertEq(baz().callee, baz);
43
function strictMode() { "use strict"; return arguments; }
44
var canonicalTTE = Object.getOwnPropertyDescriptor(strictMode(), "caller").get;
46
var args = strictMode();
48
var argsCaller = Object.getOwnPropertyDescriptor(args, "caller");
49
assertEq("get" in argsCaller, true);
50
assertEq("set" in argsCaller, true);
51
assertEq(argsCaller.get, canonicalTTE);
52
assertEq(argsCaller.set, canonicalTTE);
54
var argsCallee = Object.getOwnPropertyDescriptor(args, "callee");
55
assertEq("get" in argsCallee, true);
56
assertEq("set" in argsCallee, true);
57
assertEq(argsCallee.get, canonicalTTE);
58
assertEq(argsCallee.set, canonicalTTE);
61
/******************************************************************************/
63
if (typeof reportCompare === "function")
64
reportCompare(true, true);
66
print("All tests passed!");