blob: 6b20dfb2c2bea54c1eac3f25ea54e11f4a1e4d64 (
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// |reftest| async
// Copyright (C) 2022 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
description: |
The 'asyncTest' helper calls $DONE with the rejection value if the test function rejects.
flags: [async]
includes: [asyncHelpers.js, compareArray.js]
---*/
const rejectionValues = [];
var realDone = $DONE;
globalThis.$DONE = function (mustBeDefined) {
rejectionValues.push(mustBeDefined);
};
const someObject = {};
(async function () {
asyncTest(function () {
return Promise.reject(null);
});
})()
.then(() => {
asyncTest(function () {
return Promise.reject(someObject);
});
})
.then(() => {
asyncTest(function () {
return Promise.reject("hi");
});
})
.then(() => {
asyncTest(function () {
return Promise.reject(10);
});
})
.then(() => {
asyncTest(function () {
return {
then(res, rej) {
rej(true);
},
};
});
})
.then(() => {
assert.compareArray(rejectionValues, [null, someObject, "hi", 10, true]);
})
.then(realDone, realDone);
|