Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/built-ins/Promise/resolve/resolve-poisoned-then.js

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