summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/forms/select-no-name.html
blob: 4c3f8c02589e1a0cdcf89ab5a030d4098b105220 (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
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
    <title>Submit</title>
    <style type="text/css">
    h2 {
        display: none;
        
    }
    #pass {
        background: #0f0;
    }
    #fail {
        background: Red;
    }
    </style>
</head>
<body onload="test()">
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=20184">bug 20184</a>:
SELECT with no name generates invalid query string.</p>
<form action="">
<select><option disabled>invalid</option></select>
<select><option disabled></option></select>

<input type='hidden' id="done" name="done" value="true"/>
<input type="hidden" id="id" name="id" value="123"/>
</form>
<h2 id="pass">PASS</h2>
<h2 id="fail">FAIL</h2>
<script type="text/javascript">
if (window.testRunner) {
    testRunner.waitUntilDone();
    testRunner.dumpAsText();
}

function test() {
    var id = document.getElementById('id');
    
    // Options with "disabled" or "invalid" value
    // are are failures here.
    if(location.search && /invalid|disabled/.test(location.search)) {
      document.getElementById("fail").style.display = "inline-block";
    } else {
        if(location.search) {
            var m = location.search.match(/id=(\d+)/);
            if(m && m[1]) {
                id.value = m[1];
            } else {
                id.disabled = true;
            }
        } else id.disabled = true;
        
        if(!/done=true/.test(location.search)) {
            document.forms[0].submit();
            return;
        } 
        document.getElementById("pass").style.display = "inline-block";
    }
    if (window.testRunner)
        testRunner.notifyDone();
};
</script>
<p>
<a href="javascript:history.back();">reload</a>
</p>
</body>
</html>