<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="../../../resources/js-test.js"></script>
<script>
window.jsTestIsAsync = true;

var finishTest = false;

function selectInputDispatched() {
    debug("PASS");
    if (finishTest)
        finishJSTest();
}

function test() {
    document.getElementById("bug-test").focus();
    if (window.eventSender) {
        debug("Pressing down arrow key");
        eventSender.keyDown('downArrow');

        debug("Pressing down arrow key");
        eventSender.keyDown('downArrow');

        debug("Pressing up arrow key");
        eventSender.keyDown('upArrow');

        debug("Pressing page down key");
        eventSender.keyDown('pageDown');

        debug("Pressing page up key");
        eventSender.keyDown('pageUp');

        debug("Pressing end key");
        eventSender.keyDown('end');

        finishTest = true;

        debug("Pressing home key");
        eventSender.keyDown('home');
    } else {
        debug("Test manually by pressing up/down key. Should get PASS message");
        finishJSTest();
    }
}

successfullyParsed = true;
</script>
</head>
<body onload="test()">
<p>Selecting listbox options should fire input event</p>

<select id="bug-test" onInput="selectInputDispatched()" multiple="multiple">
  <option>option 1</option>
  <option>option 2</option>
  <option>option 3</option>
  <option>option 4</option>
</select>

<div id="console"></div>
</body>
</html>
