summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/select/listbox-select-all.html
blob: 87fdb1e57c3f4084665a61422eb812396c16c427 (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
<html>
    <head>
        <script>
            function test() {
                var sl = document.getElementById('sl');
                sl.focus();
                document.execCommand("SelectAll");
                if (!document.getElementById('o1').selected && !document.getElementById('o2').selected && !document.getElementById('o3').selected)
                    log("Test 1 Passed");
                else
                    log("Test 1 Failed. SelectAll should not change a single-select list box.");
                    
                sl.multiple = true;
                document.execCommand("SelectAll");
                if (document.getElementById('o1').selected && document.getElementById('o2').selected && document.getElementById('o3').selected)
                    log("Test 2 Passed");
                else
                    log("Test 2 Failed. SelectAll should select all items in a multi-select list box.");

                sl.multiple = false;
                
                if (window.testRunner)
                    testRunner.dumpAsText();
            }
            
            function log(msg) {
                var res = document.getElementById('res');
                res.innerHTML = res.innerHTML + msg + "<br>";
            }
        </script>
    </head>
    <body onload="test()">
        This tests that select all works on options in a list box.<br>
        <select id="sl" size=5>
        <option id="o1">1
        <option id="o2">2
        <option id="o3">3
        </select>
        <div id="res"></div>
    </body>
</html>