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: 11.2.1-1.js |
michael@0 | 9 | ECMA Section: 11.2.1 Property Accessors |
michael@0 | 10 | Description: |
michael@0 | 11 | |
michael@0 | 12 | Properties are accessed by name, using either the dot notation: |
michael@0 | 13 | MemberExpression . Identifier |
michael@0 | 14 | CallExpression . Identifier |
michael@0 | 15 | |
michael@0 | 16 | or the bracket notation: MemberExpression [ Expression ] |
michael@0 | 17 | CallExpression [ Expression ] |
michael@0 | 18 | |
michael@0 | 19 | The dot notation is explained by the following syntactic conversion: |
michael@0 | 20 | MemberExpression . Identifier |
michael@0 | 21 | is identical in its behavior to |
michael@0 | 22 | MemberExpression [ <identifier-string> ] |
michael@0 | 23 | and similarly |
michael@0 | 24 | CallExpression . Identifier |
michael@0 | 25 | is identical in its behavior to |
michael@0 | 26 | CallExpression [ <identifier-string> ] |
michael@0 | 27 | where <identifier-string> is a string literal containing the same sequence |
michael@0 | 28 | of characters as the Identifier. |
michael@0 | 29 | |
michael@0 | 30 | The production MemberExpression : MemberExpression [ Expression ] is |
michael@0 | 31 | evaluated as follows: |
michael@0 | 32 | |
michael@0 | 33 | 1. Evaluate MemberExpression. |
michael@0 | 34 | 2. Call GetValue(Result(1)). |
michael@0 | 35 | 3. Evaluate Expression. |
michael@0 | 36 | 4. Call GetValue(Result(3)). |
michael@0 | 37 | 5. Call ToObject(Result(2)). |
michael@0 | 38 | 6. Call ToString(Result(4)). |
michael@0 | 39 | 7. Return a value of type Reference whose base object is Result(5) and |
michael@0 | 40 | whose property name is Result(6). |
michael@0 | 41 | |
michael@0 | 42 | The production CallExpression : CallExpression [ Expression ] is evaluated |
michael@0 | 43 | in exactly the same manner, except that the contained CallExpression is |
michael@0 | 44 | evaluated in step 1. |
michael@0 | 45 | |
michael@0 | 46 | Author: christine@netscape.com |
michael@0 | 47 | Date: 12 november 1997 |
michael@0 | 48 | */ |
michael@0 | 49 | var SECTION = "11.2.1-1"; |
michael@0 | 50 | var VERSION = "ECMA_1"; |
michael@0 | 51 | startTest(); |
michael@0 | 52 | var TITLE = "Property Accessors"; |
michael@0 | 53 | writeHeaderToLog( SECTION + " "+TITLE ); |
michael@0 | 54 | |
michael@0 | 55 | // go through all Native Function objects, methods, and properties and get their typeof. |
michael@0 | 56 | |
michael@0 | 57 | var PROPERTY = new Array(); |
michael@0 | 58 | var p = 0; |
michael@0 | 59 | |
michael@0 | 60 | // properties and functions of the global object |
michael@0 | 61 | |
michael@0 | 62 | PROPERTY[p++] = new Property( "this", "NaN", "number" ); |
michael@0 | 63 | PROPERTY[p++] = new Property( "this", "Infinity", "number" ); |
michael@0 | 64 | PROPERTY[p++] = new Property( "this", "eval", "function" ); |
michael@0 | 65 | PROPERTY[p++] = new Property( "this", "parseInt", "function" ); |
michael@0 | 66 | PROPERTY[p++] = new Property( "this", "parseFloat", "function" ); |
michael@0 | 67 | PROPERTY[p++] = new Property( "this", "escape", "function" ); |
michael@0 | 68 | PROPERTY[p++] = new Property( "this", "unescape", "function" ); |
michael@0 | 69 | PROPERTY[p++] = new Property( "this", "isNaN", "function" ); |
michael@0 | 70 | PROPERTY[p++] = new Property( "this", "isFinite", "function" ); |
michael@0 | 71 | PROPERTY[p++] = new Property( "this", "Object", "function" ); |
michael@0 | 72 | PROPERTY[p++] = new Property( "this", "Number", "function" ); |
michael@0 | 73 | PROPERTY[p++] = new Property( "this", "Function", "function" ); |
michael@0 | 74 | PROPERTY[p++] = new Property( "this", "Array", "function" ); |
michael@0 | 75 | PROPERTY[p++] = new Property( "this", "String", "function" ); |
michael@0 | 76 | PROPERTY[p++] = new Property( "this", "Boolean", "function" ); |
michael@0 | 77 | PROPERTY[p++] = new Property( "this", "Date", "function" ); |
michael@0 | 78 | PROPERTY[p++] = new Property( "this", "Math", "object" ); |
michael@0 | 79 | |
michael@0 | 80 | // properties and methods of Object objects |
michael@0 | 81 | |
michael@0 | 82 | PROPERTY[p++] = new Property( "Object", "prototype", "object" ); |
michael@0 | 83 | PROPERTY[p++] = new Property( "Object", "toString", "function" ); |
michael@0 | 84 | PROPERTY[p++] = new Property( "Object", "valueOf", "function" ); |
michael@0 | 85 | PROPERTY[p++] = new Property( "Object", "constructor", "function" ); |
michael@0 | 86 | |
michael@0 | 87 | // properties of the Function object |
michael@0 | 88 | |
michael@0 | 89 | PROPERTY[p++] = new Property( "Function", "prototype", "function" ); |
michael@0 | 90 | PROPERTY[p++] = new Property( "Function.prototype", "toString", "function" ); |
michael@0 | 91 | PROPERTY[p++] = new Property( "Function.prototype", "length", "number" ); |
michael@0 | 92 | PROPERTY[p++] = new Property( "Function.prototype", "valueOf", "function" ); |
michael@0 | 93 | |
michael@0 | 94 | Function.prototype.myProperty = "hi"; |
michael@0 | 95 | |
michael@0 | 96 | PROPERTY[p++] = new Property( "Function.prototype", "myProperty", "string" ); |
michael@0 | 97 | |
michael@0 | 98 | // properties of the Array object |
michael@0 | 99 | PROPERTY[p++] = new Property( "Array", "prototype", "object" ); |
michael@0 | 100 | PROPERTY[p++] = new Property( "Array", "length", "number" ); |
michael@0 | 101 | PROPERTY[p++] = new Property( "Array.prototype", "constructor", "function" ); |
michael@0 | 102 | PROPERTY[p++] = new Property( "Array.prototype", "toString", "function" ); |
michael@0 | 103 | PROPERTY[p++] = new Property( "Array.prototype", "join", "function" ); |
michael@0 | 104 | PROPERTY[p++] = new Property( "Array.prototype", "reverse", "function" ); |
michael@0 | 105 | PROPERTY[p++] = new Property( "Array.prototype", "sort", "function" ); |
michael@0 | 106 | |
michael@0 | 107 | // properties of the String object |
michael@0 | 108 | PROPERTY[p++] = new Property( "String", "prototype", "object" ); |
michael@0 | 109 | PROPERTY[p++] = new Property( "String", "fromCharCode", "function" ); |
michael@0 | 110 | PROPERTY[p++] = new Property( "String.prototype", "toString", "function" ); |
michael@0 | 111 | PROPERTY[p++] = new Property( "String.prototype", "constructor", "function" ); |
michael@0 | 112 | PROPERTY[p++] = new Property( "String.prototype", "valueOf", "function" ); |
michael@0 | 113 | PROPERTY[p++] = new Property( "String.prototype", "charAt", "function" ); |
michael@0 | 114 | PROPERTY[p++] = new Property( "String.prototype", "charCodeAt", "function" ); |
michael@0 | 115 | PROPERTY[p++] = new Property( "String.prototype", "indexOf", "function" ); |
michael@0 | 116 | PROPERTY[p++] = new Property( "String.prototype", "lastIndexOf", "function" ); |
michael@0 | 117 | PROPERTY[p++] = new Property( "String.prototype", "split", "function" ); |
michael@0 | 118 | PROPERTY[p++] = new Property( "String.prototype", "substring", "function" ); |
michael@0 | 119 | PROPERTY[p++] = new Property( "String.prototype", "toLowerCase", "function" ); |
michael@0 | 120 | PROPERTY[p++] = new Property( "String.prototype", "toUpperCase", "function" ); |
michael@0 | 121 | PROPERTY[p++] = new Property( "String.prototype", "length", "number" ); |
michael@0 | 122 | |
michael@0 | 123 | // properties of the Boolean object |
michael@0 | 124 | PROPERTY[p++] = new Property( "Boolean", "prototype", "object" ); |
michael@0 | 125 | PROPERTY[p++] = new Property( "Boolean", "constructor", "function" ); |
michael@0 | 126 | PROPERTY[p++] = new Property( "Boolean.prototype", "valueOf", "function" ); |
michael@0 | 127 | PROPERTY[p++] = new Property( "Boolean.prototype", "toString", "function" ); |
michael@0 | 128 | |
michael@0 | 129 | // properties of the Number object |
michael@0 | 130 | |
michael@0 | 131 | PROPERTY[p++] = new Property( "Number", "MAX_VALUE", "number" ); |
michael@0 | 132 | PROPERTY[p++] = new Property( "Number", "MIN_VALUE", "number" ); |
michael@0 | 133 | PROPERTY[p++] = new Property( "Number", "NaN", "number" ); |
michael@0 | 134 | PROPERTY[p++] = new Property( "Number", "NEGATIVE_INFINITY", "number" ); |
michael@0 | 135 | PROPERTY[p++] = new Property( "Number", "POSITIVE_INFINITY", "number" ); |
michael@0 | 136 | PROPERTY[p++] = new Property( "Number.prototype", "toString", "function" ); |
michael@0 | 137 | PROPERTY[p++] = new Property( "Number.prototype", "constructor", "function" ); |
michael@0 | 138 | PROPERTY[p++] = new Property( "Number.prototype", "valueOf", "function" ); |
michael@0 | 139 | |
michael@0 | 140 | // properties of the Math Object. |
michael@0 | 141 | PROPERTY[p++] = new Property( "Math", "E", "number" ); |
michael@0 | 142 | PROPERTY[p++] = new Property( "Math", "LN10", "number" ); |
michael@0 | 143 | PROPERTY[p++] = new Property( "Math", "LN2", "number" ); |
michael@0 | 144 | PROPERTY[p++] = new Property( "Math", "LOG2E", "number" ); |
michael@0 | 145 | PROPERTY[p++] = new Property( "Math", "LOG10E", "number" ); |
michael@0 | 146 | PROPERTY[p++] = new Property( "Math", "PI", "number" ); |
michael@0 | 147 | PROPERTY[p++] = new Property( "Math", "SQRT1_2", "number" ); |
michael@0 | 148 | PROPERTY[p++] = new Property( "Math", "SQRT2", "number" ); |
michael@0 | 149 | PROPERTY[p++] = new Property( "Math", "abs", "function" ); |
michael@0 | 150 | PROPERTY[p++] = new Property( "Math", "acos", "function" ); |
michael@0 | 151 | PROPERTY[p++] = new Property( "Math", "asin", "function" ); |
michael@0 | 152 | PROPERTY[p++] = new Property( "Math", "atan", "function" ); |
michael@0 | 153 | PROPERTY[p++] = new Property( "Math", "atan2", "function" ); |
michael@0 | 154 | PROPERTY[p++] = new Property( "Math", "ceil", "function" ); |
michael@0 | 155 | PROPERTY[p++] = new Property( "Math", "cos", "function" ); |
michael@0 | 156 | PROPERTY[p++] = new Property( "Math", "exp", "function" ); |
michael@0 | 157 | PROPERTY[p++] = new Property( "Math", "floor", "function" ); |
michael@0 | 158 | PROPERTY[p++] = new Property( "Math", "log", "function" ); |
michael@0 | 159 | PROPERTY[p++] = new Property( "Math", "max", "function" ); |
michael@0 | 160 | PROPERTY[p++] = new Property( "Math", "min", "function" ); |
michael@0 | 161 | PROPERTY[p++] = new Property( "Math", "pow", "function" ); |
michael@0 | 162 | PROPERTY[p++] = new Property( "Math", "random", "function" ); |
michael@0 | 163 | PROPERTY[p++] = new Property( "Math", "round", "function" ); |
michael@0 | 164 | PROPERTY[p++] = new Property( "Math", "sin", "function" ); |
michael@0 | 165 | PROPERTY[p++] = new Property( "Math", "sqrt", "function" ); |
michael@0 | 166 | PROPERTY[p++] = new Property( "Math", "tan", "function" ); |
michael@0 | 167 | |
michael@0 | 168 | // properties of the Date object |
michael@0 | 169 | PROPERTY[p++] = new Property( "Date", "parse", "function" ); |
michael@0 | 170 | PROPERTY[p++] = new Property( "Date", "prototype", "object" ); |
michael@0 | 171 | PROPERTY[p++] = new Property( "Date", "UTC", "function" ); |
michael@0 | 172 | PROPERTY[p++] = new Property( "Date.prototype", "constructor", "function" ); |
michael@0 | 173 | PROPERTY[p++] = new Property( "Date.prototype", "toString", "function" ); |
michael@0 | 174 | PROPERTY[p++] = new Property( "Date.prototype", "valueOf", "function" ); |
michael@0 | 175 | PROPERTY[p++] = new Property( "Date.prototype", "getTime", "function" ); |
michael@0 | 176 | PROPERTY[p++] = new Property( "Date.prototype", "getYear", "function" ); |
michael@0 | 177 | PROPERTY[p++] = new Property( "Date.prototype", "getFullYear", "function" ); |
michael@0 | 178 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCFullYear", "function" ); |
michael@0 | 179 | PROPERTY[p++] = new Property( "Date.prototype", "getMonth", "function" ); |
michael@0 | 180 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCMonth", "function" ); |
michael@0 | 181 | PROPERTY[p++] = new Property( "Date.prototype", "getDate", "function" ); |
michael@0 | 182 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCDate", "function" ); |
michael@0 | 183 | PROPERTY[p++] = new Property( "Date.prototype", "getDay", "function" ); |
michael@0 | 184 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCDay", "function" ); |
michael@0 | 185 | PROPERTY[p++] = new Property( "Date.prototype", "getHours", "function" ); |
michael@0 | 186 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCHours", "function" ); |
michael@0 | 187 | PROPERTY[p++] = new Property( "Date.prototype", "getMinutes", "function" ); |
michael@0 | 188 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCMinutes", "function" ); |
michael@0 | 189 | PROPERTY[p++] = new Property( "Date.prototype", "getSeconds", "function" ); |
michael@0 | 190 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCSeconds", "function" ); |
michael@0 | 191 | PROPERTY[p++] = new Property( "Date.prototype", "getMilliseconds","function" ); |
michael@0 | 192 | PROPERTY[p++] = new Property( "Date.prototype", "getUTCMilliseconds", "function" ); |
michael@0 | 193 | PROPERTY[p++] = new Property( "Date.prototype", "setTime", "function" ); |
michael@0 | 194 | PROPERTY[p++] = new Property( "Date.prototype", "setMilliseconds","function" ); |
michael@0 | 195 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCMilliseconds", "function" ); |
michael@0 | 196 | PROPERTY[p++] = new Property( "Date.prototype", "setSeconds", "function" ); |
michael@0 | 197 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCSeconds", "function" ); |
michael@0 | 198 | PROPERTY[p++] = new Property( "Date.prototype", "setMinutes", "function" ); |
michael@0 | 199 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCMinutes", "function" ); |
michael@0 | 200 | PROPERTY[p++] = new Property( "Date.prototype", "setHours", "function" ); |
michael@0 | 201 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCHours", "function" ); |
michael@0 | 202 | PROPERTY[p++] = new Property( "Date.prototype", "setDate", "function" ); |
michael@0 | 203 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCDate", "function" ); |
michael@0 | 204 | PROPERTY[p++] = new Property( "Date.prototype", "setMonth", "function" ); |
michael@0 | 205 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCMonth", "function" ); |
michael@0 | 206 | PROPERTY[p++] = new Property( "Date.prototype", "setFullYear", "function" ); |
michael@0 | 207 | PROPERTY[p++] = new Property( "Date.prototype", "setUTCFullYear", "function" ); |
michael@0 | 208 | PROPERTY[p++] = new Property( "Date.prototype", "setYear", "function" ); |
michael@0 | 209 | PROPERTY[p++] = new Property( "Date.prototype", "toLocaleString", "function" ); |
michael@0 | 210 | PROPERTY[p++] = new Property( "Date.prototype", "toUTCString", "function" ); |
michael@0 | 211 | PROPERTY[p++] = new Property( "Date.prototype", "toGMTString", "function" ); |
michael@0 | 212 | |
michael@0 | 213 | for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { |
michael@0 | 214 | RESULT = eval("typeof " + PROPERTY[i].object + "." + PROPERTY[i].name ); |
michael@0 | 215 | |
michael@0 | 216 | new TestCase( SECTION, |
michael@0 | 217 | "typeof " + PROPERTY[i].object + "." + PROPERTY[i].name, |
michael@0 | 218 | PROPERTY[i].type, |
michael@0 | 219 | RESULT ); |
michael@0 | 220 | |
michael@0 | 221 | RESULT = eval("typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']"); |
michael@0 | 222 | |
michael@0 | 223 | new TestCase( SECTION, |
michael@0 | 224 | "typeof " + PROPERTY[i].object + "['" + PROPERTY[i].name +"']", |
michael@0 | 225 | PROPERTY[i].type, |
michael@0 | 226 | RESULT ); |
michael@0 | 227 | } |
michael@0 | 228 | |
michael@0 | 229 | test(); |
michael@0 | 230 | |
michael@0 | 231 | function MyObject( arg0, arg1, arg2, arg3, arg4 ) { |
michael@0 | 232 | this.name = arg0; |
michael@0 | 233 | } |
michael@0 | 234 | function Property( object, name, type ) { |
michael@0 | 235 | this.object = object; |
michael@0 | 236 | this.name = name; |
michael@0 | 237 | this.type = type; |
michael@0 | 238 | } |