Wed, 31 Dec 2014 06:09:35 +0100
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 = '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);
12 /**************
13 * BEGIN TEST *
14 **************/
16 // behavior
18 function expectTypeError(fun)
19 {
20 try
21 {
22 fun();
23 throw new Error("didn't throw");
24 }
25 catch (e)
26 {
27 assertEq(e instanceof TypeError, true,
28 "expected TypeError calling function" +
29 ("name" in fun ? " " + fun.name : "") + ", instead got: " + e);
30 }
31 }
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);
41 // accessor identity
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!");