tor-browser

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

iterator-close-non-throw-get-method-abrupt.js (1196B)


      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-iteratorclose
      5 description: >
      6  If retrieving an iterator's `return` method generates an error while
      7  closing the iterator with non-throw completion, the error should be
      8  forwarded to the runtime.
      9 info: |
     10  IteratorClose ( iteratorRecord, completion )
     11 
     12  [...]
     13  4. Let innerResult be GetMethod(iterator, "return").
     14  5. If innerResult.[[Type]] is normal,
     15    [...]
     16  6. If completion.[[Type]] is throw, return Completion(completion).
     17  7. If innerResult.[[Type]] is throw, return Completion(innerResult).
     18 
     19  GetMethod ( V, P )
     20 
     21  [...]
     22  2. Let func be ? GetV(V, P).
     23 features: [Symbol.iterator]
     24 ---*/
     25 
     26 var iterable = {};
     27 var iterationCount = 0;
     28 
     29 iterable[Symbol.iterator] = function() {
     30  return {
     31    next: function() {
     32      return { done: false, value: null };
     33    },
     34    get return() {
     35      throw new Test262Error();
     36    }
     37  };
     38 };
     39 
     40 assert.throws(Test262Error, function() {
     41  for (var x of iterable) {
     42    iterationCount += 1;
     43    break;
     44  }
     45 });
     46 
     47 assert.sameValue(iterationCount, 1, 'The loop body is evaluated');
     48 
     49 reportCompare(0, 0);