tor-browser

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

invoke-then-error-close.js (1155B)


      1 // Copyright (C) 2019 Leo Balter. All rights reserved.
      2 // This code is governed by the BSD license found in the LICENSE file.
      3 /*---
      4 description: >
      5  Error thrown when invoking the instance's `then` method (closing iterator)
      6 esid: sec-promise.allsettled
      7 info: |
      8  6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
      9  7. If result is an abrupt completion, then
     10    a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
     11    b. IfAbruptRejectPromise(result, promiseCapability).
     12 
     13  Runtime Semantics: PerformPromiseAllSettled
     14 
     15  z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
     16 features: [Promise.allSettled, Symbol.iterator]
     17 ---*/
     18 
     19 var promise = new Promise(function() {});
     20 var returnCount = 0;
     21 var iter = {};
     22 iter[Symbol.iterator] = function() {
     23  return {
     24    next() {
     25      return {
     26        done: false,
     27        value: promise
     28      };
     29    },
     30    return() {
     31      returnCount += 1;
     32      return {};
     33    }
     34  };
     35 };
     36 
     37 promise.then = function() {
     38  throw new Test262Error();
     39 };
     40 
     41 Promise.allSettled(iter);
     42 
     43 assert.sameValue(returnCount, 1);
     44 
     45 reportCompare(0, 0);