tor-browser

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

iterator-close-after-set-failure.js (906B)


      1 // Copyright (C) 2015 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 esid: sec-map-iterable
      5 description: >
      6  The iterator is closed when `Map.prototype.set` throws an error.
      7 info: |
      8  Map ( [ iterable ] )
      9 
     10  ...
     11  9. Repeat
     12    ...
     13    k. Let status be Call(adder, map, «k.[[value]], v.[[value]]»).
     14    l. If status is an abrupt completion, return IteratorClose(iter, status).
     15 features: [Symbol.iterator]
     16 ---*/
     17 
     18 var count = 0;
     19 var iterable = {};
     20 iterable[Symbol.iterator] = function() {
     21  return {
     22    next: function() {
     23      return {
     24        value: [],
     25        done: false
     26      };
     27    },
     28    return: function() {
     29      count += 1;
     30    }
     31  };
     32 };
     33 Map.prototype.set = function() {
     34  throw new Test262Error();
     35 }
     36 
     37 assert.throws(Test262Error, function() {
     38  new Map(iterable);
     39 });
     40 
     41 assert.sameValue(count, 1);
     42 
     43 reportCompare(0, 0);