Debian Codegraph @

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

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