| 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 reference to the promise itself |
| 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 |
[...] |
| 14 |
6. If SameValue(resolution, promise) is true, then |
| 15 |
a. Let selfResolutionError be a newly created TypeError object. |
| 16 |
b. Return RejectPromise(promise, selfResolutionError). |
| 17 |
flags: [async] |
| 18 |
---*/ |
| 19 |
|
| 20 |
var returnValue = null; |
| 21 |
var resolve; |
| 22 |
var promise = new Promise(function(_resolve) { |
| 23 |
resolve = _resolve; |
| 24 |
}); |
| 25 |
|
| 26 |
promise.then(function() { |
| 27 |
$DONE('The promise should not be fulfilled.'); |
| 28 |
}, function(reason) { |
| 29 |
if (!reason) { |
| 30 |
$DONE('The promise should be rejected with a value.'); |
| 31 |
return; |
| 32 |
} |
| 33 |
|
| 34 |
if (reason.constructor !== TypeError) { |
| 35 |
$DONE('The promise should be rejected with a TypeError instance.'); |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
$DONE(); |
| 40 |
}); |
| 41 |
|
| 42 |
returnValue = resolve(promise); |
| 43 |
|
| 44 |
assert.sameValue(returnValue, undefined, '"resolve" return value'); |