Files
ladybird/Tests/LibWeb/Text/input/HTML/CloseWatcher-detached-iframe.html
Shannon Booth 633b684d76 Tests/LibWeb: Handle synchronous iframe processing in CloseWatcher test
If we conform with the HTML specification by processing the iframe
synchronously as part of the iframe post connection steps, this test
will time out as the load event is fired in the appendChild call.

Create the promise for the load event before performing the load event
to handle this situation, which also allows the test to pass in
chromium.
2026-03-25 14:49:36 +01:00

28 lines
867 B
HTML

<!DOCTYPE html>
<script src="../include.js"></script>
<script>
promiseTest(async () => {
const iframe = document.createElement('iframe');
const iframeLoaded = new Promise(resolve => { iframe.onload = resolve; });
document.body.appendChild(iframe);
await iframeLoaded;
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>