| 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: Resolving with a non-object value from within the executor function |
| 5 |
es6id: 25.4.3.1 |
| 6 |
info: | |
| 7 |
[...] |
| 8 |
8. Let resolvingFunctions be CreateResolvingFunctions(promise). |
| 9 |
9. Let completion be Call(executor, undefined, |
| 10 |
«resolvingFunctions.[[Resolve]], resolvingFunctions.[[Reject]]»). |
| 11 |
|
| 12 |
25.4.1.3.2 Promise Resolve Functions |
| 13 |
7. If Type(resolution) is not Object, then |
| 14 |
a. Return FulfillPromise(promise, resolution). |
| 15 |
flags: [async] |
| 16 |
---*/ |
| 17 |
|
| 18 |
var returnValue = null; |
| 19 |
var promise = new Promise(function(resolve) { |
| 20 |
returnValue = resolve(45); |
| 21 |
}); |
| 22 |
|
| 23 |
assert.sameValue(returnValue, undefined, '"resolve" return value'); |
| 24 |
|
| 25 |
promise.then(function(value) { |
| 26 |
if (value !== 45) { |
| 27 |
$DONE('The promise should be fulfilled with the provided value.'); |
| 28 |
return; |
| 29 |
} |
| 30 |
|
| 31 |
$DONE(); |
| 32 |
}, function() { |
| 33 |
$DONE('The promise should not be rejected.'); |
| 34 |
}); |