46 lines
1.4 KiB
HTML
46 lines
1.4 KiB
HTML
<!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));
|
|
|
|
console.assert(event.promise === rejectedPromiseTest, "unhandledrejection promise should be rejectedPromiseTest.");
|
|
|
|
setTimeout(() => {
|
|
window.rejectedPromiseTest.catch((value) => {
|
|
console.log("caught - " + JSON.stringify(value));
|
|
});
|
|
});
|
|
});
|
|
|
|
window.addEventListener("rejectionhandled", (event) => {
|
|
console.log("rejectionhandled - " + JSON.stringify(event.reason));
|
|
TestPage.dispatchEventToFrontend("rejectionhandled");
|
|
});
|
|
|
|
window.rejectedPromiseTest = Promise.reject("test");
|
|
console.log(window.rejectedPromiseTest); // Ensure that the injected script sees the `Promise`.
|
|
}
|
|
|
|
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>
|