<html>
    <head>
        <title></title>
        <script type="text/javascript">
            var onchangeCount = 0;

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

                testRunner.dumpAsText();

                var popup = document.getElementById("switcher");
                popup.focus();

                eventSender.keyDown("t", null);
                eventSender.keyDown("\r", null);
            }

            function changed(select)
            {
                select.blur();
                onchangeCount++;

                var result = document.getElementById("result");
                result.innerText = onchangeCount == 1 ? "SUCCESS" : "FAILURE: onchange count was " + onchangeCount;
            }
        </script>
    </head>
    <body onload="test()">
        <p>
            Test for <i><a href="http://bugs.webkit.org/show_bug.cgi?id=13857">http://bugs.webkit.org/show_bug.cgi?id=13857</a>
            REGRESSION: onChange function applied to select element executes twice when focus is set</i>.
        </p>
        <p id="result">
            To test interactively, select the other option in the pop up. This text should change to SUCCESS.
        </p>
        <select name="switcher" id="switcher" onchange="changed(this)">
            <option value="one">One</option>
            <option value="two">Two</option>
        </select>
    </body>
</html>
