blob: 223102976b8953f09af41a86c3afb15889c03018 [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 reject;
var firstPromise = new Promise(function(_, newReject) {
window.thisInInit = this;
reject = newReject;
});
var secondPromise = firstPromise.catch(function(result) {
window.thisInFulfillCallback = this;
shouldBeFalse('thisInFulfillCallback === firstPromise');
shouldBeFalse('thisInFulfillCallback === secondPromise');
shouldBeTrue('thisInFulfillCallback === window');
window.result = result;
shouldBeEqualToString('result', 'hello');
return 'bye';
});
secondPromise.then(function(result) {
window.result = result;
shouldBeEqualToString('result', 'bye');
testPassed('fulfilled');
finishJSTest();
}, function() {
testFailed('rejected');
finishJSTest();
}, function() {
});
shouldBeFalse('thisInInit === firstPromise');
shouldBeTrue('thisInInit === window');
shouldBeTrue('firstPromise instanceof Promise');
shouldBeTrue('secondPromise instanceof Promise');
reject('hello');
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>