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