<body onload="test()">
    <input type="search" id="target" placeholder="Placeholder text" onfocus="window.hasFocus=1">
    <pre id="console"></pre>
    <script>
        var hasFocus = 0;

        function log(message) {
            document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
        }

        function test() {
            if (!window.eventSender)
                return;

            testRunner.dumpAsText();

            var target = document.getElementById("target");
            var x = target.offsetParent.offsetLeft + target.offsetLeft + target.offsetWidth / 2;
            var y = target.offsetParent.offsetTop + target.offsetTop + target.offsetHeight / 2;

            eventSender.mouseMoveTo(x, y);
            eventSender.mouseDown();
            eventSender.mouseUp();

            log(hasFocus ? "PASS" : "FAIL");
        }
    </script>
</body>
