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

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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:          10.1.4-1.js
     9    ECMA Section:       10.1.4 Scope Chain and Identifier Resolution
    10    Description:
    11    Every execution context has associated with it a scope chain. This is
    12    logically a list of objects that are searched when binding an Identifier.
    13    When control enters an execution context, the scope chain is created and
    14    is populated with an initial set of objects, depending on the type of
    15    code. When control leaves the execution context, the scope chain is
    16    destroyed.
    18    During execution, the scope chain of the execution context is affected
    19    only by WithStatement. When execution enters a with block, the object
    20    specified in the with statement is added to the front of the scope chain.
    21    When execution leaves a with block, whether normally or via a break or
    22    continue statement, the object is removed from the scope chain. The object
    23    being removed will always be the first object in the scope chain.
    25    During execution, the syntactic production PrimaryExpression : Identifier
    26    is evaluated using the following algorithm:
    28    1.  Get the next object in the scope chain. If there isn't one, go to step 5.
    29    2.  Call the [[HasProperty]] method of Result(l), passing the Identifier as
    30    the property.
    31    3.  If Result(2) is true, return a value of type Reference whose base object
    32    is Result(l) and whose property name is the Identifier.
    33    4.  Go to step 1.
    34    5.  Return a value of type Reference whose base object is null and whose
    35    property name is the Identifier.
    36    The result of binding an identifier is always a value of type Reference with
    37    its member name component equal to the identifier string.
    38    Author:             christine@netscape.com
    39    Date:               12 november 1997
    40 */
    41 var SECTION = "10.1.4-1";
    42 var VERSION = "ECMA_1";
    43 startTest();
    45 writeHeaderToLog( SECTION + " Scope Chain and Identifier Resolution");
    47 new TestCase( "SECTION", "with MyObject, eval should return square of " );
    49 test();
    51 function test() {
    52   for ( gTc=0; gTc < gTestcases.length; gTc++ ) {
    54     var MYOBJECT = new MyObject();
    55     var INPUT = 2;
    56     gTestcases[gTc].description += "( " + INPUT +" )" ;
    58     with ( MYOBJECT ) {
    59       gTestcases[gTc].actual = eval( INPUT );
    60       gTestcases[gTc].expect = Math.pow(INPUT,2);
    61     }
    63     gTestcases[gTc].passed = writeTestCaseResult(
    64       gTestcases[gTc].expect,
    65       gTestcases[gTc].actual,
    66       gTestcases[gTc].description +" = "+
    67       gTestcases[gTc].actual );
    69     gTestcases[gTc].reason += ( gTestcases[gTc].passed ) ? "" : "wrong value ";
    70   }
    71   stopTest();
    72   return ( gTestcases );
    73 }
    75 function MyObject() {
    76   this.eval = new Function( "x", "return(Math.pow(Number(x),2))" );
    77 }

mercurial