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.
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /**
8 File Name: 11.2.1-4-n.js
9 ECMA Section: 11.2.1 Property Accessors
10 Description:
12 Properties are accessed by name, using either the dot notation:
13 MemberExpression . Identifier
14 CallExpression . Identifier
16 or the bracket notation: MemberExpression [ Expression ]
17 CallExpression [ Expression ]
19 The dot notation is explained by the following syntactic conversion:
20 MemberExpression . Identifier
21 is identical in its behavior to
22 MemberExpression [ <identifier-string> ]
23 and similarly
24 CallExpression . Identifier
25 is identical in its behavior to
26 CallExpression [ <identifier-string> ]
27 where <identifier-string> is a string literal containing the same sequence
28 of characters as the Identifier.
30 The production MemberExpression : MemberExpression [ Expression ] is
31 evaluated as follows:
33 1. Evaluate MemberExpression.
34 2. Call GetValue(Result(1)).
35 3. Evaluate Expression.
36 4. Call GetValue(Result(3)).
37 5. Call ToObject(Result(2)).
38 6. Call ToString(Result(4)).
39 7. Return a value of type Reference whose base object is Result(5) and
40 whose property name is Result(6).
42 The production CallExpression : CallExpression [ Expression ] is evaluated
43 in exactly the same manner, except that the contained CallExpression is
44 evaluated in step 1.
46 Author: christine@netscape.com
47 Date: 12 november 1997
48 */
49 var SECTION = "11.2.1-4-n";
50 var VERSION = "ECMA_1";
51 startTest();
52 var TITLE = "Property Accessors";
53 writeHeaderToLog( SECTION + " "+TITLE );
55 // go through all Native Function objects, methods, and properties and get their typeof.
57 var PROPERTY = new Array();
58 var p = 0;
60 // try to access properties of primitive types
62 PROPERTY[p++] = new Property( "null", null, "null", 0 );
64 for ( var i = 0, RESULT; i < PROPERTY.length; i++ ) {
66 DESCRIPTION = PROPERTY[i].object + ".valueOf()";
67 EXPECTED = "error";
69 new TestCase( SECTION,
70 PROPERTY[i].object + ".valueOf()",
71 PROPERTY[i].value,
72 eval( PROPERTY[i].object+ ".valueOf()" ) );
74 new TestCase( SECTION,
75 PROPERTY[i].object + ".toString()",
76 PROPERTY[i].string,
77 eval(PROPERTY[i].object+ ".toString()") );
79 }
81 test();
83 function MyObject( value ) {
84 this.value = value;
85 this.stringValue = value +"";
86 this.numberValue = Number(value);
87 return this;
88 }
89 function Property( object, value, string, number ) {
90 this.object = object;
91 this.string = String(value);
92 this.number = Number(value);
93 this.value = value;
94 }