js/src/tests/ecma_2/Statements/while-002.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:          while-002
     9  *  ECMA Section:
    10  *  Description:        while statement
    11  *
    12  *  Verify that the while statement is not executed if the while expression is
    13  *  false
    14  *
    15  *  Author:             christine@netscape.com
    16  *  Date:               11 August 1998
    17  */
    18 var SECTION = "while-002";
    19 var VERSION = "ECMA_2";
    20 var TITLE   = "while statement";
    22 startTest();
    23 writeHeaderToLog( SECTION + " "+ TITLE);
    25 DoWhile( new DoWhileObject(
    26 	   "while expression is null",
    27 	   null,
    28 	   "result = \"fail: should not have evaluated statements in while block;break"
    29 	   ) );
    31 DoWhile( new DoWhileObject(
    32 	   "while expression is undefined",
    33 	   void 0,
    34 	   "result = \"fail: should not have evaluated statements in while block; break"
    35 	   ));
    37 DoWhile( new DoWhileObject(
    38 	   "while expression is 0",
    39 	   0,
    40 	   "result = \"fail: should not have evaluated statements in while block; break;"
    41 	   ));
    43 DoWhile( new DoWhileObject(
    44 	   "while expression is eval(\"\")",
    45 	   eval(""),
    46 	   "result = \"fail: should not have evaluated statements in while block; break"
    47 	   ));
    49 DoWhile( new DoWhileObject(
    50 	   "while expression is NaN",
    51 	   NaN,
    52 	   "result = \"fail: should not have evaluated statements in while block; break"
    53 	   ));
    55 test();
    57 function DoWhileObject( d, e, s ) {
    58   this.description = d;
    59   this.whileExpression = e;
    60   this.statements = s;
    61 }
    63 function DoWhile( object ) {
    64   result = "pass";
    66   while ( expression = object.whileExpression ) {
    67     eval( object.statements );
    68   }
    70   // verify that the while expression was evaluated
    72   new TestCase(
    73     SECTION,
    74     "verify that while expression was evaluated (should be "+
    75     object.whileExpression +")",
    76     "pass",
    77     (object.whileExpression == expression ||
    78      ( isNaN(object.whileExpression) && isNaN(expression) )
    79       ) ? "pass" : "fail" );
    81   new TestCase(
    82     SECTION,
    83     object.description,
    84     "pass",
    85     result );
    86 }

mercurial