tor-browser

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

iter-arg-is-poisoned.js (1036B)


      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  Reject with abrupt completion from GetIterator
      9 info: |
     10  Promise.allSettled ( iterable )
     11 
     12  ...
     13  4. Let iteratorRecord be GetIterator(iterable).
     14  5. IfAbruptRejectPromise(iteratorRecord, promiseCapability).
     15  ...
     16 
     17  #sec-getiterator
     18  GetIterator ( obj [ , hint [ , method ] ] )
     19 
     20  ...
     21  Let iterator be ? Call(method, obj).
     22  ...
     23 features: [Promise.allSettled, Symbol.iterator]
     24 flags: [async]
     25 ---*/
     26 
     27 var poison = [];
     28 var error = new Test262Error();
     29 Object.defineProperty(poison, Symbol.iterator, {
     30  get() {
     31    throw error;
     32  }
     33 });
     34 
     35 try {
     36  Promise.allSettled(poison).then(function() {
     37    $DONE('The promise should be rejected, but was resolved');
     38  }, function(err) {
     39    assert.sameValue(err, error);
     40  }).then($DONE, $DONE);
     41 } catch (error) {
     42  $DONE(`The promise should be rejected, but threw an exception: ${error.message}`);
     43 }