Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / checked-pseudo-selector.html
blob3a8973c114a3984cb4eac0979b5f666480153f24
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>:checked pseudo selector not matching selected option</title>
5 </head>
6 <body>
8 <p>This is a :checked pseudo selector test.</p>
9 <div id="console"></div>
11 <form action=''>
12 <select id='sel' name='select' multiple>
13 <option id="option1" selected>option1</option>
14 <option id="option2">option2</option>
15 <option id="option3" selected>option3</option>
16 <option id="option4">option4</option>
17 </select>
18 <br>
19 <input id="radio1" type="radio" name="radiotest" value="radio1" /> Radio1
20 <br>
21 <input id="radio2" type="radio" name="radiotest" value="radio2" checked/> Radio2
22 <br>
23 <input id="checkbox1" type="checkbox" name="checktest" value="checkbox1" checked/> Checkbox1
24 <br>
25 <input id="checkbox2" type="checkbox" name="checktest" value="checkbox2" checked/> Checkbox2
26 </form>
27 <br>
28 <script language="JavaScript" type="text/javascript">
29 var totalChecked = 0;
30 var expectedCount = 0;
31 var idArray=new Array("option1","option2","option3","option4","radio1","radio2","checkbox1","checkbox2");
33 if (window.testRunner) {
34 testRunner.dumpAsText();
37 function isCheckedOrSelected(id) {
38 var obj = document.getElementById(id);
39 if (obj.checked || obj.selected)
40 return true;
43 function runTest() {
44 for (var i = 0; i < idArray.length; i++) {
45 if (isCheckedOrSelected(idArray[i]))
46 expectedCount++;
48 totalChecked = document.querySelectorAll(':checked').length;
49 logResult(totalChecked,expectedCount);
52 function logResult(totalChecked, expectedCount) {
53 if (totalChecked != expectedCount)
54 document.write('FAIL - expected: ' + expectedCount + ' and document.querySelectorAll got: ' + totalChecked);
55 else
56 document.write('PASS - expected: ' + expectedCount + ' and document.querySelectorAll got: ' + totalChecked);
57 document.write('<br>');
60 if (window.eventSender) {
61 runTest();
63 </script>
64 </body>
65 </html>