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

Side by Side Diff: LayoutTests/fast/forms/time/time-valueasnumber.html

Issue 149413004: HTMLInputElement.valueAsNumber compliance (NaN handling.) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 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
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../../resources/js-test.js"></script> 4 <script src="../../../resources/js-test.js"></script>
5 </head> 5 </head>
6 <body> 6 <body>
7 <p id="description"></p> 7 <p id="description"></p>
8 <div id="console"></div> 8 <div id="console"></div>
9 <script> 9 <script>
10 description('Tests for .valueAsNumber with &lt;input type=time>.'); 10 description('Tests for .valueAsNumber with &lt;input type=time>.');
(...skipping 21 matching lines...) Expand all
32 shouldBe('setValueAsNumberAndGetValue(0, 0, 0, 2)', '"00:00:00.002"'); 32 shouldBe('setValueAsNumberAndGetValue(0, 0, 0, 2)', '"00:00:00.002"');
33 shouldBe('setValueAsNumberAndGetValue(11, 59, 59, 999)', '"11:59:59.999"'); 33 shouldBe('setValueAsNumberAndGetValue(11, 59, 59, 999)', '"11:59:59.999"');
34 shouldBe('setValueAsNumberAndGetValue(12, 0, 0, 0)', '"12:00"'); 34 shouldBe('setValueAsNumberAndGetValue(12, 0, 0, 0)', '"12:00"');
35 shouldBe('setValueAsNumberAndGetValue(23, 59, 59, 999)', '"23:59:59.999"'); 35 shouldBe('setValueAsNumberAndGetValue(23, 59, 59, 999)', '"23:59:59.999"');
36 shouldBe('setValueAsNumberAndGetValue(24, 0, 0, 0)', '"00:00"'); 36 shouldBe('setValueAsNumberAndGetValue(24, 0, 0, 0)', '"00:00"');
37 shouldBe('setValueAsNumberAndGetValue(48, 0, 13, 0)', '"00:00:13"'); 37 shouldBe('setValueAsNumberAndGetValue(48, 0, 13, 0)', '"00:00:13"');
38 shouldBe('setValueAsNumberAndGetValue(-23, -59, -59, 0)', '"00:00:01"'); 38 shouldBe('setValueAsNumberAndGetValue(-23, -59, -59, 0)', '"00:00:01"');
39 39
40 debug('Tests to set invalid values to valueAsNumber:'); 40 debug('Tests to set invalid values to valueAsNumber:');
41 shouldBe('input.value = ""; input.valueAsNumber = null; input.value', '"00:00"') ; 41 shouldBe('input.value = ""; input.valueAsNumber = null; input.value', '"00:00"') ;
42 shouldThrow('input.valueAsNumber = "foo"', '"NotSupportedError: Failed to set th e \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is not a number."'); 42 shouldBeNaN('input.valueAsNumber = "foo"; input.valueAsNumber');
43 shouldThrow('input.valueAsNumber = NaN', '"NotSupportedError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is not a number."'); 43 shouldBeEqualToString('input.valueAsNumber = "foo"; input.value', '');
44 shouldThrow('input.valueAsNumber = Number.NaN', '"NotSupportedError: Failed to s et the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is not a number."'); 44 shouldBeNaN('input.valueAsNumber = NaN; input.valueAsNumber');
45 shouldThrow('input.valueAsNumber = Infinity', '"NotSupportedError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is i nfinite."'); 45 shouldBeEqualToString('input.valueAsNumber = NaN; input.value', '');
46 shouldThrow('input.valueAsNumber = Number.POSITIVE_INFINITY', '"NotSupportedErro r: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The val ue provided is infinite."'); 46 shouldBeNaN('input.valueAsNumber = Number.NaN; input.valueAsNumber');
47 shouldThrow('input.valueAsNumber = Number.NEGATIVE_INFINITY', '"NotSupportedErro r: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The val ue provided is infinite."'); 47 shouldBeEqualToString('input.valueAsNumber = Number.NaN; input.value', '');
48 shouldThrow('input.valueAsNumber = Infinity', '"TypeError: Failed to set the \'v alueAsNumber\' property on \'HTMLInputElement\': The value provided is infinite. "');
49 shouldThrow('input.valueAsNumber = Number.POSITIVE_INFINITY', '"TypeError: Faile d to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provi ded is infinite."');
50 shouldThrow('input.valueAsNumber = Number.NEGATIVE_INFINITY', '"TypeError: Faile d to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provi ded is infinite."');
48 51
49 debug('Step attribute value and string representation:'); 52 debug('Step attribute value and string representation:');
50 // If the step attribute value is 1 second and the second part is 0, we should s how the second part. 53 // If the step attribute value is 1 second and the second part is 0, we should s how the second part.
51 shouldBe('input.step = "1"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:00:00 "'); 54 shouldBe('input.step = "1"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:00:00 "');
52 // If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part. 55 // If the step attribute value is 0.001 second and the millisecond part is 0, we should show the millisecond part.
53 shouldBe('input.step = "0.001"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:0 0:00.000"'); 56 shouldBe('input.step = "0.001"; setValueAsNumberAndGetValue(0, 0, 0, 0)', '"00:0 0:00.000"');
54 </script> 57 </script>
55 </body> 58 </body>
56 </html> 59 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698