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: 10.1.6
9 ECMA Section: Activation Object
10 Description:
12 If the function object being invoked has an arguments property, let x be
13 the value of that property; the activation object is also given an internal
14 property [[OldArguments]] whose initial value is x; otherwise, an arguments
15 property is created for the function object but the activation object is
16 not given an [[OldArguments]] property. Next, arguments object described
17 below (the same one stored in the arguments property of the activation
18 object) is used as the new value of the arguments property of the function
19 object. This new value is installed even if the arguments property already
20 exists and has the ReadOnly attribute (as it will for native Function
21 objects). (These actions are taken to provide compatibility with a form of
22 program syntax that is now discouraged: to access the arguments object for
23 function f within the body of f by using the expression f.arguments.
24 The recommended way to access the arguments object for function f within
25 the body of f is simply to refer to the variable arguments.)
27 Author: christine@netscape.com
28 Date: 12 november 1997
29 */
31 var SECTION = "10.1.6";
32 var VERSION = "ECMA_1";
33 startTest();
34 var TITLE = "Activation Object";
36 writeHeaderToLog( SECTION + " "+ TITLE);
38 var arguments = "FAILED!";
40 var ARG_STRING = "value of the argument property";
42 new TestCase( SECTION,
43 "(new TestObject(0,1,2,3,4,5)).length",
44 6,
45 (new TestObject(0,1,2,3,4,5)).length );
47 for ( i = 0; i < 6; i++ ) {
49 new TestCase( SECTION,
50 "(new TestObject(0,1,2,3,4,5))["+i+"]",
51 i,
52 (new TestObject(0,1,2,3,4,5))[i]);
53 }
56 // The current object already has an arguments property.
58 new TestCase( SECTION,
59 "(new AnotherTestObject(1,2,3)).arguments",
60 ARG_STRING,
61 (new AnotherTestObject(1,2,3)).arguments );
63 // The function invoked with [[Call]]
65 new TestCase( SECTION,
66 "TestFunction(1,2,3)",
67 ARG_STRING,
68 TestFunction() + '' );
71 test();
75 function Prototype() {
76 this.arguments = ARG_STRING;
77 }
78 function TestObject() {
79 this.__proto__ = new Prototype();
80 return arguments;
81 }
82 function AnotherTestObject() {
83 this.__proto__ = new Prototype();
84 return this;
85 }
86 function TestFunction() {
87 arguments = ARG_STRING;
88 return arguments;
89 }
90 function AnotherTestFunction() {
91 this.__proto__ = new Prototype();
92 return this;
93 }