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

Side by Side 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: the fix 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 test(function ()
haraken 2014/07/05 09:45:17 Nit: No style guide for JavaScript, but Blink norm
18 {
haraken 2014/07/05 09:45:17 Nit: Ditto. 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 {
37 var input = document.getElementById("text-without-default");
38
39 assert_equals(input.value, "");
40 assert_false(input.hasAttribute("value"));
41
42 input.value = null;
43
44 assert_equals(input.value, "");
45 assert_false(input.hasAttribute("value"));
46 }, "input[type=text] without value content attribute.");
47
48 test(function ()
49 {
50 var input = document.getElementById("hidden");
51
52 assert_equals(input.value, "value");
53 assert_equals(input.getAttribute("value"), "value");
54
55 input.value = null;
56
57 assert_equals(input.value, "");
58 assert_true(input.hasAttribute("value"));
59 assert_equals(input.getAttribute("value"), "");
60 }, "input[type=hidden] with value content attribute.");
61 </script>
62 </body>
63 </html>
OLDNEW
« 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