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

Side by Side Diff: LayoutTests/fast/forms/number/number-stepup-stepdown.html

Issue 136783006: Upgrade stepUp()/stepDown() implementation to match spec. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: applyStep(): add missing EventQueueScope 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('Check stepUp() and stepDown() bahevior for number type.'); 8 description('Check stepUp() and stepDown() behavior for number type.');
9 9
10 var input = document.createElement('input'); 10 var input = document.createElement('input');
11 11
12 function setInputAttributes(min, max, step, value) { 12 function setInputAttributes(min, max, step, value) {
13 input.min = min; 13 input.min = min;
14 input.max = max; 14 input.max = max;
15 input.step = step; 15 input.step = step;
16 input.value = value; 16 input.value = value;
17 } 17 }
18 18
(...skipping 29 matching lines...) Expand all
48 if (typeof stepCount !== 'undefined') 48 if (typeof stepCount !== 'undefined')
49 input.stepDown(stepCount); 49 input.stepDown(stepCount);
50 else 50 else
51 input.stepDown(); 51 input.stepDown();
52 return input.value; 52 return input.value;
53 } 53 }
54 54
55 debug('Number type'); 55 debug('Number type');
56 input.type = 'number'; 56 input.type = 'number';
57 debug('Invalid value'); 57 debug('Invalid value');
58 shouldThrow('stepUp("", null, null)'); 58 shouldBeEqualToString('stepUp("", null, null)', '1');
59 shouldThrow('stepDown("", null, null)'); 59 shouldBeEqualToString('stepDown("", null, null)', '-1');
60 debug('Non-number arguments'); 60 debug('Non-number arguments');
61 shouldBe('stepUp("0", null, null, "0")', '"0"'); 61 shouldBe('stepUp("0", null, null, "0")', '"0"');
62 shouldBe('stepDown("0", null, null, "0")', '"0"'); 62 shouldBe('stepDown("0", null, null, "0")', '"0"');
63 shouldBe('stepUp("0", null, null, "foo")', '"0"'); 63 shouldBe('stepUp("0", null, null, "foo")', '"0"');
64 shouldBe('stepDown("0", null, null, "foo")', '"0"'); 64 shouldBe('stepDown("0", null, null, "foo")', '"0"');
65 shouldBe('stepUp("0", null, null, null)', '"0"'); 65 shouldBe('stepUp("0", null, null, null)', '"0"');
66 shouldBe('stepDown("0", null, null, null)', '"0"'); 66 shouldBe('stepDown("0", null, null, null)', '"0"');
67 debug('Normal cases'); 67 debug('Normal cases');
68 shouldBe('stepUp("0", null, null)', '"1"'); 68 shouldBe('stepUp("0", null, null)', '"1"');
69 shouldBe('stepUp("1", null, null, 2)', '"3"'); 69 shouldBe('stepUp("1", null, null, 2)', '"3"');
70 shouldBe('stepUp("3", null, null, -1)', '"2"'); 70 shouldBe('stepUp("3", null, null, -1)', '"2"');
71 shouldBe('stepDown("2", null, null)', '"1"'); 71 shouldBe('stepDown("2", null, null)', '"1"');
72 shouldBe('stepDown("1", null, null, 2)', '"-1"'); 72 shouldBe('stepDown("1", null, null, 2)', '"-1"');
73 shouldBe('stepDown("-1", null, null, -1)', '"0"'); 73 shouldBe('stepDown("-1", null, null, -1)', '"0"');
74 debug('Extra arguments'); 74 debug('Extra arguments');
75 shouldBe('input.value = "0"; input.min = null; input.step = null; input.stepUp(1 , 2); input.value', '"1"'); 75 shouldBe('input.value = "0"; input.min = null; input.step = null; input.stepUp(1 , 2); input.value', '"1"');
76 shouldBe('input.value = "1"; input.stepDown(1, 3); input.value', '"0"'); 76 shouldBe('input.value = "1"; input.stepDown(1, 3); input.value', '"0"');
77 debug('Invalid step value'); 77 debug('Invalid step value');
78 shouldBe('stepUp("0", "foo", null)', '"1"'); 78 shouldBe('stepUp("0", "foo", null)', '"1"');
79 shouldBe('stepUp("1", "0", null)', '"2"'); 79 shouldBe('stepUp("1", "0", null)', '"2"');
80 shouldBe('stepUp("2", "-1", null)', '"3"'); 80 shouldBe('stepUp("2", "-1", null)', '"3"');
81 debug('Step=any'); 81 debug('Step=any');
82 shouldThrow('stepUp("0", "any", null)'); 82 shouldThrow('stepUp("0", "any", null)');
83 shouldThrow('stepDown("0", "any", null)'); 83 shouldThrow('stepDown("0", "any", null)');
84 debug('Step=any corner case'); 84 debug('Step=any corner case');
85 shouldThrow('stepUpExplicitBounds("0", "100", "any", "1.5", "1")'); 85 shouldThrow('stepUpExplicitBounds("0", "100", "any", "1.5", "1")');
86 shouldThrow('stepDownExplicitBounds("0", "100", "any", "1.5", "1")'); 86 shouldThrow('stepDownExplicitBounds("0", "100", "any", "1.5", "1")');
87 debug('Overflow/underflow'); 87 debug('Overflow/underflow');
88 shouldBe('stepDown("1", "1", "0")', '"0"'); 88 shouldBe('stepDown("1", "1", "0")', '"0"');
89 shouldThrow('stepDown("0", "1", "0")'); 89 shouldBeEqualToString('stepDown("0", "1", "0")', '0');
90 shouldThrow('stepDown("1", "1", "0", 2)'); 90 shouldBeEqualToString('stepDown("1", "1", "0", 2)', '0');
91 shouldBe('input.value', '"1"'); 91 shouldBeEqualToString('stepDown("1", "3.40282346e+38", "", 2)', '-3.40282346e+38 ');
92 shouldThrow('stepDown("1", "3.40282346e+38", "", 2)'); 92 shouldBeEqualToString('stepUp("-1", "1", "0")', '0');
93 shouldBe('stepUp("-1", "1", "0")', '"0"'); 93 shouldBeEqualToString('stepUp("0", "1", "0")', '0');
94 shouldThrow('stepUp("0", "1", "0")'); 94 shouldBeEqualToString('stepUp("-1", "1", "0", 2)', '0');
95 shouldThrow('stepUp("-1", "1", "0", 2)'); 95 shouldBeEqualToString('stepUp("1", "3.40282346e+38", "", 2)', '3.40282346e+38');
96 shouldBe('input.value', '"-1"');
97 shouldThrow('stepUp("1", "3.40282346e+38", "", 2)');
98 debug('stepDown()/stepUp() for stepMismatch values'); 96 debug('stepDown()/stepUp() for stepMismatch values');
99 shouldBe('stepUp("1", "2", "")', '"3"'); 97 shouldBeEqualToString('stepUpExplicitBounds("0", "", "2", "1"); input.value', '2 ');
100 shouldBe('input.stepDown(); input.value', '"1"'); 98 shouldBeEqualToString('stepUp("1", "2", "")', '2');
101 shouldBe('input.min = "0"; stepUp("9", "10", "", 9)', '"99"'); 99 shouldBeEqualToString('input.stepDown(); input.value', '0');
102 shouldBe('stepDown("19", "10", "0")', '"9"'); 100 shouldBeEqualToString('input.min = "0"; stepUp("9", "10", "", 9)', '90');
103 shouldBe('stepUp("89", "10", "99")', '"99"'); 101 shouldBeEqualToString('stepDown("19", "10", "0")', '10');
102 shouldBeEqualToString('stepUp("89", "10", "99")', '90');
104 debug('Huge value and small step'); 103 debug('Huge value and small step');
105 shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999999)', '"1e+38"'); 104 shouldBe('input.min = ""; stepUp("1e+38", "1", "", 999999)', '"1e+38"');
106 shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999999)', '"1e+38"'); 105 shouldBe('input.max = ""; stepDown("1e+38", "1", "", 999999)', '"1e+38"');
107 debug('Fractional numbers'); 106 debug('Fractional numbers');
108 shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"'); 107 shouldBe('input.min = ""; stepUp("0", "0.33333333333333333", "", 3)', '"1"');
109 shouldBe('stepUp("1", "0.1", "", 10)', '"2"'); 108 shouldBe('stepUp("1", "0.1", "", 10)', '"2"');
110 shouldBe('input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input. stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input. stepUp(); input.value', '"3"'); 109 shouldBe('input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input. stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input. stepUp(); input.value', '"3"');
111 shouldBe('input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"' ); 110 shouldBe('input.min = "0"; stepUp("0", "0.003921568627450980", "1", 255)', '"1"' );
112 shouldBe('for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value', '"0 "'); 111 shouldBe('for (var i = 0; i < 255; i++) { input.stepDown(); }; input.value', '"0 "');
113 debug('Rounding'); 112 debug('Rounding');
114 shouldBe('stepUp("5.005", "0.005", "", 2)', '"5.015"'); 113 shouldBe('stepUp("5.005", "0.005", "", 2)', '"5.015"');
115 shouldBe('stepUp("5.005", "0.005", "", 11)', '"5.06"'); 114 shouldBe('stepUp("5.005", "0.005", "", 11)', '"5.06"');
116 shouldBe('stepUp("5.005", "0.005", "", 12)', '"5.065"'); 115 shouldBe('stepUp("5.005", "0.005", "", 12)', '"5.065"');
117 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 2)', '"5.015"'); 116 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 2)', '"5.015"');
118 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 11)', '"5.06"'); 117 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 11)', '"5.06"');
119 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 12)', '"5.065"'); 118 shouldBe('stepUpExplicitBounds("4", "9", "0.005", "5.005", 12)', '"5.065"');
120 </script> 119 </script>
121 </body> 120 </body>
122 </html> 121 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698