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/. */
7 /**
8 File Name: 15.3.1.1-2.js
9 ECMA Section: 15.3.1.1 The Function Constructor Called as a Function
10 Function(p1, p2, ..., pn, body )
12 Description:
13 When the Function function is called with some arguments p1, p2, . . . , pn,
14 body (where n might be 0, that is, there are no "p" arguments, and where body
15 might also not be provided), the following steps are taken:
17 1. Create and return a new Function object exactly if the function constructor
18 had been called with the same arguments (15.3.2.1).
20 Author: christine@netscape.com
21 Date: 28 october 1997
23 */
24 var SECTION = "15.3.1.1-2";
25 var VERSION = "ECMA_1";
26 startTest();
27 var TITLE = "The Function Constructor Called as a Function";
29 writeHeaderToLog( SECTION + " "+ TITLE);
31 var myfunc1 = Function("a","b","c", "return a+b+c" );
32 var myfunc2 = Function("a, b, c", "return a+b+c" );
33 var myfunc3 = Function("a,b", "c", "return a+b+c" );
35 myfunc1.toString = Object.prototype.toString;
36 myfunc2.toString = Object.prototype.toString;
37 myfunc3.toString = Object.prototype.toString;
39 new TestCase( SECTION,
40 "myfunc1 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()",
41 "[object Function]",
42 myfunc1.toString() );
44 new TestCase( SECTION,
45 "myfunc1.length",
46 3,
47 myfunc1.length );
49 new TestCase( SECTION,
50 "myfunc1.prototype.toString()",
51 "[object Object]",
52 myfunc1.prototype.toString() );
54 new TestCase( SECTION,
55 "myfunc1.prototype.constructor",
56 myfunc1,
57 myfunc1.prototype.constructor );
59 new TestCase( SECTION,
60 "myfunc1.arguments",
61 null,
62 myfunc1.arguments );
64 new TestCase( SECTION,
65 "myfunc1(1,2,3)",
66 6,
67 myfunc1(1,2,3) );
69 new TestCase( SECTION,
70 "var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS",
71 "",
72 eval("var MYPROPS = ''; for ( var p in myfunc1.prototype ) { MYPROPS += p; }; MYPROPS") );
74 new TestCase( SECTION,
75 "myfunc2 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()",
76 "[object Function]",
77 myfunc2.toString() );
79 new TestCase( SECTION,
80 "myfunc2.length",
81 3,
82 myfunc2.length );
84 new TestCase( SECTION,
85 "myfunc2.prototype.toString()",
86 "[object Object]",
87 myfunc2.prototype.toString() );
89 new TestCase( SECTION,
90 "myfunc2.prototype.constructor",
91 myfunc2,
92 myfunc2.prototype.constructor );
94 new TestCase( SECTION,
95 "myfunc2.arguments",
96 null,
97 myfunc2.arguments );
99 new TestCase( SECTION,
100 "myfunc2( 1000, 200, 30 )",
101 1230,
102 myfunc2(1000,200,30) );
104 new TestCase( SECTION,
105 "var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS",
106 "",
107 eval("var MYPROPS = ''; for ( var p in myfunc2.prototype ) { MYPROPS += p; }; MYPROPS") );
109 new TestCase( SECTION,
110 "myfunc3 = Function('a','b','c'); myfunc.toString = Object.prototype.toString; myfunc.toString()",
111 "[object Function]",
112 myfunc3.toString() );
114 new TestCase( SECTION,
115 "myfunc3.length",
116 3,
117 myfunc3.length );
119 new TestCase( SECTION,
120 "myfunc3.prototype.toString()",
121 "[object Object]",
122 myfunc3.prototype.toString() );
124 new TestCase( SECTION,
125 "myfunc3.prototype.valueOf() +''",
126 "[object Object]",
127 myfunc3.prototype.valueOf() +'' );
129 new TestCase( SECTION,
130 "myfunc3.prototype.constructor",
131 myfunc3,
132 myfunc3.prototype.constructor );
134 new TestCase( SECTION,
135 "myfunc3.arguments",
136 null,
137 myfunc3.arguments );
139 new TestCase( SECTION,
140 "myfunc3(-100,100,NaN)",
141 Number.NaN,
142 myfunc3(-100,100,NaN) );
144 new TestCase( SECTION,
145 "var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS",
146 "",
147 eval("var MYPROPS = ''; for ( var p in myfunc3.prototype ) { MYPROPS += p; }; MYPROPS") );
149 test();