invoke-resolve-error-reject.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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: Promise rejection in response to error
  5. esid: sec-promise.all
  6. info: |
  7. 11. Let result be PerformPromiseAll(iteratorRecord, C, promiseCapability).
  8. 12. If result is an abrupt completion,
  9. a. If iteratorRecord.[[done]] is false, let result be
  10. IteratorClose(iterator, result).
  11. b. IfAbruptRejectPromise(result, promiseCapability).
  12. [...]
  13. 25.4.4.1.1 Runtime Semantics: PerformPromiseAll
  14. [...]
  15. 6. Repeat
  16. [...]
  17. i. Let nextPromise be Invoke(constructor, "resolve", «nextValue»).
  18. j. ReturnIfAbrupt(nextPromise ).
  19. flags: [async]
  20. ---*/
  21. var thrown = new Test262Error();
  22. Promise.resolve = function() {
  23. throw thrown;
  24. };
  25. Promise.all([1])
  26. .then(function() {
  27. $ERROR('The promise should not be fulfilled.');
  28. }, function(reason) {
  29. if (reason !== thrown) {
  30. $ERROR('The promise should be rejected with the thrown error object');
  31. }
  32. }).then($DONE, $DONE);