blob: 8e39bc0f70e4893b26b74470d61ff395bd573bd3 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../http/tests/inspector/resources/protocol-test.js"></script>
<script>
function createUnhandledPromise() {
window.addEventListener("unhandledrejection", (event) => {
console.log("unhandledrejection - " + JSON.stringify(event.reason));
});
window.addEventListener("rejectionhandled", (event) => {
console.log("rejectionhandled - " + JSON.stringify(event.reason));
TestPage.dispatchEventToFrontend("rejectionhandled");
});
let promise = Promise.reject("test");
setTimeout(() => {
promise.catch((value) => {
console.log("caught - " + JSON.stringify(value));
});
}, 5);
}
function test()
{
ProtocolTest.awaitEvent("rejectionhandled")
.then(() => {
ProtocolTest.completeTest();
});
ProtocolTest.evaluateInPage(`createUnhandledPromise()`)
.catch((e) => {
ProtocolTest.fail(e);
});
}
</script>
</head>
<body onload="runTest()">
<p>Tests that the injected script only `.then()`s promises if they are returned by native getters.</p>
</body>
</html>