2006-12-18 Kirby White <KWhiteRight@gmail.com>
[WebKit-https.git] / LayoutTests / fast / dom / HTMLInputElement / input-checked-reset.html
1 <html>
2 <head>
3 </head>
4 <body>
5 <form>
6 <input id="checkboxUnchecked" type="checkbox" value="Unchecked"><br>
7 <input id="checkboxChecked" type="checkbox" value="Checked" checked="checked"><br>
8 <input id="radioUnchecked" name="radio1" type="radio" value="Unchecked"><br>
9 <input id="radioChecked" name="radio1" type="radio" value="Checked" checked="checked"><br>
10
11 <input id="inputReset" type="reset">
12 <button id="buttonReset" type="reset">Reset Button</button>
13 </form>
14 <p>This test verifies that check-type input form controls are properly reset by
15 both a reset input control and a reset button control.
16
17 <p>You should see four element IDs below, and the word "SUCCESS" twice after each:</p>
18
19 <script>
20 if (window.layoutTestController)
21     layoutTestController.dumpAsText();
22 var inputReset = document.getElementById("inputReset");
23 var buttonReset = document.getElementById("buttonReset");
24
25 function testChecked(testElement, expected, button)
26 {
27     var success = false;
28     if (testElement.checked == expected)
29     {
30         testElement.checked = !expected;
31         button.click();
32         if (testElement.checked == expected)
33             success = true;
34     }
35     if (success)
36         document.writeln(": SUCCESS");
37     else
38         document.writeln(": FAILED (checked = " + testElement.checked + ")");
39 }
40
41 function test(elementId, expected)
42 {
43     var element = document.getElementById(elementId);
44     document.writeln(elementId);
45     testChecked(element, expected, inputReset);
46     testChecked(element, expected, buttonReset);
47     document.writeln("<br>");
48 }
49
50 test("checkboxUnchecked", false);
51 test("checkboxChecked", true);
52 test("radioUnchecked", false);
53 test("radioChecked", true);
54 </script>
55 </body>
56 </html>