OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../../../resources/testharness.js"></script> |
| 5 <script src="../../../resources/testharnessreport.js"></script> |
| 6 <link rel="stylesheet" href="../../../resources/testharness.css"> |
| 7 </head> |
| 8 <body> |
| 9 <p>This test checks that assigning null to HTMLInputElement.value behaves |
| 10 correctly; i.e. as if the empty string was assigned.</p> |
| 11 <form style="display: none"> |
| 12 <input id="text-with-default" type="text" value="default"> |
| 13 <input id="text-without-default" type="text"> |
| 14 <input id="hidden" type="hidden" value="value"> |
| 15 </form> |
| 16 <script> |
| 17 |
| 18 test(function () { |
| 19 var input = document.getElementById("text-with-default"); |
| 20 |
| 21 assert_equals(input.value, "default"); |
| 22 assert_equals(input.getAttribute("value"), "default"); |
| 23 |
| 24 input.value = "custom"; |
| 25 |
| 26 assert_equals(input.value, "custom"); |
| 27 assert_equals(input.getAttribute("value"), "default"); |
| 28 |
| 29 input.value = null; |
| 30 |
| 31 assert_equals(input.value, ""); |
| 32 assert_true(input.hasAttribute("value")); |
| 33 }, "input[type=text] with value content attribute."); |
| 34 |
| 35 test(function () { |
| 36 var input = document.getElementById("text-without-default"); |
| 37 |
| 38 assert_equals(input.value, ""); |
| 39 assert_false(input.hasAttribute("value")); |
| 40 |
| 41 input.value = null; |
| 42 |
| 43 assert_equals(input.value, ""); |
| 44 assert_false(input.hasAttribute("value")); |
| 45 }, "input[type=text] without value content attribute."); |
| 46 |
| 47 test(function () { |
| 48 var input = document.getElementById("hidden"); |
| 49 |
| 50 assert_equals(input.value, "value"); |
| 51 assert_equals(input.getAttribute("value"), "value"); |
| 52 |
| 53 input.value = null; |
| 54 |
| 55 assert_equals(input.value, ""); |
| 56 assert_true(input.hasAttribute("value")); |
| 57 assert_equals(input.getAttribute("value"), ""); |
| 58 }, "input[type=hidden] with value content attribute."); |
| 59 |
| 60 </script> |
| 61 </body> |
| 62 </html> |
OLD | NEW |