invoke-resolve-get-error.js 997 B

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. esid: sec-promise.all
  5. description: >
  6. Promise.resolve is retrieved before GetIterator call (abrupt lookup).
  7. info: |
  8. Promise.all ( iterable )
  9. [...]
  10. 3. Let promiseResolve be GetPromiseResolve(C).
  11. 4. IfAbruptRejectPromise(promiseResolve, promiseCapability).
  12. GetPromiseResolve ( promiseConstructor )
  13. [...]
  14. 2. Let promiseResolve be ? Get(promiseConstructor, "resolve").
  15. flags: [async]
  16. features: [Symbol.iterator]
  17. ---*/
  18. const iter = {
  19. get [Symbol.iterator]() {
  20. throw new Test262Error('unreachable');
  21. },
  22. };
  23. const resolveError = { name: 'MyError' };
  24. Object.defineProperty(Promise, 'resolve', {
  25. get() {
  26. throw resolveError;
  27. },
  28. });
  29. Promise.all(iter).then(() => {
  30. throw new Test262Error('The promise should be rejected, but it was resolved');
  31. }, (reason) => {
  32. assert.sameValue(reason, resolveError);
  33. }).then($DONE, $DONE);