<!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 value = {
  then: function(fulfillCallback, rejectCallback) {
    testPassed('value.then is called.');
    window.thisValue = this;
    shouldBe('thisValue', 'value');
    rejectCallback('hello');
  }
};
var promise = new Promise(function(resolve) { resolve(value); });

promise.then(function(result) {
  testFailed('fulfilled');
  finishJSTest();
}, function(result) {
  testPassed('rejected');
  window.result = result;
  shouldBeEqualToString('result', 'hello');
  finishJSTest();
});

debug('The promise is not rejected now.');

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
