js/src/tests/ecma_2/Statements/try-007.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-007.js
     9  *  ECMA Section:
    10  *  Description:        The try statement
    11  *
    12  *  This test has a for-in statement within a try block.
    13  *
    14  *
    15  *  Author:             christine@netscape.com
    16  *  Date:               11 August 1998
    17  */
    18 var SECTION = "try-007";
    19 var VERSION = "ECMA_2";
    20 var TITLE   = "The try statement:  for-in";
    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 TryForIn( new TryObject( "hello", throwException, true ));
    46 TryForIn( 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  *  The check function is either throwException() or noException().
    57  *  See above.
    58  *
    59  */
    60 function TryObject( value, fun, exception ) {
    61   this.value = value;
    62   this.exception = exception;
    64   this.check = fun;
    65   this.valueOf = function () { return this.value; }
    66 }
    68 /**
    69  *  This function has a for-in statement within a try block.  Test cases
    70  *  are added after the try-catch-finally statement.  Within the for-in
    71  *  block, call a function that can throw an exception.  Verify that any
    72  *  exceptions are properly caught.
    73  */
    75 function TryForIn( object ) {
    76   try {
    77     for ( p in object ) {
    78       if ( typeof object[p] == "function" ) {
    79 	result = object[p]();
    80       }
    81     }
    82   } catch ( e ) {
    83     result = e;
    84   }
    86   new TestCase(
    87     SECTION,
    88     "TryForIn( " + object+ " )",
    89     (object.exception ? EXCEPTION_STRING +": " + object.value : object.value),
    90     result );
    92 }

mercurial