Debian Codegraph @

js/src/tests/test262/built-ins/Promise/race/reject-deferred.js

raw
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: Rejecting through deferred invocation of the provided resolving function
6 es6id: 25.4.4.3
7 info: |
8 [...]
9 6. Let promiseCapability be NewPromiseCapability(C).
10 [...]
11 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
12 [...]
13
14 25.4.4.3.1 Runtime Semantics: PerformPromiseRace
15 1. Repeat
16 [...]
17 j. Let result be Invoke(nextPromise, "then",
18 «promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
19
20 25.4.1.3.1 Promise Reject Functions
21 [...]
22 6. Return RejectPromise(promise, reason).
23 flags: [async]
24 ---*/
25
26 var thenable = {
27 then: function(_, reject) {
28 new Promise(function(resolve) {
29 resolve();
30 })
31 .then(function() {
32 reject();
33 });
34 }
35 };
36
37 Promise.race([thenable])
38 .then(function() {
39 $DONE('The promise should not be fulfilled.');
40 }, function() {
41 $DONE();
42 });