blob: 705303c13d477f164ebe0ad51d2968de17dd1028 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description('Test Promise.');
window.jsTestIsAsync = true;
var resolver;
var promise = new Promise(function(r) { resolver = r; });
var promiseState = 'pending';
var promiseResult = undefined;
promise.then(function(result) {
promiseState = 'fulfilled';
promiseResult = result;
}, function(result) {
promiseState = 'rejected';
promiseResult = result;
});
shouldBeEqualToString('promiseState', 'pending');
resolver.reject('hello');
shouldBeEqualToString('promiseState', 'pending');
promise.then(function() {
testFailed('promise is fulfilled.');
finishJSTest();
}, function() {
shouldBeEqualToString('promiseState', 'rejected');
shouldBeEqualToString('promiseResult', 'hello');
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>