invoke-resolve-get-error-reject.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (C) 2015 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. Error retrieving the constructor's `resolve` method (rejecting promise)
  6. esid: sec-performpromiseall
  7. info: |
  8. 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
  9. 12. If result is an abrupt completion,
  10. a. If iteratorRecord.[[done]] is false, let result be
  11. IteratorClose(iterator, result).
  12. b. IfAbruptRejectPromise(result, promiseCapability).
  13. [...]
  14. Runtime Semantics: PerformPromiseAll
  15. ...
  16. 1. Let promiseResolve be ? Get(constructor, `"resolve"`).
  17. ...
  18. 1. Repeat,
  19. 1. Let next be IteratorStep(iteratorRecord).
  20. ...
  21. 1. Let nextPromise be ? Call(promiseResolve, constructor, < nextValue >).
  22. flags: [async]
  23. ---*/
  24. var error = new Test262Error();
  25. Object.defineProperty(Promise, 'resolve', {
  26. get: function() {
  27. throw error;
  28. }
  29. });
  30. Promise.all([new Promise(function() {})]).then(function() {
  31. $ERROR('The promise should be rejected');
  32. }, function(reason) {
  33. assert.sameValue(reason, error);
  34. }).then($DONE, $DONE);