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

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

<head>
    <script src="../../resources/js-test.js"></script>
    <script id="ui-script" type="text/plain">
        (function() {
            var count = 0;
            function fireSuccessiveTaps() {
                if (count < 3)
                    uiController.singleTapAtPoint(200, 200, fireSuccessiveTaps);
                else
                    uiController.uiScriptComplete("");

                count++;
            }
            fireSuccessiveTaps();
        })();
    </script>

    <script>
    var scriptCompleted = false;
    var clickCount = 0;
    jsTestIsAsync = true;

    function getUIScript() {
        return document.getElementById("ui-script").text;
    }

    function runTest() {
        if (testRunner.runUIScript)
            testRunner.runUIScript(getUIScript(), function(result) {
                scriptCompleted = true;
                if (clickCount == 3)
                    finishJSTest();
            });
    }
    function handleClicked() {
        clickCount++;
        document.body.appendChild(document.createTextNode("Click!"));
        document.body.appendChild(document.createElement("br"));
        if (clickCount == 3 && scriptCompleted)
            finishJSTest();
    }
    </script>

    <style>
    body {
        margin: 0;
    }

    #target {
        touch-action: manipulation;
        width: 400px;
        height: 400px;
    }
    </style>
</head>

<body onload="runTest()">
    <button id="target" onclick="handleClicked()"></button>
    <p>Repeatedly tapping on the button should fire click events.</p>
    <p>This test is best run in WebKitTestRunner. If you are running this test manually, verify that tapping the button causes a "Click!" message to appear below, and that click occurred without the regular 350ms delay for double tapping.</p>
</body>

</html>
