Newer
Older
minerva / Tests / LibWeb / Text / input / HTML / CloseWatcher-detached-iframe.html
@minerva minerva on 13 Jul 803 bytes Initial commit
<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>