summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/select/listbox-scroll-after-options-removed.html
blob: c1f6031ce9dc8cd374017a1b983d9186d76e70fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>
    <head>
        <script>
        function test()
        {
            if (window.testRunner) {
                testRunner.dumpAsText();
                testRunner.waitUntilDone();
            }

            setTimeout(test2, 0);
        }
        
        function test2()
        {
            var select = document.getElementById("listbox");
            while (select.hasChildNodes())
                select.removeChild(select.firstChild);

            var option = document.createElement("option");
            option.innerText = "Test Passed";
            select.appendChild(option);
        
            var scrollTop = select.scrollTop;
            if (scrollTop == 0)
                log("Test Passed");
            else
                log("Test Failed.  scrollTop = " + scrollTop + " even though there is only one option in the listbox");
            
            if (window.testRunner)
                testRunner.notifyDone();
        }
        
        function log(msg)
        {
            document.getElementById('console').appendChild(document.createTextNode(msg + '\n'));
        }
        </script>
    </head>
    <body onload="test()">
        <a href="http://bugs.webkit.org/show_bug.cgi?id=15252">Bug 15252: &lt;select multiple&gt; doesn't scroll to top when old options are removed and new ones are added, leaving listbox empty-looking</a>

        <p>When the test runs, all the &lt;option&gt;s in the select are removed and replaced with 1 new option. If the bug is present, the select will appear empty until you scroll up with the mousewheel.</p>

        <select id="listbox" size="4">
            <option>1</option>
            <option>2</option>
            <option>3</option>
            <option>4</option>
            <option>5</option>
            <option selected>6</option>
        </select>
        <pre id="console"></pre>
    </body>
</html>