| OLD | NEW |
| 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> | 1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <script src="script-tests/label-control.js"></script> | 7 <script> |
| 8 description('Test that label.control references the correct form control, or nul
l if there is no associated control.'); |
| 9 |
| 10 debug("Find a control that is the first descendent in a label"); |
| 11 document.write("<label id='test1'><input id='inputId1'></label>"); |
| 12 shouldBe("document.getElementById('test1').control.id", "'inputId1'"); |
| 13 |
| 14 debug("Find a control based on a label with valid 'for' attribute"); |
| 15 document.write("<label id='test2' for='inputId2'></label><input id='inputId2' ty
pe='number'>"); |
| 16 shouldBe("document.getElementById('test2').htmlFor", "'inputId2'"); |
| 17 shouldBe("document.getElementById('test2').control.type", "'number'"); |
| 18 |
| 19 debug("Find a control in p element in label"); |
| 20 document.write("<label id='test3'><p><input id='inputId3' type='date'></p></labe
l>"); |
| 21 shouldBe("document.getElementById('test3').control.id", "'inputId3'"); |
| 22 |
| 23 debug("Find a control in fieldset in label."); |
| 24 debug("Note that filedset is a form control that is not labelable."); |
| 25 document.write("<label id='test4'><fieldset><input id='inputId4'></fieldset></la
bel>"); |
| 26 shouldBe("document.getElementById('test4').control.id", "'inputId4'"); |
| 27 |
| 28 debug("Find a control in legend in label."); |
| 29 debug("Note that legend is a form control that is not labelable."); |
| 30 document.write("<label id='test5'><legend><input id='inputId5'></legend></label>
"); |
| 31 shouldBe("document.getElementById('test5').control.id", "'inputId5'"); |
| 32 |
| 33 debug("Find a control in optgroup in label."); |
| 34 debug("Note that optgroup is a form control that is not labelable."); |
| 35 document.write("<label id='test6'><optgroup><input id='inputId6'></optgroup></la
bel>"); |
| 36 shouldBe("document.getElementById('test6').control.id", "'inputId6'"); |
| 37 |
| 38 debug("Find a control in option in label."); |
| 39 debug("Note that option is a form control that is not labelable."); |
| 40 document.write("<label id='test7'><option><input id='inputId7'></option></label>
"); |
| 41 shouldBe("document.getElementById('test7').control.id", "'inputId7'"); |
| 42 |
| 43 debug("Test label with 'for' attribute which is not a valid element id"); |
| 44 document.write("<label for='foo' id='test8'><input id='inputId8'></label>"); |
| 45 shouldBe("document.getElementById('test8').control", "null"); |
| 46 |
| 47 debug("Test label with 'for' attribute which is not a form control"); |
| 48 document.write("<label for='divId' id='test9'><input id='inputId9'></label><div
id='divId'></div>"); |
| 49 shouldBe("document.getElementById('test9').htmlFor", "'divId'"); |
| 50 shouldBe("document.getElementById('test9').control", "null"); |
| 51 |
| 52 debug("Test label with 'for' attribute which is not a labelable form control - f
ieldset"); |
| 53 document.write("<label for='fsId' id='test10'><input id='inputId10'></label><fie
ldset id='fsId'></fieldset>"); |
| 54 shouldBe("document.getElementById('test10').htmlFor", "'fsId'"); |
| 55 shouldBe("document.getElementById('test10').control", "null"); |
| 56 |
| 57 debug("Test label with 'for' attribute which is not a labelable form control - l
egend"); |
| 58 document.write("<label for='legendId' id='test11'><input id='inputId11'></label>
<legend id='legendId'></legend>"); |
| 59 shouldBe("document.getElementById('test11').htmlFor", "'legendId'"); |
| 60 shouldBe("document.getElementById('test11').control", "null"); |
| 61 |
| 62 debug("Test label with 'for' attribute which is not a labelable form control - o
ptgroup"); |
| 63 document.write("<label for='optgroupId' id='test12'><input id='inputId12'></labe
l><optgroup id='optgroupId'></optgroup>"); |
| 64 shouldBe("document.getElementById('test12').htmlFor", "'optgroupId'"); |
| 65 shouldBe("document.getElementById('test12').control", "null"); |
| 66 |
| 67 debug("Test label with 'for' attribute which is not a labelable form control - o
ption"); |
| 68 document.write("<label for='optionId' id='test13'><input id='inputId13'></label>
<option id='optionId'></option>"); |
| 69 shouldBe("document.getElementById('test13').htmlFor", "'optionId'"); |
| 70 shouldBe("document.getElementById('test13').control", "null"); |
| 71 </script> |
| 8 </body> | 72 </body> |
| 9 </html> | 73 </html> |
| OLD | NEW |