Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(174)

Unified Diff: LayoutTests/fast/dom/HTMLInputElement/input-value-null.html

Issue 372543002: Use [TreatNullAs=EmptyString] for HTMLInputElement.value (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: testcase style adjustment Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLInputElement/input-value-null-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..5e33ecde1784aa90c85fb7d254a8e3d8e960b2be
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLInputElement/input-value-null.html
@@ -0,0 +1,62 @@
+<!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 () {
+ 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>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLInputElement/input-value-null-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698