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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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-1.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-1";
    34 var VERSION = "ECMA_1";
    35 startTest();
    36 var TITLE   = "Eval Code";
    38 writeHeaderToLog( SECTION + " "+ TITLE);
    40 var THIS = eval("this");
    42 new TestCase( SECTION,
    43 	      "this +''",
    44 	      GLOBAL,
    45 	      THIS + "" );
    47 var GLOBAL_PROPERTIES = new Array();
    48 var i = 0;
    50 for ( p in THIS ) {
    51   GLOBAL_PROPERTIES[i++] = p;
    52 }
    54 for ( i = 0; i < GLOBAL_PROPERTIES.length; i++ ) {
    55   new TestCase( SECTION,
    56 		GLOBAL_PROPERTIES[i] +" == THIS["+GLOBAL_PROPERTIES[i]+"]",
    57 		true,
    58 		eval(GLOBAL_PROPERTIES[i]) == eval( "THIS[GLOBAL_PROPERTIES[i]]") );
    59 }
    61 //  this in eval statements is the same as this value of the calling context
    63 var RESULT = THIS == this;
    65 new TestCase( SECTION,
    66 	      "eval( 'this == THIS' )",
    67 	      true,
    68 	      RESULT );
    70 var RESULT = THIS +'';
    72 new TestCase( SECTION,
    73 	      "eval( 'this + \"\"' )",
    74 	      GLOBAL,
    75 	      RESULT );
    78 new TestCase( SECTION,
    79 	      "eval( 'this == THIS' )",
    80 	      true,
    81 	      eval( "this == THIS" ) );
    83 new TestCase( SECTION,
    84 	      "eval( 'this + \"\"' )",
    85 	      GLOBAL,
    86 	      eval( "this +''") );
    89 test();

mercurial