Debian Codegraph @

js/src/tests/test262/built-ins/Promise/allSettled/call-resolve-element-items.js

raw
1 // Copyright (C) 2019 Leo Balter. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-promise.allsettled-resolve-element-functions
6 description: >
7 Cannot change result value of resolved Promise.allSettled elements.
8 info: |
9 Promise.allSettled Resolve Element Functions
10
11 1. Let F be the active function object.
12 2. Let alreadyCalled be F.[[AlreadyCalled]].
13 3. If alreadyCalled.[[Value]] is true, return undefined.
14 4. Set alreadyCalled.[[Value]] to true.
15 ...
16 includes: [promiseHelper.js]
17 features: [Promise.allSettled]
18 ---*/
19
20 var callCount = 0;
21
22 function Constructor(executor) {
23 function resolve(values) {
24 callCount += 1;
25 checkSettledPromises(values, [
26 {
27 status: 'fulfilled',
28 value: 'expectedValue-p1'
29 },
30 {
31 status: 'fulfilled',
32 value: 'expectedValue-p2'
33 }
34 ], 'values');
35 }
36 executor(resolve, Test262Error.thrower);
37 }
38 Constructor.resolve = function(v) {
39 return v;
40 };
41
42 var p1 = {
43 then(onFulfilled, onRejected) {
44 onFulfilled('expectedValue-p1');
45 onFulfilled('unexpectedValue-p1');
46 }
47 };
48 var p2 = {
49 then(onFulfilled, onRejected) {
50 onFulfilled('expectedValue-p2');
51 onFulfilled('unexpectedValue-p2');
52 }
53 };
54
55 assert.sameValue(callCount, 0, 'callCount before call to all()');
56
57 Promise.allSettled.call(Constructor, [p1, p2]);
58
59 assert.sameValue(callCount, 1, 'callCount after call to all()');
60
61 reportCompare(0, 0);