LibWeb: Fix CloseWatcher constructor for detached iframes

This fixes the last subtest in /close-watcher/frame-removal.html :)
This commit is contained in:
Benjamin Bjerken 2024-10-15 12:39:47 +02:00 committed by Tim Flynn
commit 63d9ed9d8c
Notes: github-actions[bot] 2024-10-15 12:42:46 +00:00
3 changed files with 34 additions and 2 deletions

View file

@ -0,0 +1,25 @@
<script src="../include.js"></script>
<script>
promiseTest(async () => {
const iframe = document.createElement('iframe');
document.body.appendChild(iframe);
await new Promise(resolve => iframe.onload = resolve);
const iframeCloseWatcher = iframe.contentWindow.CloseWatcher;
const iframeDOMException = iframe.contentWindow.DOMException;
iframe.remove();
try {
new iframeCloseWatcher();
println("FAIL");
} catch (error) {
if (error instanceof iframeDOMException && error.name === "InvalidStateError") {
println("PASS");
} else {
println(`FAIL: CloseWatcher construction threw unexpected error: ${error.name}`);
}
}
});
</script>