tor-browser

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

invoke-then-error-reject.js (1056B)


      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 description: >
      7  Error thrown when invoking the instance's `then` method (rejecting Promise)
      8 esid: sec-promise.allsettled
      9 info: |
     10  6. Let result be PerformPromiseAllSettled(iteratorRecord, C, promiseCapability).
     11  7. If result is an abrupt completion, then
     12    a. If iteratorRecord.[[Done]] is false, set result to IteratorClose(iteratorRecord, result).
     13    b. IfAbruptRejectPromise(result, promiseCapability).
     14 
     15  Runtime Semantics: PerformPromiseAllSettled
     16 
     17  z. Perform ? Invoke(nextPromise, "then", « resolveElement, rejectElement »).
     18 flags: [async]
     19 features: [Promise.allSettled]
     20 ---*/
     21 
     22 var promise = new Promise(function() {});
     23 var error = new Test262Error();
     24 
     25 promise.then = function() {
     26  throw error;
     27 };
     28 
     29 Promise.allSettled([promise]).then(function() {
     30  throw new Test262Error('The promise should be rejected');
     31 }, function(reason) {
     32  assert.sameValue(reason, error);
     33 }).then($DONE, $DONE);