tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

iterclose-generator-throw.js (579B)


      1 var finallyCount = 0;
      2 
      3 function* gen(o) {
      4  try {
      5    yield 1;
      6    yield 2;
      7    yield 3;
      8  } finally {
      9    finallyCount++;
     10  }
     11 }
     12 
     13 function closeIter(o) {
     14  for (var x of o) {
     15    if (x == 2) {
     16      throw "good"
     17    }
     18  }
     19 }
     20 
     21 function test() {
     22  with ({}) {}
     23  finallyCount = 0;
     24 
     25  for (var i = 0; i < 100; i++) {
     26    var caught = "bad";
     27    try {
     28      closeIter(gen());
     29    } catch (e) {
     30      caught = e;
     31    }
     32    assertEq(caught, "good");
     33  }
     34  assertEq(finallyCount, 100);
     35 }
     36 
     37 with ({}) {}
     38 
     39 test();
     40 
     41 // Force an IC in Ion.
     42 try {
     43  closeIter([1,2,3,4,5]);
     44 } catch {}
     45 
     46 test();