tor-browser

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

invoke-then-get-error-reject.js (1203B)


      1 // |reftest| async
      2 // Copyright (C) 2016 the V8 project authors. All rights reserved.
      3 // This code is governed by the BSD license found in the LICENSE file.
      4 /*---
      5 description: >
      6  Error thrown when accessing the instance's `then` method (rejecting promise)
      7 esid: sec-promise.race
      8 info: |
      9    11. Let result be PerformPromiseRace(iteratorRecord, C, promiseCapability).
     10    12. If result is an abrupt completion,
     11        a. If iteratorRecord.[[done]] is false, let result be
     12           IteratorClose(iterator, result).
     13        b. IfAbruptRejectPromise(result, promiseCapability).
     14 
     15    [...]
     16 
     17    25.4.4.3.1 Runtime Semantics: PerformPromiseRace
     18 
     19    1. Repeat
     20        [...]
     21        j. Let result be Invoke(nextPromise, "then",
     22           «promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
     23        k. ReturnIfAbrupt(result).
     24 flags: [async]
     25 ---*/
     26 
     27 var promise = new Promise(function() {});
     28 var error = new Test262Error();
     29 
     30 Object.defineProperty(promise, 'then', {
     31  get: function() {
     32    throw error;
     33  }
     34 });
     35 
     36 Promise.race([promise]).then(function() {
     37  throw new Test262Error('The promise should be rejected');
     38 }, function(reason) {
     39  assert.sameValue(reason, error);
     40 }).then($DONE, $DONE);