chromium/third_party/blink/web_tests/fast/forms/select/select-change-popup-to-listbox-roundtrip.html

<html>
<script>

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

function runTest()
{
    var s1 = document.getElementById("s1");
    s1.size = 1;
    s1.size = 5;

    var s2 = document.getElementById("s2");
    s2.size = 1;
    // force layout.
    document.body.offsetTop;
    s2.size = 5;

    var s3 = document.getElementById("s3");
    s3.size = 1;
    setTimeout(function()
    {
        s3.size = 5;
        reportResults();
    }, 0);
}

function reportResults()
{
    var selected1 = s1.selectedIndex;
    var selected2 = s2.selectedIndex;
    var selected3 = s3.selectedIndex;
    document.getElementById("test").innerHTML = "<ul>" +
        "<li>Changing the size of a select element from 5 to 1 and back 5 should acquire selection of the first item: " + (selected1 == 0 ? "PASS" : "FAIL") +
        "<li>Forcing layout should not affect the outcome: " + (selected2 == selected1 ? "PASS" : "FAIL") +
        "<li>And neither should dropping out of the message loop: " + (selected3 == selected1 ? "PASS" : "FAIL") +
        "</ul>";

    if (window.testRunner)
        testRunner.notifyDone();
}

</script>
<body onload="runTest()">
    <div id="test">
        <select id="s1" size="5"><option>test</select>
        <select id="s2" size="5"><option>test</select>
        <select id="s3" size="5"><option>test</select>
    </div>
</body>