tor-browser

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

invoke-resolve-error-close.js (1183B)


      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 /*---
      5 description: >
      6    Explicit iterator closing in response to error
      7 esid: sec-promise.all
      8 info: |
      9    11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
     10    12. If result is an abrupt completion,
     11        a. If iteratorRecord.[[done]] is false, let result be
     12           IteratorClose(iterator, result).
     13        b. IfAbruptRejectPromise(result, promiseCapability).
     14 
     15    [...]
     16 
     17    25.4.4.1.1 Runtime Semantics: PerformPromiseAll
     18 
     19    [...]
     20    6. Repeat
     21        [...]
     22        i. Let nextPromise be Invoke(constructor, "resolve", «nextValue»).
     23        j. ReturnIfAbrupt(nextPromise ).
     24 features: [Symbol.iterator]
     25 ---*/
     26 
     27 var iterDoneSpy = {};
     28 var callCount = 0;
     29 iterDoneSpy[Symbol.iterator] = function() {
     30  return {
     31    next: function() {
     32      return {
     33        value: null,
     34        done: false
     35      };
     36    },
     37    return: function() {
     38      callCount += 1;
     39    }
     40  };
     41 };
     42 
     43 Promise.resolve = function() {
     44  throw new Test262Error();
     45 };
     46 
     47 Promise.all(iterDoneSpy);
     48 
     49 assert.sameValue(callCount, 1);
     50 
     51 reportCompare(0, 0);