js/src/tests/ecma/ExecutionContexts/10.2.2-1.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma/ExecutionContexts/10.2.2-1.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,89 @@
     1.4 +// |reftest| skip-if(Android) -- bug - nsIDOMWindow.crypto throws NS_ERROR_NOT_IMPLEMENTED on Android
     1.5 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +
    1.11 +/**
    1.12 +   File Name:          10.2.2-1.js
    1.13 +   ECMA Section:       10.2.2 Eval Code
    1.14 +   Description:
    1.15 +
    1.16 +   When control enters an execution context for eval code, the previous
    1.17 +   active execution context, referred to as the calling context, is used to
    1.18 +   determine the scope chain, the variable object, and the this value. If
    1.19 +   there is no calling context, then initializing the scope chain, variable
    1.20 +   instantiation, and determination of the this value are performed just as
    1.21 +   for global code.
    1.22 +
    1.23 +   The scope chain is initialized to contain the same objects, in the same
    1.24 +   order, as the calling context's scope chain.  This includes objects added
    1.25 +   to the calling context's scope chain by WithStatement.
    1.26 +
    1.27 +   Variable instantiation is performed using the calling context's variable
    1.28 +   object and using empty property attributes.
    1.29 +
    1.30 +   The this value is the same as the this value of the calling context.
    1.31 +
    1.32 +   Author:             christine@netscape.com
    1.33 +   Date:               12 november 1997
    1.34 +*/
    1.35 +
    1.36 +var SECTION = "10.2.2-1";
    1.37 +var VERSION = "ECMA_1";
    1.38 +startTest();
    1.39 +var TITLE   = "Eval Code";
    1.40 +
    1.41 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.42 +
    1.43 +var THIS = eval("this");
    1.44 +
    1.45 +new TestCase( SECTION,
    1.46 +	      "this +''",
    1.47 +	      GLOBAL,
    1.48 +	      THIS + "" );
    1.49 +
    1.50 +var GLOBAL_PROPERTIES = new Array();
    1.51 +var i = 0;
    1.52 +
    1.53 +for ( p in THIS ) {
    1.54 +  GLOBAL_PROPERTIES[i++] = p;
    1.55 +}
    1.56 +
    1.57 +for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) {
    1.58 +  new TestCase( SECTION,
    1.59 +		GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]",
    1.60 +		true,
    1.61 +		eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") );
    1.62 +}
    1.63 +
    1.64 +//  this in eval statements is the same as this value of the calling context
    1.65 +
    1.66 +var RESULT = THIS == this;
    1.67 +
    1.68 +new TestCase( SECTION,
    1.69 +	      "eval( 'this == THIS' )",
    1.70 +	      true,
    1.71 +	      RESULT );
    1.72 +
    1.73 +var RESULT = THIS +'';
    1.74 +
    1.75 +new TestCase( SECTION,
    1.76 +	      "eval( 'this + \"\"' )",
    1.77 +	      GLOBAL,
    1.78 +	      RESULT );
    1.79 +
    1.80 +
    1.81 +new TestCase( SECTION,
    1.82 +	      "eval( 'this == THIS' )",
    1.83 +	      true,
    1.84 +	      eval( "this == THIS" ) );
    1.85 +
    1.86 +new TestCase( SECTION,
    1.87 +	      "eval( 'this + \"\"' )",
    1.88 +	      GLOBAL,
    1.89 +	      eval( "this +''") );
    1.90 +
    1.91 +
    1.92 +test();

mercurial