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

Side by Side Diff: LayoutTests/fast/forms/number/number-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 <script> 7 <script>
8 description('Tests for .valueAsNumber with &lt;input type=number>.'); 8 description('Tests for .valueAsNumber with &lt;input type=number>.');
9 9
10 var input = document.createElement('input'); 10 var input = document.createElement('input');
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 shouldBeTrue('isNaN(valueAsNumberFor("nan"))'); 46 shouldBeTrue('isNaN(valueAsNumberFor("nan"))');
47 shouldBeTrue('isNaN(valueAsNumberFor("Inf"))'); 47 shouldBeTrue('isNaN(valueAsNumberFor("Inf"))');
48 shouldBeTrue('isNaN(valueAsNumberFor("inf"))'); 48 shouldBeTrue('isNaN(valueAsNumberFor("inf"))');
49 shouldBeTrue('isNaN(valueAsNumberFor("Infinity"))'); 49 shouldBeTrue('isNaN(valueAsNumberFor("Infinity"))');
50 shouldBeTrue('isNaN(valueAsNumberFor("infinity"))'); 50 shouldBeTrue('isNaN(valueAsNumberFor("infinity"))');
51 51
52 debug('Too huge exponent to support'); 52 debug('Too huge exponent to support');
53 shouldBeTrue('isNaN(valueAsNumberFor("1.2E65535"))'); 53 shouldBeTrue('isNaN(valueAsNumberFor("1.2E65535"))');
54 54
55 debug('Tests for the valueAsNumber setter:'); 55 debug('Tests for the valueAsNumber setter:');
56 shouldBe('setValueAsNumberAndGetValue(0)', '"0"'); 56 shouldBeEqualToString('setValueAsNumberAndGetValue(0)', '0');
57 shouldBe('setValueAsNumberAndGetValue(10)', '"10"'); 57 shouldBeEqualToString('setValueAsNumberAndGetValue(10)', '10');
58 shouldBe('setValueAsNumberAndGetValue(01)', '"1"'); 58 shouldBeEqualToString('setValueAsNumberAndGetValue(01)', '1');
59 shouldBe('setValueAsNumberAndGetValue(-0)', '"0"'); 59 shouldBeEqualToString('setValueAsNumberAndGetValue(-0)', '0');
60 shouldBe('setValueAsNumberAndGetValue(-1.2)', '"-1.2"'); 60 shouldBeEqualToString('setValueAsNumberAndGetValue(-1.2)', '-1.2');
61 shouldBe('setValueAsNumberAndGetValue(1.2e10)', '"12000000000"'); 61 shouldBeEqualToString('setValueAsNumberAndGetValue(1.2e10)', '12000000000');
62 shouldBe('setValueAsNumberAndGetValue(1.2e-10)', '"1.2e-10"'); 62 shouldBeEqualToString('setValueAsNumberAndGetValue(1.2e-10)', '1.2e-10');
63 shouldBe('setValueAsNumberAndGetValue(1.2345678901234567e+38)', '"1.234567890123 4567e+38"'); 63 shouldBeEqualToString('setValueAsNumberAndGetValue(1.2345678901234567e+38)', '1. 2345678901234567e+38');
64 shouldBe('setValueAsNumberAndGetValue("-3.40282346e+38")', '"-3.40282346e+38"'); 64 shouldBeEqualToString('setValueAsNumberAndGetValue("-3.40282346e+38")', '-3.4028 2346e+38');
65 shouldThrow('setValueAsNumberAndGetValue("-3.40282348e+38")', '"InvalidStateErro r: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The val ue provided (-3.40282e+38) is outside the range (-3.40282e+38, 3.40282e+38)."'); 65 shouldThrow('setValueAsNumberAndGetValue("-3.40282348e+38")', '"InvalidStateErro r: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The val ue provided (-3.40282e+38) is outside the range (-3.40282e+38, 3.40282e+38)."');
66 shouldBe('setValueAsNumberAndGetValue("3.40282346e+38")', '"3.40282346e+38"'); 66 shouldBe('setValueAsNumberAndGetValue("3.40282346e+38")', '"3.40282346e+38"');
67 shouldThrow('setValueAsNumberAndGetValue("3.40282348e+38")', '"InvalidStateError : Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The valu e provided (3.40282e+38) is outside the range (-3.40282e+38, 3.40282e+38)."'); 67 shouldThrow('setValueAsNumberAndGetValue("3.40282348e+38")', '"InvalidStateError : Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The valu e provided (3.40282e+38) is outside the range (-3.40282e+38, 3.40282e+38)."');
68 68
69 debug('Tests to set invalid values to valueAsNumber:'); 69 debug('Tests to set invalid values to valueAsNumber:');
70 shouldBe('setValueAsNumberAndGetValue(null)', '"0"'); 70 shouldBeEqualToString('setValueAsNumberAndGetValue(null)', '0');
71 shouldThrow('setValueAsNumberAndGetValue("foo")', '"NotSupportedError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is not a number."'); 71 shouldBeEqualToString('setValueAsNumberAndGetValue("foo")', '');
72 shouldThrow('setValueAsNumberAndGetValue(NaN)', '"NotSupportedError: Failed to s et the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is not a number."'); 72 shouldBeEqualToString('setValueAsNumberAndGetValue(NaN)', '');
73 shouldThrow('setValueAsNumberAndGetValue(Number.NaN)', '"NotSupportedError: Fail ed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value prov ided is not a number."'); 73 shouldBeEqualToString('setValueAsNumberAndGetValue(Number.NaN)', '');
74 shouldThrow('setValueAsNumberAndGetValue(Infinity)', '"NotSupportedError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provid ed is infinite."'); 74 shouldThrow('setValueAsNumberAndGetValue(Infinity)', '"TypeError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is in finite."');
75 shouldThrow('setValueAsNumberAndGetValue(Number.POSITIVE_INFINITY)', '"NotSuppor tedError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is infinite."'); 75 shouldThrow('setValueAsNumberAndGetValue(Number.POSITIVE_INFINITY)', '"TypeError : Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The valu e provided is infinite."');
76 shouldThrow('setValueAsNumberAndGetValue(Number.NEGATIVE_INFINITY)', '"NotSuppor tedError: Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The value provided is infinite."'); 76 shouldThrow('setValueAsNumberAndGetValue(Number.NEGATIVE_INFINITY)', '"TypeError : Failed to set the \'valueAsNumber\' property on \'HTMLInputElement\': The valu e provided is infinite."');
77 </script> 77 </script>
78 </body> 78 </body>
79 </html> 79 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698