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.8 |
michael@0 | 9 | ECMA Section: Arguments Object |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | When control enters an execution context for declared function code, |
michael@0 | 13 | anonymous code, or implementation-supplied code, an arguments object is |
michael@0 | 14 | created and initialized as follows: |
michael@0 | 15 | |
michael@0 | 16 | The [[Prototype]] of the arguments object is to the original Object |
michael@0 | 17 | prototype object, the one that is the initial value of Object.prototype |
michael@0 | 18 | (section 15.2.3.1). |
michael@0 | 19 | |
michael@0 | 20 | A property is created with name callee and property attributes {DontEnum}. |
michael@0 | 21 | The initial value of this property is the function object being executed. |
michael@0 | 22 | This allows anonymous functions to be recursive. |
michael@0 | 23 | |
michael@0 | 24 | A property is created with name length and property attributes {DontEnum}. |
michael@0 | 25 | The initial value of this property is the number of actual parameter values |
michael@0 | 26 | supplied by the caller. |
michael@0 | 27 | |
michael@0 | 28 | For each non-negative integer, iarg, less than the value of the length |
michael@0 | 29 | property, a property is created with name ToString(iarg) and property |
michael@0 | 30 | attributes { DontEnum }. The initial value of this property is the value |
michael@0 | 31 | of the corresponding actual parameter supplied by the caller. The first |
michael@0 | 32 | actual parameter value corresponds to iarg = 0, the second to iarg = 1 and |
michael@0 | 33 | so on. In the case when iarg is less than the number of formal parameters |
michael@0 | 34 | for the function object, this property shares its value with the |
michael@0 | 35 | corresponding property of the activation object. This means that changing |
michael@0 | 36 | this property changes the corresponding property of the activation object |
michael@0 | 37 | and vice versa. The value sharing mechanism depends on the implementation. |
michael@0 | 38 | |
michael@0 | 39 | Author: christine@netscape.com |
michael@0 | 40 | Date: 12 november 1997 |
michael@0 | 41 | */ |
michael@0 | 42 | |
michael@0 | 43 | var SECTION = "10.1.8"; |
michael@0 | 44 | var VERSION = "ECMA_1"; |
michael@0 | 45 | startTest(); |
michael@0 | 46 | var TITLE = "Arguments Object"; |
michael@0 | 47 | |
michael@0 | 48 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 49 | |
michael@0 | 50 | var ARG_STRING = "value of the argument property"; |
michael@0 | 51 | |
michael@0 | 52 | new TestCase( SECTION, |
michael@0 | 53 | "GetCallee()", |
michael@0 | 54 | GetCallee, |
michael@0 | 55 | GetCallee() ); |
michael@0 | 56 | |
michael@0 | 57 | var LIMIT = 100; |
michael@0 | 58 | |
michael@0 | 59 | for ( var i = 0, args = "" ; i < LIMIT; i++ ) { |
michael@0 | 60 | args += String(i) + ( i+1 < LIMIT ? "," : "" ); |
michael@0 | 61 | |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | var LENGTH = eval( "GetLength("+ args +")" ); |
michael@0 | 65 | |
michael@0 | 66 | new TestCase( SECTION, |
michael@0 | 67 | "GetLength("+args+")", |
michael@0 | 68 | 100, |
michael@0 | 69 | LENGTH ); |
michael@0 | 70 | |
michael@0 | 71 | var ARGUMENTS = eval( "GetArguments( " +args+")" ); |
michael@0 | 72 | |
michael@0 | 73 | for ( var i = 0; i < 100; i++ ) { |
michael@0 | 74 | new TestCase( SECTION, |
michael@0 | 75 | "GetArguments("+args+")["+i+"]", |
michael@0 | 76 | i, |
michael@0 | 77 | ARGUMENTS[i] ); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | test(); |
michael@0 | 81 | |
michael@0 | 82 | function TestFunction() { |
michael@0 | 83 | var arg_proto = arguments.__proto__; |
michael@0 | 84 | } |
michael@0 | 85 | function GetCallee() { |
michael@0 | 86 | var c = arguments.callee; |
michael@0 | 87 | return c; |
michael@0 | 88 | } |
michael@0 | 89 | function GetArguments() { |
michael@0 | 90 | var a = arguments; |
michael@0 | 91 | return a; |
michael@0 | 92 | } |
michael@0 | 93 | function GetLength() { |
michael@0 | 94 | var l = arguments.length; |
michael@0 | 95 | return l; |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | function AnotherTestFunction() { |
michael@0 | 99 | this.__proto__ = new Prototype(); |
michael@0 | 100 | return this; |
michael@0 | 101 | } |