diff options
Diffstat (limited to 'LayoutTests/fast/dom/HTMLLabelElement')
10 files changed, 280 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/HTMLLabelElement/click-label-expected.txt b/LayoutTests/fast/dom/HTMLLabelElement/click-label-expected.txt new file mode 100644 index 0000000..442e91c --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/click-label-expected.txt @@ -0,0 +1,5 @@ +This tests that the correct form control element is clicked when clicking on a label. If the test is successful, the text "SUCCESS" should show below. +label1inc +label2inc + +SUCCESS diff --git a/LayoutTests/fast/dom/HTMLLabelElement/click-label.html b/LayoutTests/fast/dom/HTMLLabelElement/click-label.html new file mode 100644 index 0000000..b8dbfbd --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/click-label.html @@ -0,0 +1,43 @@ +<html> +<head> +<script> +var clickcount = 0; +function dispatchClickEvent(target) { + // Create a click event and dispatch it + var event = document.createEvent('UIEvents'); + event.initUIEvent('click', true, true, window, 1) + target.dispatchEvent(event); +} + +function runTest() { + if (window.layoutTestController) + layoutTestController.dumpAsText(); + + var label1 = document.getElementById('label1'); + dispatchClickEvent(label1); + if (clickcount < 1) + return; + + var label2 = document.getElementById('label2'); + dispatchClickEvent(label2); + if (clickcount < 2) + return; + document.getElementById('result').innerHTML = 'SUCCESS' +} + +function inc() +{ + clickcount++; +} +</script> +</head> +<body onload="runTest()"> +This tests that the correct form control element is clicked when clicking on a label. +If the test is successful, the text "SUCCESS" should show below.<br> +<Label id="label1">label1<button onclick="inc();">inc</button></label><br> +<Label id="label2">label2<fieldset><legend><button onclick="inc();">inc</button></legend></fieldset></label><br> +<div id="result">FAILURE</div> + +</body> +</html> + diff --git a/LayoutTests/fast/dom/HTMLLabelElement/focus-label-expected.txt b/LayoutTests/fast/dom/HTMLLabelElement/focus-label-expected.txt new file mode 100644 index 0000000..ff90b5d --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/focus-label-expected.txt @@ -0,0 +1,5 @@ +This tests that the correct form control element is activated when clicking on a label. If the test is successful, the text "SUCCESS" should show below. +label1 +label2 + +SUCCESS diff --git a/LayoutTests/fast/dom/HTMLLabelElement/focus-label.html b/LayoutTests/fast/dom/HTMLLabelElement/focus-label.html new file mode 100644 index 0000000..b1f697d --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/focus-label.html @@ -0,0 +1,32 @@ +<html> +<head> +<script> + +function runTest() { + if (window.layoutTestController) + layoutTestController.dumpAsText(); + + var label1 = document.getElementById('label1'); + label1.focus(); + if (document.getElementById('cb1') != document.activeElement) + return; + + var label2 = document.getElementById('label2'); + label2.focus(); + if (document.getElementById('cb2') != document.activeElement) + return; + document.getElementById('result').innerHTML = 'SUCCESS' +} + +</script> +</head> +<body onload="runTest()"> +This tests that the correct form control element is activated when clicking on a label. +If the test is successful, the text "SUCCESS" should show below.<br> +<Label id="label1">label1<input id="cb1" type="checkbox"></label><br> +<Label id="label2">label2<fieldset><legend><input id="cb2" type="checkbox"></legend></fieldset></label><br> +<div id="result">FAILURE</div> + +</body> +</html> + diff --git a/LayoutTests/fast/dom/HTMLLabelElement/form/test1-expected.txt b/LayoutTests/fast/dom/HTMLLabelElement/form/test1-expected.txt new file mode 100644 index 0000000..e374b37 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/form/test1-expected.txt @@ -0,0 +1,7 @@ +This test attempts to access an HTMLLabelElement's form property. The first test accesses the form property of an label which is inside of a form. The second test accesses the form property of an label which is not inside of a form + +Passed + +Passed + + diff --git a/LayoutTests/fast/dom/HTMLLabelElement/form/test1.html b/LayoutTests/fast/dom/HTMLLabelElement/form/test1.html new file mode 100644 index 0000000..6a30bd0 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/form/test1.html @@ -0,0 +1,46 @@ +<html> + <head> + <script language="javascript"> + function print(message) + { + var paragraph = document.createElement("p"); + paragraph.appendChild(document.createTextNode(message)); + document.getElementById("console").appendChild(paragraph); + } + function test() + { + if(window.layoutTestController) + layoutTestController.dumpAsText(); + + labelInsideForm = document.getElementById("labelInsideForm"); + labelNotInsideForm = document.getElementById("labelNotInsideForm"); + + form = document.getElementById("form"); + + if(labelInsideForm.form == form) + print("Passed"); + else + print("Failed"); + + if(labelNotInsideForm.form == null) + print("Passed"); + else + print("Failed"); + } + </script> + </head> + + <body onload="test();"> + <p>This test attempts to access an HTMLLabelElement's form property. The first test accesses the form property of an label which is inside of a form. The second test accesses the form property of an label which is not inside of a form</p> + + <div id="console"></div> + + <form id="form"> + <label id="labelInsideForm"> + </label> + </form> + + <label id="labelNotInsideForm"> + </label> + </body> +</html> diff --git a/LayoutTests/fast/dom/HTMLLabelElement/label-control-expected.txt b/LayoutTests/fast/dom/HTMLLabelElement/label-control-expected.txt new file mode 100644 index 0000000..bb127c6 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/label-control-expected.txt @@ -0,0 +1,51 @@ +Test that label.control references the correct form control, or null if there is no associated control. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +Find a control that is the first descendent in a label +PASS document.getElementById('test1').control.id is 'inputId1' +Find a control based on a label with valid 'for' attribute +PASS document.getElementById('test2').htmlFor is 'inputId2' +PASS document.getElementById('test2').control.type is 'number' +Find a control in p element in label +PASS document.getElementById('test3').control.id is 'inputId3' +Find a control in fieldset in label. +Note that filedset is a form control that is not labelable. +PASS document.getElementById('test4').control.id is 'inputId4' +Find a control in legend in label. +Note that legend is a form control that is not labelable. +PASS document.getElementById('test5').control.id is 'inputId5' +Find a control in optgroup in label. +Note that optgroup is a form control that is not labelable. +PASS document.getElementById('test6').control.id is 'inputId6' +Find a control in option in label. +Note that option is a form control that is not labelable. +PASS document.getElementById('test7').control.id is 'inputId7' +Test label with 'for' attribute which is not a valid element id +PASS document.getElementById('test8').control is null +Test label with 'for' attribute which is not a form control +PASS document.getElementById('test9').htmlFor is 'divId' +PASS document.getElementById('test9').control is null +Test label with 'for' attribute which is not a labelable form control - fieldset +PASS document.getElementById('test10').htmlFor is 'fsId' +PASS document.getElementById('test10').control is null +Test label with 'for' attribute which is not a labelable form control - legend +PASS document.getElementById('test11').htmlFor is 'legendId' +PASS document.getElementById('test11').control is null +Test label with 'for' attribute which is not a labelable form control - optgroup +PASS document.getElementById('test12').htmlFor is 'optgroupId' +PASS document.getElementById('test12').control is null +Test label with 'for' attribute which is not a labelable form control - option +PASS document.getElementById('test13').htmlFor is 'optionId' +PASS document.getElementById('test13').control is null +PASS successfullyParsed is true + +TEST COMPLETE + + + + + + + diff --git a/LayoutTests/fast/dom/HTMLLabelElement/label-control.html b/LayoutTests/fast/dom/HTMLLabelElement/label-control.html new file mode 100644 index 0000000..cd0691f --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/label-control.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="script-tests/label-control.js"></script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/HTMLLabelElement/script-tests/TEMPLATE.html b/LayoutTests/fast/dom/HTMLLabelElement/script-tests/TEMPLATE.html new file mode 100644 index 0000000..1951c43 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/script-tests/TEMPLATE.html @@ -0,0 +1,13 @@ +<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> +<html> +<head> +<link rel="stylesheet" href="../../js/resources/js-test-style.css"> +<script src="../../js/resources/js-test-pre.js"></script> +</head> +<body> +<p id="description"></p> +<div id="console"></div> +<script src="YOUR_JS_FILE_HERE"></script> +<script src="../../js/resources/js-test-post.js"></script> +</body> +</html> diff --git a/LayoutTests/fast/dom/HTMLLabelElement/script-tests/label-control.js b/LayoutTests/fast/dom/HTMLLabelElement/script-tests/label-control.js new file mode 100644 index 0000000..7a93c12 --- /dev/null +++ b/LayoutTests/fast/dom/HTMLLabelElement/script-tests/label-control.js @@ -0,0 +1,65 @@ +description('Test that label.control references the correct form control, or null if there is no associated control.'); + +debug("Find a control that is the first descendent in a label"); +document.write("<label id='test1'><input id='inputId1'></label>"); +shouldBe("document.getElementById('test1').control.id", "'inputId1'"); + +debug("Find a control based on a label with valid 'for' attribute"); +document.write("<label id='test2' for='inputId2'></label><input id='inputId2' type='number'>"); +shouldBe("document.getElementById('test2').htmlFor", "'inputId2'"); +shouldBe("document.getElementById('test2').control.type", "'number'"); + +debug("Find a control in p element in label"); +document.write("<label id='test3'><p><input id='inputId3' type='date'></p></label>"); +shouldBe("document.getElementById('test3').control.id", "'inputId3'"); + +debug("Find a control in fieldset in label."); +debug("Note that filedset is a form control that is not labelable."); +document.write("<label id='test4'><fieldset><input id='inputId4'></fieldset></label>"); +shouldBe("document.getElementById('test4').control.id", "'inputId4'"); + +debug("Find a control in legend in label."); +debug("Note that legend is a form control that is not labelable."); +document.write("<label id='test5'><legend><input id='inputId5'></legend></label>"); +shouldBe("document.getElementById('test5').control.id", "'inputId5'"); + +debug("Find a control in optgroup in label."); +debug("Note that optgroup is a form control that is not labelable."); +document.write("<label id='test6'><optgroup><input id='inputId6'></optgroup></label>"); +shouldBe("document.getElementById('test6').control.id", "'inputId6'"); + +debug("Find a control in option in label."); +debug("Note that option is a form control that is not labelable."); +document.write("<label id='test7'><option><input id='inputId7'></option></label>"); +shouldBe("document.getElementById('test7').control.id", "'inputId7'"); + +debug("Test label with 'for' attribute which is not a valid element id"); +document.write("<label for='foo' id='test8'><input id='inputId8'></label>"); +shouldBe("document.getElementById('test8').control", "null"); + +debug("Test label with 'for' attribute which is not a form control"); +document.write("<label for='divId' id='test9'><input id='inputId9'></label><div id='divId'></div>"); +shouldBe("document.getElementById('test9').htmlFor", "'divId'"); +shouldBe("document.getElementById('test9').control", "null"); + +debug("Test label with 'for' attribute which is not a labelable form control - fieldset"); +document.write("<label for='fsId' id='test10'><input id='inputId10'></label><fieldset id='fsId'></fieldset>"); +shouldBe("document.getElementById('test10').htmlFor", "'fsId'"); +shouldBe("document.getElementById('test10').control", "null"); + +debug("Test label with 'for' attribute which is not a labelable form control - legend"); +document.write("<label for='legendId' id='test11'><input id='inputId11'></label><legend id='legendId'></legend>"); +shouldBe("document.getElementById('test11').htmlFor", "'legendId'"); +shouldBe("document.getElementById('test11').control", "null"); + +debug("Test label with 'for' attribute which is not a labelable form control - optgroup"); +document.write("<label for='optgroupId' id='test12'><input id='inputId12'></label><optgroup id='optgroupId'></optgroup>"); +shouldBe("document.getElementById('test12').htmlFor", "'optgroupId'"); +shouldBe("document.getElementById('test12').control", "null"); + +debug("Test label with 'for' attribute which is not a labelable form control - option"); +document.write("<label for='optionId' id='test13'><input id='inputId13'></label><option id='optionId'></option>"); +shouldBe("document.getElementById('test13').htmlFor", "'optionId'"); +shouldBe("document.getElementById('test13').control", "null"); + +var successfullyParsed = true; |