Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/exception-after-resolve-in-thenable-job.js

raw
1 // Copyright (C) 2015 André Bargull. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 es6id: 25.4.2.2
6 description: >
7 Already resolved promise is not rejected when then() function throws an exception.
8 info: |
9 PromiseResolveThenableJob ( promiseToResolve, thenable, then )
10
11 1. Let resolvingFunctions be CreateResolvingFunctions(promiseToResolve).
12 2. Let thenCallResult be Call(then, thenable, «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
13 3. If thenCallResult is an abrupt completion,
14 a. Let status be Call(resolvingFunctions.[[Reject]], undefined, «thenCallResult.[[value]]»)
15 b. NextJob Completion(status).
16 ...
17 flags: [async]
18 ---*/
19
20 var thenable = {
21 then: function(resolve) {
22 resolve();
23 }
24 };
25
26 var thenableWithError = {
27 then: function(resolve) {
28 resolve(thenable);
29 throw new Error("ignored exception");
30 }
31 };
32
33 function executor(resolve, reject) {
34 resolve(thenableWithError);
35 }
36
37 new Promise(executor).then($DONE, $DONE);