js/src/tests/ecma_2/Statements/try-009.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:          try-009.js
     9  *  ECMA Section:
    10  *  Description:        The try statement
    11  *
    12  *  This test has a try block within a while block.  Verify that an exception
    13  *  breaks out of the while.  I don't really know why this is an interesting
    14  *  test case but Mike Shaver had two of these so what the hey.
    15  *
    16  *  Author:             christine@netscape.com
    17  *  Date:               11 August 1998
    18  */
    19 var SECTION = "try-009";
    20 var VERSION = "ECMA_2";
    21 var TITLE   = "The try statement: try in a while block";
    23 startTest();
    24 writeHeaderToLog( SECTION + " "+ TITLE);
    26 var EXCEPTION_STRING = "Exception thrown: ";
    27 var NO_EXCEPTION_STRING = "No exception thrown: ";
    30 TryInWhile( new TryObject( "hello", ThrowException, true ) );
    31 TryInWhile( new TryObject( "aloha", NoException, false ));
    33 test();
    35 function TryObject( value, throwFunction, result ) {
    36   this.value = value;
    37   this.thrower = throwFunction;
    38   this.result = result;
    39 }
    40 function ThrowException() {
    41   throw EXCEPTION_STRING + this.value;
    42 }
    43 function NoException() {
    44   return NO_EXCEPTION_STRING + this.value;
    45 }
    46 function TryInWhile( object ) {
    47   result = null;
    48   while ( true ) {
    49     try {
    50       object.thrower();
    51       result = NO_EXCEPTION_STRING + object.value;
    52       break;
    53     } catch ( e ) {
    54       result = e;
    55       break;
    56     }
    57   }
    59   new TestCase(
    60     SECTION,
    61     "( "+ object  +".thrower() )",
    62     (object.result
    63      ? EXCEPTION_STRING + object.value :
    64      NO_EXCEPTION_STRING + object.value),
    65     result );
    66 }

mercurial