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

<html>
<meta name="viewport" content="initial-scale=1.0, width=device-width">

<head>
    <script src="../../../resources/js-test-pre.js"></script>
    <script src="../../../resources/ui-helper.js"></script>
    <script>
    clickCount = 0;
    jsTestIsAsync = true;

    async function runTest() {
        description("This test verifies that repeatedly tapping a button when the viewport is at initial scale dispatches click events instead of only causing the user to zoom. To manually run the test, tap the button several quickly; the button should be clicked multiple times, without waiting for a ~300 ms delay between each tap.");

        if (!testRunner.runUIScript)
            return;

        const target = document.querySelector("button");
        while (clickCount < 3)
            await UIHelper.activateElement(target);

        testPassed("Dispatched three clicks.");
        finishJSTest();
    }

    function handleClick() {
        clickCount++;
    }
    </script>

    <style>
    body {
        margin: 0;
    }

    button {
        width: 100%;
        height: 100px;
    }
    </style>
</head>

<body onload="runTest()">
    <button onclick="handleClick()"></button>
    <p id="description"></p>
    <script src="../../../resources/js-test-post.js"></script>
</body>

</html>
