michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 10.1.6 michael@0: ECMA Section: Activation Object michael@0: Description: michael@0: michael@0: If the function object being invoked has an arguments property, let x be michael@0: the value of that property; the activation object is also given an internal michael@0: property [[OldArguments]] whose initial value is x; otherwise, an arguments michael@0: property is created for the function object but the activation object is michael@0: not given an [[OldArguments]] property. Next, arguments object described michael@0: below (the same one stored in the arguments property of the activation michael@0: object) is used as the new value of the arguments property of the function michael@0: object. This new value is installed even if the arguments property already michael@0: exists and has the ReadOnly attribute (as it will for native Function michael@0: objects). (These actions are taken to provide compatibility with a form of michael@0: program syntax that is now discouraged: to access the arguments object for michael@0: function f within the body of f by using the expression f.arguments. michael@0: The recommended way to access the arguments object for function f within michael@0: the body of f is simply to refer to the variable arguments.) michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 12 november 1997 michael@0: */ michael@0: michael@0: var SECTION = "10.1.6"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Activation Object"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: var arguments = "FAILED!"; michael@0: michael@0: var ARG_STRING = "value of the argument property"; michael@0: michael@0: new TestCase( SECTION, michael@0: "(new TestObject(0,1,2,3,4,5)).length", michael@0: 6, michael@0: (new TestObject(0,1,2,3,4,5)).length ); michael@0: michael@0: for ( i = 0; i < 6; i++ ) { michael@0: michael@0: new TestCase( SECTION, michael@0: "(new TestObject(0,1,2,3,4,5))["+i+"]", michael@0: i, michael@0: (new TestObject(0,1,2,3,4,5))[i]); michael@0: } michael@0: michael@0: michael@0: // The current object already has an arguments property. michael@0: michael@0: new TestCase( SECTION, michael@0: "(new AnotherTestObject(1,2,3)).arguments", michael@0: ARG_STRING, michael@0: (new AnotherTestObject(1,2,3)).arguments ); michael@0: michael@0: // The function invoked with [[Call]] michael@0: michael@0: new TestCase( SECTION, michael@0: "TestFunction(1,2,3)", michael@0: ARG_STRING, michael@0: TestFunction() + '' ); michael@0: michael@0: michael@0: test(); michael@0: michael@0: michael@0: michael@0: function Prototype() { michael@0: this.arguments = ARG_STRING; michael@0: } michael@0: function TestObject() { michael@0: this.__proto__ = new Prototype(); michael@0: return arguments; michael@0: } michael@0: function AnotherTestObject() { michael@0: this.__proto__ = new Prototype(); michael@0: return this; michael@0: } michael@0: function TestFunction() { michael@0: arguments = ARG_STRING; michael@0: return arguments; michael@0: } michael@0: function AnotherTestFunction() { michael@0: this.__proto__ = new Prototype(); michael@0: return this; michael@0: }