<!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 resolve;
var promise = new Promise(function(r) { resolve = r; });

promise.then(function () {
  testFailed('fulfilled');
}, function (error) {
  testPassed('rejected');
  window.result = error.toString();
  shouldBeEqualToString('result', 'TypeError: Cannot resolve a promise with itself');
}).then(finishJSTest, finishJSTest);

resolve(promise);

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