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 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 /*
7 * Date: 08 August 2001
8 *
9 * SUMMARY: When we invoke a function, the arguments object should take
10 * a back seat to any local identifier named "arguments".
11 *
12 * See http://bugzilla.mozilla.org/show_bug.cgi?id=94506
13 */
14 //-----------------------------------------------------------------------------
15 var UBound = 0;
16 var BUGNUMBER = 94506;
17 var summary = 'Testing functions employing identifiers named "arguments"';
18 var status = '';
19 var statusitems = [];
20 var actual = '';
21 var actualvalues = [];
22 var expect= '';
23 var expectedvalues = [];
24 var TYPE_OBJECT = typeof new Object();
25 var arguments = 5555;
28 // use a parameter named "arguments"
29 function F1(arguments)
30 {
31 return arguments;
32 }
35 // use a local variable named "arguments"
36 function F2()
37 {
38 var arguments = 55;
39 return arguments;
40 }
43 // same thing in a different order. CHANGES THE RESULT!
44 function F3()
45 {
46 return arguments;
47 var arguments = 555;
48 }
51 // use the global variable above named "arguments"
52 function F4()
53 {
54 return arguments;
55 }
59 /*
60 * In Sections 1 and 2, expect the local identifier, not the arguments object.
61 * In Sections 3 and 4, expect the arguments object, not the the identifier.
62 */
64 status = 'Section 1 of test';
65 actual = F1(5);
66 expect = 5;
67 addThis();
70 status = 'Section 2 of test';
71 actual = F2();
72 expect = 55;
73 addThis();
76 status = 'Section 3 of test';
77 actual = typeof F3();
78 expect = TYPE_OBJECT;
79 addThis();
82 status = 'Section 4 of test';
83 actual = typeof F4();
84 expect = TYPE_OBJECT;
85 addThis();
88 // Let's try calling F1 without providing a parameter -
89 status = 'Section 5 of test';
90 actual = F1();
91 expect = undefined;
92 addThis();
95 // Let's try calling F1 with too many parameters -
96 status = 'Section 6 of test';
97 actual = F1(3,33,333);
98 expect = 3;
99 addThis();
103 //-----------------------------------------------------------------------------
104 test();
105 //-----------------------------------------------------------------------------
108 function addThis()
109 {
110 statusitems[UBound] = status;
111 actualvalues[UBound] = actual;
112 expectedvalues[UBound] = expect;
113 UBound++;
114 }
117 function test()
118 {
119 enterFunc ('test');
120 printBugNumber(BUGNUMBER);
121 printStatus (summary);
123 for (var i = 0; i < UBound; i++)
124 {
125 reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
126 }
128 exitFunc ('test');
129 }