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-4-n.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-4-n"; |
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 | // try to access properties of primitive types |
michael@0 | 61 | |
michael@0 | 62 | PROPERTY[p++] = new Property( "null", null, "null", 0 ); |
michael@0 | 63 | |
michael@0 | 64 | for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) { |
michael@0 | 65 | |
michael@0 | 66 | DESCRIPTION = PROPERTY[i].object + ".valueOf()"; |
michael@0 | 67 | EXPECTED = "error"; |
michael@0 | 68 | |
michael@0 | 69 | new TestCase( SECTION, |
michael@0 | 70 | PROPERTY[i].object + ".valueOf()", |
michael@0 | 71 | PROPERTY[i].value, |
michael@0 | 72 | eval( PROPERTY[i].object+ ".valueOf()" ) ); |
michael@0 | 73 | |
michael@0 | 74 | new TestCase( SECTION, |
michael@0 | 75 | PROPERTY[i].object + ".toString()", |
michael@0 | 76 | PROPERTY[i].string, |
michael@0 | 77 | eval(PROPERTY[i].object+ ".toString()") ); |
michael@0 | 78 | |
michael@0 | 79 | } |
michael@0 | 80 | |
michael@0 | 81 | test(); |
michael@0 | 82 | |
michael@0 | 83 | function MyObject( value ) { |
michael@0 | 84 | this.value = value; |
michael@0 | 85 | this.stringValue = value +""; |
michael@0 | 86 | this.numberValue = Number(value); |
michael@0 | 87 | return this; |
michael@0 | 88 | } |
michael@0 | 89 | function Property( object, value, string, number ) { |
michael@0 | 90 | this.object = object; |
michael@0 | 91 | this.string = String(value); |
michael@0 | 92 | this.number = Number(value); |
michael@0 | 93 | this.value = value; |
michael@0 | 94 | } |