blob: a9df56e4b09641b52f3d846d5615a2befe537bc3 (
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
|
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description('Test Promise.');
window.jsTestIsAsync = true;
var resolve;
var promise = new Promise(function(r) { resolve = r; });
var promiseState = 'pending';
var promiseResult = undefined;
promise.then(function(result) {
promiseState = 'fulfilled';
promiseResult = result;
}, function(result) {
promiseState = 'rejected';
promiseResult = result;
});
shouldBeEqualToString('promiseState', 'pending');
resolve('hello');
shouldBeEqualToString('promiseState', 'pending');
promise.then(function() {
shouldBeEqualToString('promiseState', 'fulfilled');
shouldBeEqualToString('promiseResult', 'hello');
finishJSTest();
}, function() {
testFailed('promise is rejected.');
finishJSTest();
});
</script>
</body>
</html>
|