tor-browser

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

iter-next-err-reject.js (1613B)


      1 // |reftest| async
      2 // Copyright (C) 2019 Leo Balter. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 
      5 /*---
      6 esid: sec-promise.allsettled
      7 description: >
      8  Error when call an iterator next step (rejecting promise)
      9 info: |
     10  Promise.allSettled ( iterable )
     11 
     12  6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
     13  7. If result is an abrupt completion, then
     14    a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
     15    b. IfAbruptRejectPromise(result, promiseCapability).
     16 
     17  Runtime Semantics: PerformPromiseAllSettled
     18 
     19  ...
     20  6. Repeat
     21    a. Let next be IteratorStep(iteratorRecord).
     22    b. If next is an abrupt completion, set iteratorRecord.[[Done]] to true.
     23    c. ReturnIfAbrupt(next).
     24    ...
     25 
     26  IteratorStep ( iteratorRecord )
     27 
     28  1. Let result be ? IteratorNext(iteratorRecord).
     29 
     30  IteratorNext ( iteratorRecord [ , value ] )
     31 
     32  1. If value is not present, then
     33    a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « »).
     34  2. Else,
     35    a. Let result be ? Call(iteratorRecord.[[NextMethod]], iteratorRecord.[[Iterator]], « value »).
     36  ...
     37 features: [Promise.allSettled, Symbol.iterator]
     38 flags: [async]
     39 ---*/
     40 
     41 var iterNextValThrows = {};
     42 var error = new Test262Error();
     43 iterNextValThrows[Symbol.iterator] = function() {
     44  return {
     45    next() {
     46      throw error;
     47    }
     48  };
     49 };
     50 
     51 Promise.allSettled(iterNextValThrows).then(function() {
     52  $DONE('The promise should be rejected.');
     53 }, function(reason) {
     54  assert.sameValue(reason, error);
     55 }).then($DONE, $DONE);