blob: 9bd21c91a9960c419006d076e6217428bc938632 [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 unhandled promise rejection event.');
window.jsTestIsAsync = true;
window.error = null;
window.promise = [];
window.count = 0;
window.index = 0;
window.onunhandledrejection = function (e) {
error = e;
index = count++;
shouldBe(`error.type`, `"unhandledrejection"`);
shouldBe(`error.cancelable`, `true`);
shouldBe(`error.promise`, `promise[${index}]`);
shouldBe(`error.reason`, `${index}`);
if (count === 3)
finishJSTest();
return false;
};
for (let i = 0; i < 3; ++i)
window.promise[i] = Promise.reject(i);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>