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