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