Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/race/reject-ignored-immed.js

raw
1 // Copyright (C) 2016 the V8 project authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 description: >
5 Resolved promises ignore rejections through immediate invocation of the
6 provided resolving function
7 es6id: 25.4.4.3
8 info: |
9 [...]
10 6. Let promiseCapability be NewPromiseCapability(C).
11 [...]
12 11. Let result be PerformPromiseRace(iteratorRecord, promiseCapability, C).
13 [...]
14
15 25.4.4.3.1 Runtime Semantics: PerformPromiseRace
16 1. Repeat
17 [...]
18 j. Let result be Invoke(nextPromise, "then",
19 «promiseCapability.[[Resolve]], promiseCapability.[[Reject]]»).
20
21 25.4.1.3.1 Promise Reject Functions
22 [...]
23 2. Let promise be the value of F's [[Promise]] internal slot.
24 3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
25 slot.
26 4. If alreadyResolved.[[value]] is true, return undefined.
27 flags: [async]
28 ---*/
29
30 var fulfiller = {
31 then: function(resolve) {
32 resolve();
33 }
34 };
35 var rejector = {
36 then: function(_, reject) {
37 reject();
38 }
39 };
40
41 Promise.race([fulfiller, rejector])
42 .then(function() {
43 $DONE();
44 }, function() {
45 $DONE('The promise should not be rejected.');
46 });