js/src/tests/js1_7/geniter/throw-forever.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/. */
     6 //-----------------------------------------------------------------------------
     7 var BUGNUMBER     = "(none)";
     8 var summary = "gen.throw(ex) returns ex for an exhausted gen";
     9 var actual, expect;
    11 printBugNumber(BUGNUMBER);
    12 printStatus(summary);
    14 /**************
    15  * BEGIN TEST *
    16  **************/
    18 function gen()
    19 {
    20   var x = 5, y = 7;
    21   var z = x + y;
    22   yield z;
    23 }
    25 var failed = false;
    26 var it = gen();
    28 try
    29 {
    30   // throw works even on newly-initialized generators
    31   var thrown = "foobar";
    32   var doThrow = true;
    33   try
    34   {
    35     it.throw(thrown);
    36   }
    37   catch (e)
    38   {
    39     if (e === thrown)
    40       doThrow = false;
    41   }
    42   if (doThrow)
    43     throw "it.throw(\"" + thrown + "\") failed";
    45   // you can throw stuff at a generator which hasn't
    46   // been used yet forever
    47   thrown = "baz";
    48   doThrow = true;
    49   try
    50   {
    51     it.throw(thrown);
    52   }
    53   catch (e)
    54   {
    55     if (e === thrown)
    56       doThrow = false;
    57   }
    58   if (doThrow)
    59     throw "it.throw(\"" + thrown + "\") failed";
    61   // don't execute a yield -- the uncaught exception
    62   // exhausted the generator
    63   var stopPassed = false;
    64   try
    65   {
    66     it.next();
    67   }
    68   catch (e)
    69   {
    70     if (e === StopIteration)
    71       stopPassed = true;
    72   }
    74   if (!stopPassed)
    75     throw "missing or incorrect StopIteration";
    76 }
    77 catch (e)
    78 {
    79   failed = e;
    80 }
    82 expect = false;
    83 actual = failed;
    85 reportCompare(expect, actual, summary);

mercurial