Debian Codegraph @

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

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