summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Promise/allSettled/resolve-thenable.js
blob: 008e9525e96c9e635912ab890114d6a136588a65 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// |reftest| async
// Copyright (C) 2019 Leo Balter. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: Resolving with a thenable object value
esid: sec-promise.allsettled
info: |
  Let promiseCapability be NewPromiseCapability(C).
flags: [async]
features: [Promise.allSettled]
---*/

var value = {};
var promise;

try {
  Array.prototype.then = function(resolve) {
    resolve(value);
  };

  promise = Promise.allSettled([]);
} finally {
  delete Array.prototype.then;
}

promise.then(function(val) {
  assert.sameValue(val, value);
}, function() {
  $DONE('The promise should not be rejected.');
}).then($DONE, $DONE);