Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/resolve-thenable-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 Resolving with a thenable object value from within the executor function
6 es6id: 25.4.3.1
7 info: |
8 [...]
9 8. Let resolvingFunctions be CreateResolvingFunctions(promise).
10 9. Let completion be Call(executor, undefined,
11 «resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»).
12
13 25.4.1.3.2 Promise Resolve Functions
14 [...]
15 8. Let then be Get(resolution, "then").
16 9. If then is an abrupt completion, then
17 [...]
18 10. Let thenAction be then.[[value]].
19 11. If IsCallable(thenAction) is false, then
20 [...]
21 12. Perform EnqueueJob ("PromiseJobs", PromiseResolveThenableJob,
22 «promise, resolution, thenAction»)
23 flags: [async]
24 ---*/
25
26 var returnValue = null;
27 var value = {};
28 var thenable = new Promise(function(resolve) {
29 resolve(value);
30 });
31 var promise = new Promise(function(resolve) {
32 returnValue = resolve(thenable);
33 });
34
35 assert.sameValue(returnValue, undefined, '"resolve" return value');
36
37 promise.then(function(val) {
38 if (val !== value) {
39 $DONE('The promise should be fulfilled with the provided value.');
40 return;
41 }
42
43 $DONE();
44 }, function() {
45 $DONE('The promise should not be rejected.');
46 });