| <!DOCTYPE HTML> |
| <head> |
| <title>input type checkbox</title> |
| <link rel="author" title="Gary Gao" href="mailto:angrytoast@gmail.com"> |
| <link rel="help" href="https://html.spec.whatwg.org/multipage/#checkbox-state-(type=checkbox)"> |
| <script src="/resources/testharness.js"></script> |
| <script src="/resources/testharnessreport.js"></script> |
| </head> |
| <body> |
| <div style="display:none;"> |
| <input id="checkbox_default" type="checkbox" width="20" /> |
| |
| <input id="checkbox_checked" type="checkbox" checked /> |
| |
| <input id="checkbox_indeterminate" type="checkbox" /> |
| |
| <input id="checkbox_default_value" type="checkbox" /> |
| </div> |
| |
| <div id="log"></div> |
| |
| <script> |
| var checkbox_default = document.getElementById('checkbox_default'), |
| checkbox_checked = document.getElementById('checkbox_checked'), |
| checkbox_indeterminate = document.getElementById('checkbox_indeterminate'), |
| checkbox_default_value = document.getElementById('checkbox_default_value'); |
| |
| test(function() { |
| assert_false(checkbox_default.checked); |
| }, "default checkbox has no checkedness state"); |
| |
| test(function() { |
| assert_true(checkbox_checked.checked); |
| }, "checkbox with initial state set to checked has checkedness state"); |
| |
| test(function() { |
| checkbox_default.checked = 'chicken' |
| assert_true(checkbox_default.checked); |
| }, "changing the checked attribute to a string sets the checkedness state"); |
| |
| test(function() { |
| assert_false(checkbox_indeterminate.indeterminate); |
| }, "a checkbox has an indeterminate state set to false onload"); |
| |
| test(function() { |
| checkbox_indeterminate.indeterminate = true, |
| assert_true(checkbox_indeterminate.indeterminate); |
| }, "on setting, a checkbox's indeterminate state must be set to the new value and returns the last value it was set to"); |
| |
| test(function() { |
| assert_equals(checkbox_default_value.value, 'on'); |
| }, "default/on: on getting, if the element has a value attribute, it must return that attribute's value; otherwise, it must return the string 'on'"); |
| |
| test(function() { |
| checkbox_default_value.value = 'chicken' |
| assert_equals(checkbox_default_value.value, 'chicken'); |
| }, "on getting, if the element has a value attribute, it must return that attribute's value"); |
| </script> |
| |
| </body> |