<!-- webkit-test-runner [ ShowModalDialogEnabled=true ] -->
<html>

<head>
<script>
function sleep(ms) {
    let start = new Date();
    while (new Date() - start < ms);
}

(() => {
    if (window.testRunner)
        testRunner.dumpAsText();
})();

window.onclick = () => {
    window.onclick = null;
    document.designMode = "on";
    document.execCommand("selectAll");

    let frame = document.body.appendChild(document.createElement("iframe"));
    let mediaList = frame.contentWindow.matchMedia("(max-width: 100px)");
    mediaList.addListener(() => {
        let link = document.createElement("a");
        link.href = "https://www.webkit.org";
        link.click();
        showModalDialog("resources/self-closing-modal-dialog.html");
    });

    document.execCommand("delete");
}
</script>
</head>

<body>
<script>
if (window.eventSender) {
    eventSender.mouseMoveTo(innerHeight / 2, innerWidth / 2);
    eventSender.mouseDown();
    eventSender.mouseUp();
}
</script>
</body>

</html>
