js/src/tests/ecma_2/Statements/try-006.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-006.js
     9  *  ECMA Section:
    10  *  Description:        The try statement
    11  *
    12  *  Throw an exception from within a With block in a try block.  Verify
    13  *  that any expected exceptions are caught.
    14  *
    15  *  Author:             christine@netscape.com
    16  *  Date:               11 August 1998
    17  */
    18 var SECTION = "try-006";
    19 var VERSION = "ECMA_2";
    20 var TITLE   = "The try statement";
    22 startTest();
    23 writeHeaderToLog( SECTION + " "+ TITLE);
    25 /**
    26  *  This is the "check" function for test objects that will
    27  *  throw an exception.
    28  */
    29 function throwException() {
    30   throw EXCEPTION_STRING +": " + this.valueOf();
    31 }
    32 var EXCEPTION_STRING = "Exception thrown:";
    34 /**
    35  *  This is the "check" function for test objects that do not
    36  *  throw an exception
    37  */
    38 function noException() {
    39   return this.valueOf();
    40 }
    42 /**
    43  *  Add test cases here
    44  */
    45 TryWith( new TryObject( "hello", throwException, true ));
    46 TryWith( new TryObject( "hola",  noException, false ));
    48 /**
    49  *  Run the test.
    50  */
    52 test();
    54 /**
    55  *  This is the object that will be the "this" in a with block.
    56  */
    57 function TryObject( value, fun, exception ) {
    58   this.value = value;
    59   this.exception = exception;
    61   this.valueOf = new Function ( "return this.value" );
    62   this.check = fun;
    63 }
    65 /**
    66  *  This function has the try block that has a with block within it.
    67  *  Test cases are added in this function.  Within the with block, the
    68  *  object's "check" function is called.  If the test object's exception
    69  *  property is true, we expect the result to be the exception value.
    70  *  If exception is false, then we expect the result to be the value of
    71  *  the object.
    72  */
    73 function TryWith( object ) {
    74   try {
    75     with ( object ) {
    76       result = check();
    77     }
    78   } catch ( e ) {
    79     result = e;
    80   }
    82   new TestCase(
    83     SECTION,
    84     "TryWith( " + object.value +" )",
    85     (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()),
    86     result );
    87 }

mercurial