michael@0: // |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: michael@0: /** michael@0: File Name: 10.2.2-2.js michael@0: ECMA Section: 10.2.2 Eval Code michael@0: Description: michael@0: michael@0: When control enters an execution context for eval code, the previous michael@0: active execution context, referred to as the calling context, is used to michael@0: determine the scope chain, the variable object, and the this value. If michael@0: there is no calling context, then initializing the scope chain, variable michael@0: instantiation, and determination of the this value are performed just as michael@0: for global code. michael@0: michael@0: The scope chain is initialized to contain the same objects, in the same michael@0: order, as the calling context's scope chain. This includes objects added michael@0: to the calling context's scope chain by WithStatement. michael@0: michael@0: Variable instantiation is performed using the calling context's variable michael@0: object and using empty property attributes. michael@0: michael@0: The this value is the same as the this value of the calling context. michael@0: michael@0: Author: christine@netscape.com michael@0: Date: 12 november 1997 michael@0: */ michael@0: michael@0: var SECTION = "10.2.2-2"; michael@0: var VERSION = "ECMA_1"; michael@0: startTest(); michael@0: var TITLE = "Eval Code"; michael@0: michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: // Test Objects michael@0: michael@0: var OBJECT = new MyObject( "hello" ); michael@0: var GLOBAL_PROPERTIES = new Array(); michael@0: var i = 0; michael@0: michael@0: for ( p in this ) { michael@0: GLOBAL_PROPERTIES[i++] = p; michael@0: } michael@0: michael@0: with ( OBJECT ) { michael@0: var THIS = this; michael@0: new TestCase( SECTION, michael@0: "eval( 'this == THIS' )", michael@0: true, michael@0: eval("this == THIS") ); michael@0: new TestCase( SECTION, michael@0: "this in a with() block", michael@0: GLOBAL, michael@0: this+"" ); michael@0: new TestCase( SECTION, michael@0: "new MyObject('hello').value", michael@0: "hello", michael@0: value ); michael@0: new TestCase( SECTION, michael@0: "eval(new MyObject('hello').value)", michael@0: "hello", michael@0: eval("value") ); michael@0: new TestCase( SECTION, michael@0: "new MyObject('hello').getClass()", michael@0: "[object Object]", michael@0: getClass() ); michael@0: new TestCase( SECTION, michael@0: "eval(new MyObject('hello').getClass())", michael@0: "[object Object]", michael@0: eval("getClass()") ); michael@0: new TestCase( SECTION, michael@0: "eval(new MyObject('hello').toString())", michael@0: "hello", michael@0: eval("toString()") ); michael@0: new TestCase( SECTION, michael@0: "eval('getClass') == Object.prototype.toString", michael@0: true, michael@0: eval("getClass") == Object.prototype.toString ); michael@0: michael@0: for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) { michael@0: new TestCase( SECTION, GLOBAL_PROPERTIES[i] + michael@0: " == THIS["+GLOBAL_PROPERTIES[i]+"]", true, michael@0: eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") ); michael@0: } michael@0: michael@0: } michael@0: michael@0: test(); michael@0: michael@0: function MyObject( value ) { michael@0: this.value = value; michael@0: this.getClass = Object.prototype.toString; michael@0: this.toString = new Function( "return this.value+''" ); michael@0: return this; michael@0: }