invoke-then-error-reject.js (1201B)
1 // |reftest| async 2 // Copyright (C) 2015 the V8 project authors. All rights reserved. 3 // This code is governed by the BSD license found in the LICENSE file. 4 5 /*--- 6 description: > 7 Error thrown when invoking the instance's `then` method (rejecting Promise) 8 esid: sec-performpromiseall 9 info: | 10 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability). 11 12. If result is an abrupt completion, 12 a. If iteratorRecord.[[done]] is false, let result be 13 IteratorClose(iterator, result). 14 b. IfAbruptRejectPromise(result, promiseCapability). 15 16 [...] 17 18 25.4.4.1.1 Runtime Semantics: PerformPromiseAll 19 20 [...] 21 6. Repeat 22 [...] 23 r. Let result be Invoke(nextPromise, "then", «resolveElement, 24 resultCapability.[[Reject]]»). 25 s. ReturnIfAbrupt(result). 26 flags: [async] 27 ---*/ 28 29 var promise = new Promise(function() {}); 30 var error = new Test262Error(); 31 32 Object.defineProperty(promise, "then", { 33 value: function() { 34 throw error; 35 } 36 }); 37 38 Promise.all([promise]).then(function() { 39 throw new Test262Error('The promise should be rejected'); 40 }, function(reason) { 41 assert.sameValue(reason, error); 42 }).then($DONE, $DONE);