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

    #target {
        font-size: 100px;
    }

    #clickTarget {
        width: 100px;
        height: 100px;
        background-color: green;
    }
    </style>
    <script>
    if (window.testRunner) {
        testRunner.dumpAsText();
        testRunner.waitUntilDone();
    }

    async function run()
    {
        if (!window.testRunner)
            return;

        function didChangeSelection()
        {
            result.textContent = window.getSelection().toString()
        }

        document.addEventListener("selectionchange", didChangeSelection);

        var clickTarget = document.getElementById("clickTarget");

        clickTarget.addEventListener("click", event => {
            event.preventDefault();

            setTimeout(async function () {
                // The test is done, but we need to tap again to ensure we don't
                // hang the next test with a double tap.
                document.removeEventListener("selectionchange", didChangeSelection);
                await UIHelper.tapAt(10, 500);

                testRunner.notifyDone();
            }, 0);
        });

        var target = document.getElementById("target");        
        window.getSelection().setBaseAndExtent(target, 0, target, 6);

        await UIHelper.activateElement(clickTarget);
    }
    </script>
</head>
<body onload="run()">
    <div id="target">WebKit</div>
    <div id="clickTarget"></div>
    <pre>The selected text is: "<span id="result"></span>"</pre>
    <p>This test verifies that the DOM selection is not dismissed when tapping on an element that preventDefault()s the click event.</p>
</body>
</html>
