js/src/tests/js1_7/geniter/throw-after-close.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.close(); gen.throw(ex) throws ex forever";
     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   it.close();
    32   // throw on closed generators just rethrows
    33   var doThrow = true;
    34   var thrown = "foobar";
    35   try
    36   {
    37     it.throw(thrown);
    38   }
    39   catch (e)
    40   {
    41     if (e === thrown)
    42       doThrow = false;
    43   }
    45   if (doThrow)
    46     throw "it.throw(\"" + thrown + "\") failed";
    48   // you can throw stuff at a closed generator forever
    49   doThrow = true;
    50   thrown = "sparky";
    51   try
    52   {
    53     it.throw(thrown);
    54   }
    55   catch (e)
    56   {
    57     if (e === thrown)
    58       doThrow = false;
    59   }
    61   if (doThrow)
    62     throw "it.throw(\"" + thrown + "\") failed";
    64   // don't execute a yield -- the uncaught exception
    65   // exhausted the generator
    66   var stopPassed = false;
    67   try
    68   {
    69     it.next();
    70   }
    71   catch (e)
    72   {
    73     if (e === StopIteration)
    74       stopPassed = true;
    75   }
    77   if (!stopPassed)
    78     throw "invalid or incorrect StopIteration";
    79 }
    80 catch (e)
    81 {
    82   failed = e;
    83 }
    87 expect = false;
    88 actual = failed;
    90 reportCompare(expect, actual, summary);

mercurial