<!DOCTYPE html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("This test passes if it does not crash.");
jsTestIsAsync = true;

let topFrame = document.body.appendChild(document.createElement('iframe'));
let subframe1 = topFrame.contentDocument.body.appendChild(document.createElement('iframe'));
subframe1.contentWindow.onunload = () => {
    subframe1.contentWindow.onunload = null;

    let subframe2 = topFrame.contentDocument.body.appendChild(document.createElement('iframe'));
    if (!subframe2.contentWindow) {
        setTimeout(finishJSTest, 0);
        return;
    }
    subframe2.contentWindow.onunload = () => {
        subframe2.contentWindow.onunload = null;

        // Navigate top frame.
        let a = topFrame.contentDocument.createElement('a');
        a.href = 'about:blank';
        a.click();

        setTimeout(finishJSTest, 0);
    };
};

topFrame.src = 'about:blank';
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
