Debian Codegraph @

js/src/tests/test262/built-ins/Promise/resolve/arg-poisoned-then.js

raw
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 `Promise.resolve` invoked with an object with a "poisoned" `then` property
8 es6id: 25.4.4.5
9 info: |
10 6. Let resolveResult be Call(promiseCapability.[[Resolve]], undefined,
11 «x»).
12
13 [...]
14
15 25.4.1.3.2 Promise Resolve Functions
16
17 8. Let then be Get(resolution, "then").
18 9. If then is an abrupt completion, then
19 a. Return RejectPromise(promise, then.[[value]]).
20 flags: [async]
21 ---*/
22
23 var poisonedThen = {};
24 var err = new Test262Error();
25 Object.defineProperty(poisonedThen, 'then', {
26 get: function() {
27 throw err;
28 }
29 });
30
31 Promise.resolve(poisonedThen).then(function() {
32 throw new Test262Error(
33 'Promise should be rejected when retrieving `then` property throws an error'
34 );
35 }, function(reason) {
36 assert.sameValue(reason, err);
37 }).then($DONE, $DONE);