1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 01:07:35 +00:00

LibWeb: Use CSO if running script is null in HostPromiseRejectionTracker

This commit is contained in:
Luke Wilde 2022-06-27 19:53:30 +01:00 committed by Linus Groh
parent 1d5b03ce17
commit 62491cda0b
2 changed files with 39 additions and 13 deletions

View file

@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<head>
<title>Unhandled Promise rejection with no [[ScriptOrModule]] for the current execution context</title>
</head>
<body>
<button onclick="
Promise.reject(new Error('Success!'));
window.timer = setTimeout(() => {
const element = document.createElement('p');
element.innerText = 'Did not receieve unhandledrejection event in 100ms.';
element.style.color = 'red';
document.body.appendChild(element);
}, 100)
">
Click me to cause an unhandled promise rejection.
</button>
<script>
window.onunhandledrejection = (rejectionEvent) => {
clearTimeout(window.timer);
const element = document.createElement("p");
element.innerText = rejectionEvent.reason.message;
element.style.color = "green";
document.body.appendChild(element);
}
</script>
</body>
</html>