summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Promise/prototype/then/prfm-rejected.js
blob: 4b74b5f3cb66342b0236292f27c27576cf0be1ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// |reftest| async
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 25.4.5.3
description: PerformPromiseThen on a rejected promise
info: |
    7. Return PerformPromiseThen(promise, onFulfilled, onRejected,
       resultCapability).

    25.4.5.3.1 PerformPromiseThen

    [...]
    9. Else if the value of promise's [[PromiseState]] internal slot is
       "rejected",
       a. Let reason be the value of promise's [[PromiseResult]] internal slot.
       b. Perform EnqueueJob("PromiseJobs", PromiseReactionJob,
          «rejectReaction, reason»).
    [...]
flags: [async]
---*/

var value = {};
var p = new Promise(function(_, reject) {
  reject(value);
});

p.then(function() {
  $DONE('The `onFulfilled` handler should not be invoked.');
}, function(x) {
  if (x !== value) {
    $DONE('The `onRejected` handler should be invoked with the promise result.');
    return;
  }
  $DONE();
});