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 // |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android
2 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 /**
9 File Name: 10.2.2-2.js
10 ECMA Section: 10.2.2 Eval Code
11 Description:
13 When control enters an execution context for eval code, the previous
14 active execution context, referred to as the calling context, is used to
15 determine the scope chain, the variable object, and the this value. If
16 there is no calling context, then initializing the scope chain, variable
17 instantiation, and determination of the this value are performed just as
18 for global code.
20 The scope chain is initialized to contain the same objects, in the same
21 order, as the calling context's scope chain. This includes objects added
22 to the calling context's scope chain by WithStatement.
24 Variable instantiation is performed using the calling context's variable
25 object and using empty property attributes.
27 The this value is the same as the this value of the calling context.
29 Author: christine@netscape.com
30 Date: 12 november 1997
31 */
33 var SECTION = "10.2.2-2";
34 var VERSION = "ECMA_1";
35 startTest();
36 var TITLE = "Eval Code";
38 writeHeaderToLog( SECTION + " "+ TITLE);
40 // Test Objects
42 var OBJECT = new MyObject( "hello" );
43 var GLOBAL_PROPERTIES = new Array();
44 var i = 0;
46 for ( p in this ) {
47 GLOBAL_PROPERTIES[i++] = p;
48 }
50 with ( OBJECT ) {
51 var THIS = this;
52 new TestCase( SECTION,
53 "eval( 'this == THIS' )",
54 true,
55 eval("this == THIS") );
56 new TestCase( SECTION,
57 "this in a with() block",
58 GLOBAL,
59 this+"" );
60 new TestCase( SECTION,
61 "new MyObject('hello').value",
62 "hello",
63 value );
64 new TestCase( SECTION,
65 "eval(new MyObject('hello').value)",
66 "hello",
67 eval("value") );
68 new TestCase( SECTION,
69 "new MyObject('hello').getClass()",
70 "[object Object]",
71 getClass() );
72 new TestCase( SECTION,
73 "eval(new MyObject('hello').getClass())",
74 "[object Object]",
75 eval("getClass()") );
76 new TestCase( SECTION,
77 "eval(new MyObject('hello').toString())",
78 "hello",
79 eval("toString()") );
80 new TestCase( SECTION,
81 "eval('getClass') == Object.prototype.toString",
82 true,
83 eval("getClass") == Object.prototype.toString );
85 for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) {
86 new TestCase( SECTION, GLOBAL_PROPERTIES[i] +
87 " == THIS["+GLOBAL_PROPERTIES[i]+"]", true,
88 eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") );
89 }
91 }
93 test();
95 function MyObject( value ) {
96 this.value = value;
97 this.getClass = Object.prototype.toString;
98 this.toString = new Function( "return this.value+''" );
99 return this;
100 }