tor-browser

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

invoke-then-get-error-close.js (1329B)


      1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 description: >
      5  Error thrown when accesing the instance's `then` method (closing iterator)
      6 esid: sec-performpromiseall
      7 info: |
      8    11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
      9    12. If result is an abrupt completion,
     10        a. If iteratorRecord.[[done]] is false, let result be
     11           IteratorClose(iterator, result).
     12        b. IfAbruptRejectPromise(result, promiseCapability).
     13 
     14    [...]
     15 
     16    25.4.4.1.1 Runtime Semantics: PerformPromiseAll
     17 
     18    [...]
     19    6. Repeat
     20        [...]
     21        r. Let result be Invoke(nextPromise, "then", «resolveElement,
     22           resultCapability.[[Reject]]»).
     23        s. ReturnIfAbrupt(result).
     24 features: [Symbol.iterator]
     25 ---*/
     26 
     27 var promise = new Promise(function() {});
     28 var returnCount = 0;
     29 var iter = {};
     30 iter[Symbol.iterator] = function() {
     31  return {
     32    next: function() {
     33      return {
     34        done: false,
     35        value: promise
     36      };
     37    },
     38    return: function() {
     39      returnCount += 1;
     40      return {};
     41    }
     42  };
     43 };
     44 
     45 Object.defineProperty(promise, 'then', {
     46  get: function() {
     47    throw new Test262Error();
     48  }
     49 });
     50 
     51 Promise.all(iter);
     52 
     53 assert.sameValue(returnCount, 1);
     54 
     55 reportCompare(0, 0);