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