Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/reject-via-abrupt-queue.js

raw
1 // Copyright (C) 2017 Mozilla Corporation. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 description: >
6 Rejecting through an abrupt completion - captured in a queued job
7 esid: sec-promise-executor
8 info: |
9 25.4.3.1 Promise ( executor )
10
11 ...
12 9. Let completion be Call(executor, undefined, « resolvingFunctions.[[Resolve]],
13 resolvingFunctions.[[Reject]] »).
14 10. If completion is an abrupt completion, then
15 a. Perform ? Call(resolvingFunctions.[[Reject]], undefined, « completion.[[Value]] »).
16 11. Return promise.
17
18 25.4.1.3.1 Promise Reject Functions
19
20 ...
21 6. Return RejectPromise(promise, reason).
22
23 25.4.5.3.1 PerformPromiseThen ( promise, onFulfilled, onRejected, resultCapability )
24
25 ...
26 4. If IsCallable(onRejected) is false, then
27 a. Set onRejected to undefined.
28 ...
29 6. Let rejectReaction be the PromiseReaction { [[Capability]]: resultCapability,
30 [[Type]]: "Reject", [[Handler]]: onRejected }.
31 ...
32 9. Else,
33 a. Assert: The value of promise.[[PromiseState]] is "rejected".
34 ...
35 d. Perform EnqueueJob("PromiseJobs", PromiseReactionJob, « rejectReaction, reason »).
36 flags: [async]
37 ---*/
38
39 var thenable = Promise.resolve();
40 var p = new Promise(function() {
41 throw thenable;
42 });
43
44 p.then(function() {
45 $DONE('The promise should not be fulfilled.');
46 }).then(function() {
47 $DONE('The promise should not be fulfilled.');
48 }, function(x) {
49 if (x !== thenable) {
50 $DONE('The promise should be rejected with the resolution value.');
51 return;
52 }
53 $DONE();
54 });