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