| 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 non-thenable object value after invocation of 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 |
a. Return FulfillPromise(promise, resolution). |
| 21 |
flags: [async] |
| 22 |
---*/ |
| 23 |
|
| 24 |
var returnValue = null; |
| 25 |
var nonThenable = { |
| 26 |
then: null |
| 27 |
}; |
| 28 |
var resolve; |
| 29 |
var promise = new Promise(function(_resolve) { |
| 30 |
resolve = _resolve; |
| 31 |
}); |
| 32 |
|
| 33 |
promise.then(function(value) { |
| 34 |
if (value !== nonThenable) { |
| 35 |
$DONE('The promise should be fulfilled with the provided value.'); |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
$DONE(); |
| 40 |
}, function() { |
| 41 |
$DONE('The promise should not be rejected.'); |
| 42 |
}); |
| 43 |
|
| 44 |
returnValue = resolve(nonThenable); |
| 45 |
|
| 46 |
assert.sameValue(returnValue, undefined, '"resolve" return value'); |