45 lines
958 B
HTML
45 lines
958 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 rejection handled event.');
|
|
|
|
window.jsTestIsAsync = true;
|
|
|
|
window.error = null;
|
|
window.promise = null;
|
|
window.reason = null;
|
|
|
|
window.onunhandledrejection = function (e) {
|
|
error = e;
|
|
shouldBe(`error.type`, `"unhandledrejection"`);
|
|
shouldBe(`error.cancelable`, `true`);
|
|
shouldBe(`error.promise`, `promise`);
|
|
shouldBe(`error.reason`, `"ERROR"`);
|
|
promise.catch(function (r) {
|
|
window.reason = r;
|
|
shouldBe(`reason`, `"ERROR"`);
|
|
});
|
|
|
|
setTimeout(function () {
|
|
finishJSTest();
|
|
}, 100);
|
|
return false;
|
|
};
|
|
|
|
window.onrejectionhandled = function (e) {
|
|
testFailed(`rejectionhandled is fired.`);
|
|
};
|
|
|
|
window.promise = Promise.reject("ERROR");
|
|
|
|
</script>
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|