test_radio_radionodelist.html (1948B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=779723 5 --> 6 <head> 7 <title>Test for Bug 779723</title> 8 <script src="/tests/SimpleTest/SimpleTest.js"></script> 9 <script src="/tests/SimpleTest/EventUtils.js"></script> 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=779723">Mozilla Bug 779723</a> 14 <p id="display"></p> 15 <form> 16 <input type="checkbox" name="rdo" value="0" id="r0" checked="checked"> 17 <input type="radio" name="rdo" id="r1"> 18 <input type="radio" name="rdo" id="r2" value="2"> 19 </form> 20 <script class="testbody" type="text/javascript"> 21 /** Test for Bug 779723 */ 22 23 var rdoList = document.forms[0].elements.namedItem('rdo'); 24 is(rdoList.value, "", "The value attribute should be empty"); 25 26 document.getElementById('r2').checked = true; 27 is(rdoList.value, "2", "The value attribute should be 2"); 28 29 document.getElementById('r1').checked = true; 30 is(rdoList.value, "on", "The value attribute should be on"); 31 32 document.getElementById('r1').value = 1; 33 is(rdoList.value, "1", "The value attribute should be 1"); 34 35 is(rdoList.value, document.getElementById('r1').value, 36 "The value attribute should be equal to the first checked radio input element's value"); 37 ok(!document.getElementById('r2').checked, 38 "The second radio input element should not be checked"); 39 40 rdoList.value = '2'; 41 is(rdoList.value, document.getElementById('r2').value, 42 "The value attribute should be equal to the second radio input element's value"); 43 ok(document.getElementById('r2').checked, 44 "The second radio input element should be checked"); 45 46 rdoList.value = '3'; 47 is(rdoList.value, document.getElementById('r2').value, 48 "The value attribute should be the second radio input element's value"); 49 ok(document.getElementById('r2').checked, 50 "The second radio input element should be checked"); 51 52 </script> 53 </pre> 54 </body> 55 </html>