chromium/third_party/blink/web_tests/fast/css/checked-pseudo-selector.html

<!DOCTYPE html>
<html>
<head>
<title>:checked pseudo selector not matching selected option</title>
</head>
<body>

<p>This is a :checked pseudo selector test.</p>
<div id="console"></div>

<form action=''>
<select id='sel' name='select' multiple>
    <option id="option1" selected>option1</option>
    <option id="option2">option2</option>
    <option id="option3" selected>option3</option>
    <option id="option4">option4</option>
</select>
<br>
<input id="radio1" type="radio" name="radiotest" value="radio1" /> Radio1
<br>
<input id="radio2" type="radio" name="radiotest" value="radio2" checked/> Radio2
<br>
<input id="checkbox1" type="checkbox" name="checktest" value="checkbox1" checked/> Checkbox1
<br>
<input id="checkbox2" type="checkbox" name="checktest" value="checkbox2" checked/> Checkbox2
</form>
<br>
<script language="JavaScript" type="text/javascript">
var totalChecked = 0;
var expectedCount = 0;
var idArray=new Array("option1","option2","option3","option4","radio1","radio2","checkbox1","checkbox2");

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

function isCheckedOrSelected(id) {
    var obj = document.getElementById(id);
    if (obj.checked || obj.selected)
        return true;
}

function runTest() {
    for (var i = 0; i < idArray.length; i++) {
        if (isCheckedOrSelected(idArray[i]))
            expectedCount++;
    }
    totalChecked = document.querySelectorAll(':checked').length;
    logResult(totalChecked,expectedCount);
}

function logResult(totalChecked, expectedCount) {
     if (totalChecked != expectedCount)
        document.write('FAIL - expected: ' + expectedCount + ' and document.querySelectorAll got: ' + totalChecked);
    else
        document.write('PASS - expected: ' + expectedCount + ' and document.querySelectorAll got: ' + totalChecked);
    document.write('<br>');
    }

if (window.eventSender) {
    runTest();
 }
</script>
</body>
</html>