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-2 |
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-2"; |
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 | // Tests for anonymous functions |
michael@0 | 51 | |
michael@0 | 52 | var GetCallee = new Function( "var c = arguments.callee; return c" ); |
michael@0 | 53 | var GetArguments = new Function( "var a = arguments; return a" ); |
michael@0 | 54 | var GetLength = new Function( "var l = arguments.length; return l" ); |
michael@0 | 55 | |
michael@0 | 56 | var ARG_STRING = "value of the argument property"; |
michael@0 | 57 | |
michael@0 | 58 | new TestCase( SECTION, |
michael@0 | 59 | "GetCallee()", |
michael@0 | 60 | GetCallee, |
michael@0 | 61 | GetCallee() ); |
michael@0 | 62 | |
michael@0 | 63 | var LIMIT = 100; |
michael@0 | 64 | |
michael@0 | 65 | for ( var i = 0, args = "" ; i < LIMIT; i++ ) { |
michael@0 | 66 | args += String(i) + ( i+1 < LIMIT ? "," : "" ); |
michael@0 | 67 | |
michael@0 | 68 | } |
michael@0 | 69 | |
michael@0 | 70 | var LENGTH = eval( "GetLength("+ args +")" ); |
michael@0 | 71 | |
michael@0 | 72 | new TestCase( SECTION, |
michael@0 | 73 | "GetLength("+args+")", |
michael@0 | 74 | 100, |
michael@0 | 75 | LENGTH ); |
michael@0 | 76 | |
michael@0 | 77 | var ARGUMENTS = eval( "GetArguments( " +args+")" ); |
michael@0 | 78 | |
michael@0 | 79 | for ( var i = 0; i < 100; i++ ) { |
michael@0 | 80 | new TestCase( SECTION, |
michael@0 | 81 | "GetArguments("+args+")["+i+"]", |
michael@0 | 82 | i, |
michael@0 | 83 | ARGUMENTS[i] ); |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | test(); |