Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/reject-via-fn-immed-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 immediate invocation of the provided resolving function,
7 captured in a queued job.
8 esid: sec-promise-executor
9 info: |
10 25.4.3.1 Promise ( executor )
11
12 ...
13 9. Let completion be Call(executor, undefined, « resolvingFunctions.[[Resolve]],
14 resolvingFunctions.[[Reject]] »).
15 10. If completion is an abrupt completion, then
16 a. Perform ? Call(resolvingFunctions.[[Reject]], undefined, « completion.[[Value]] »).
17 11. Return promise.
18
19 25.4.1.3.1 Promise Reject Functions
20
21 ...
22 6. Return RejectPromise(promise, reason).
23
24 25.4.5.3.1 PerformPromiseThen ( promise, onFulfilled, onRejected, resultCapability )
25
26 ...
27 4. If IsCallable(onRejected) is false, then
28 a. Set onRejected to undefined.
29 ...
30 6. Let rejectReaction be the PromiseReaction { [[Capability]]: resultCapability,
31 [[Type]]: "Reject", [[Handler]]: onRejected }.
32 ...
33 9. Else,
34 a. Assert: The value of promise.[[PromiseState]] is "rejected".
35 ...
36 d. Perform EnqueueJob("PromiseJobs", PromiseReactionJob, « rejectReaction, reason »).
37 flags: [async]
38 ---*/
39
40 var thenable = Promise.resolve();
41 var returnValue = null;
42 var p = new Promise(function(_, reject) {
43 returnValue = reject(thenable);
44 });
45
46 assert.sameValue(returnValue, undefined, '"reject" function return value');
47
48 p.then(function() {
49 $DONE('The promise should not be fulfilled.');
50 }).then(function() {
51 $DONE('The promise should not be fulfilled.');
52 }, function(x) {
53 if (x !== thenable) {
54 $DONE('The promise should be rejected with the resolution value.');
55 return;
56 }
57
58 $DONE();
59 });