js/src/tests/ecma_2/Statements/switch-004.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:          switch-003.js
     9  *  ECMA Section:
    10  *  Description:        The switch Statement
    11  *
    12  *  This uses variables and objects as case expressions in switch statements.
    13  * This verifies a bunch of bugs:
    14  *
    15  * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988
    16  * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975
    17  * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954
    18  *
    19  *  Author:             christine@netscape.com
    20  *  Date:               11 August 1998
    21  *
    22  */
    23 var SECTION = "switch-003";
    24 var VERSION = "ECMA_2";
    25 var TITLE   = "The switch statement";
    26 var BUGNUMBER= "315988";
    28 startTest();
    29 writeHeaderToLog( SECTION + " "+ TITLE);
    31 ONE = new Number(1);
    32 ZERO = new Number(0);
    33 var A = new String("A");
    34 var B = new String("B");
    35 TRUE = new Boolean( true );
    36 FALSE = new Boolean( false );
    37 UNDEFINED  = void 0;
    38 NULL = null;
    40 SwitchTest( ZERO, "ZERO" );
    41 SwitchTest( NULL, "NULL" );
    42 SwitchTest( UNDEFINED, "UNDEFINED" );
    43 SwitchTest( FALSE, "FALSE" );
    44 SwitchTest( false,  "false" );
    45 SwitchTest( 0,      "0" );
    47 SwitchTest ( TRUE, "TRUE" );
    48 SwitchTest( 1,     "1" );
    49 SwitchTest( ONE,   "ONE" );
    50 SwitchTest( true,  "true" );
    52 SwitchTest( "a",   "a" );
    53 SwitchTest( A,     "A" );
    54 SwitchTest( "b",   "b" );
    55 SwitchTest( B,     "B" );
    57 SwitchTest( new Boolean( true ), "default" );
    58 SwitchTest( new Boolean(false ), "default" );
    59 SwitchTest( new String( "A" ),   "default" );
    60 SwitchTest( new Number( 0 ),     "default" );
    62 test();
    64 function SwitchTest( input, expect ) {
    65   var result = "";
    67   switch ( input ) {
    68   default:   result += "default"; break;
    69   case "a":  result += "a";       break;
    70   case "b":  result += "b";       break;
    71   case A:    result += "A";       break;
    72   case B:    result += "B";       break;
    73   case new Boolean(true): result += "new TRUE";   break;
    74   case new Boolean(false): result += "new FALSE"; break;
    75   case NULL: result += "NULL";    break;
    76   case UNDEFINED: result += "UNDEFINED"; break;
    77   case true: result += "true";    break;
    78   case false: result += "false";  break;
    79   case TRUE:  result += "TRUE";   break;
    80   case FALSE: result += "FALSE";  break;
    81   case 0:    result += "0";       break;
    82   case 1:    result += "1";       break;
    83   case new Number(0) : result += "new ZERO";  break;
    84   case new Number(1) : result += "new ONE";   break;
    85   case ONE:  result += "ONE";     break;
    86   case ZERO: result += "ZERO";    break;
    87   }
    89   new TestCase(
    90     SECTION,
    91     "switch with no breaks:  input is " + input,
    92     expect,
    93     result );
    94 }

mercurial