39 lines
820 B
HTML
39 lines
820 B
HTML
<!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>
|