Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/all/reject-ignored-deferred.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 deferred invocation of the
6 provided resolving function
7 es6id: 25.4.4.1
8 info: |
9 [...]
10 6. Let promiseCapability be NewPromiseCapability(C).
11 [...]
12 11. Let result be PerformPromiseAll(iteratorRecord, promiseCapability, C).
13 [...]
14
15 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
16 [...]
17 6. Repeat
18 [...]
19 r. Let result be Invoke(nextPromise, "then", resolveElement,
20 promiseCapability.[[Reject]]»).
21
22 25.4.1.3.1 Promise Reject Functions
23 [...]
24 2. Let promise be the value of F's [[Promise]] internal slot.
25 3. Let alreadyResolved be the value of F's [[AlreadyResolved]] internal
26 slot.
27 4. If alreadyResolved.[[value]] is true, return undefined.
28 flags: [async]
29 ---*/
30
31 var fulfiller = {
32 then: function(resolve) {
33 new Promise(function(resolve) {
34 resolve();
35 })
36 .then(function() {
37 resolve();
38 });
39 }
40 };
41 var rejector = {
42 then: function(resolve, reject) {
43 new Promise(function(resolve) {
44 resolve();
45 })
46 .then(function() {
47 resolve();
48 reject();
49 });
50 }
51 };
52
53 Promise.all([fulfiller, rejector])
54 .then(function() {
55 $DONE();
56 }, function() {
57 $DONE('The promise should not be rejected.');
58 });