<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ignoreSynchronousMessagingTimeouts=true ] -->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
<script src="../../../../resources/ui-helper.js"></script>
<style>
body, html {
    width: 100%;
    height: 100%;
    margin: 0;
}

#target {
    background-color: tomato;
    color: white;
    width: 100%;
    height: 200px;
    text-align: center;
    font-size: 20px;
}
</style>
</head>
<body>
<div id="target">Tap to show an alert</div>
<p>This test verifies that presenting a modal alert while handling a synchronous touch event doesn't cause the application process to hang. To verify manually, tap the red area above, and check that the JavaScript alert is presented with no significant delay.</p>
<script>
if (window.testRunner) {
    testRunner.setShouldDismissJavaScriptAlertsAsynchronously(true);
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
}

target.addEventListener("touchstart", () => alert("This is a modal alert."));
target.addEventListener("touchend", () => testRunner.notifyDone(), { passive : true });
addEventListener("load", async () => await UIHelper.activateAt(100, 100));
</script>
</body>
</html>
