aboutsummaryrefslogtreecommitdiff
path: root/test/js/promise_s19.t.js
blob: d339b3f640987664ab7497ca79e894430e0e0783 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*---
includes: [compareArray.js]
flags: [async]
---*/

let stages = [];

var returnValue = null;
var value = {};
var resolve;

var poisonedThen = Object.defineProperty({}, 'then', {
    get: function() {
        stages.push('Throw!');
        throw value;
    }
});

var promise = new Promise(function(_resolve) {
    resolve = _resolve;
});

promise.then(
    v => $DONOTEVALUATE(),
    e => {
        stages.push('Reject!');
        assert.sameValue(e, value, 'The promise should be fulfilled with the provided value.');
})
.then(() => assert.compareArray(stages, ['Throw!', undefined, 'Reject!']))
.then($DONE, $DONE);

returnValue = resolve(poisonedThen);

stages.push(returnValue);