Chromium Code Reviews| Index: LayoutTests/fast/dom/HTMLInputElement/input-value-null.html |
| diff --git a/LayoutTests/fast/dom/HTMLInputElement/input-value-null.html b/LayoutTests/fast/dom/HTMLInputElement/input-value-null.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..355032e697b52a872fdc2fddb219de6dca3a14e0 |
| --- /dev/null |
| +++ b/LayoutTests/fast/dom/HTMLInputElement/input-value-null.html |
| @@ -0,0 +1,63 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<head> |
| +<script src="../../../resources/testharness.js"></script> |
| +<script src="../../../resources/testharnessreport.js"></script> |
| +<link rel="stylesheet" href="../../../resources/testharness.css"> |
| +</head> |
| +<body> |
| +<p>This test checks that assigning null to HTMLInputElement.value behaves |
| + correctly; i.e. as if the empty string was assigned.</p> |
| +<form style="display: none"> |
| +<input id="text-with-default" type="text" value="default"> |
| +<input id="text-without-default" type="text"> |
| +<input id="hidden" type="hidden" value="value"> |
| +</form> |
| +<script> |
| + test(function () |
|
haraken
2014/07/05 09:45:17
Nit: No style guide for JavaScript, but Blink norm
|
| + { |
|
haraken
2014/07/05 09:45:17
Nit: Ditto.
test(function() {
...;
});
|
| + var input = document.getElementById("text-with-default"); |
| + |
| + assert_equals(input.value, "default"); |
| + assert_equals(input.getAttribute("value"), "default"); |
| + |
| + input.value = "custom"; |
| + |
| + assert_equals(input.value, "custom"); |
| + assert_equals(input.getAttribute("value"), "default"); |
| + |
| + input.value = null; |
| + |
| + assert_equals(input.value, ""); |
| + assert_true(input.hasAttribute("value")); |
| + }, "input[type=text] with value content attribute."); |
| + |
| + test(function () |
| + { |
| + var input = document.getElementById("text-without-default"); |
| + |
| + assert_equals(input.value, ""); |
| + assert_false(input.hasAttribute("value")); |
| + |
| + input.value = null; |
| + |
| + assert_equals(input.value, ""); |
| + assert_false(input.hasAttribute("value")); |
| + }, "input[type=text] without value content attribute."); |
| + |
| + test(function () |
| + { |
| + var input = document.getElementById("hidden"); |
| + |
| + assert_equals(input.value, "value"); |
| + assert_equals(input.getAttribute("value"), "value"); |
| + |
| + input.value = null; |
| + |
| + assert_equals(input.value, ""); |
| + assert_true(input.hasAttribute("value")); |
| + assert_equals(input.getAttribute("value"), ""); |
| + }, "input[type=hidden] with value content attribute."); |
| +</script> |
| +</body> |
| +</html> |