OLD | NEW |
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('Check stepUp() and stepDown() bahevior for range type.'); | 10 description('Check stepUp() and stepDown() behavior for range type.'); |
11 | 11 |
12 var input; | 12 var input; |
13 | 13 |
14 function createRangeElement() { | 14 function createRangeElement() { |
15 input = document.createElement('input'); | 15 input = document.createElement('input'); |
16 input.type = 'range'; | 16 input.type = 'range'; |
17 } | 17 } |
18 | 18 |
19 function setInputAttributes(min, max, step, value) { | 19 function setInputAttributes(min, max, step, value) { |
20 input.min = min; | 20 input.min = min; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 shouldBeEqualToString('stepUpExplicitBounds(null, null, "0", "1")', '2'); | 101 shouldBeEqualToString('stepUpExplicitBounds(null, null, "0", "1")', '2'); |
102 shouldBeEqualToString('stepUpExplicitBounds(null, null, "-1", "2")', '3'); | 102 shouldBeEqualToString('stepUpExplicitBounds(null, null, "-1", "2")', '3'); |
103 shouldBeEqualToString('stepDownExplicitBounds(null, null, "foo", "1")', '0'); | 103 shouldBeEqualToString('stepDownExplicitBounds(null, null, "foo", "1")', '0'); |
104 shouldBeEqualToString('stepDownExplicitBounds(null, null, "0", "2")', '1'); | 104 shouldBeEqualToString('stepDownExplicitBounds(null, null, "0", "2")', '1'); |
105 shouldBeEqualToString('stepDownExplicitBounds(null, null, "-1", "3")', '2'); | 105 shouldBeEqualToString('stepDownExplicitBounds(null, null, "-1", "3")', '2'); |
106 debug('Step bases'); | 106 debug('Step bases'); |
107 shouldBeEqualToString('createInputWithContentAttributes(0, 100, "20", "50"); inp
ut.value', '60'); | 107 shouldBeEqualToString('createInputWithContentAttributes(0, 100, "20", "50"); inp
ut.value', '60'); |
108 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.value', '25'); | 108 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.value', '25'); |
109 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.stepUp(1); input.value', '75'); | 109 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.stepUp(1); input.value', '75'); |
110 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.stepUp(1); input.stepDown(1); input.value', '25'); | 110 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.stepUp(1); input.stepDown(1); input.value', '25'); |
111 // FIXME: these shouldn't throw according to the spec; commented-out version giv
e its expected outcomes. | 111 shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25");
input.stepUp(2); input.stepDown(2); input.value', '25'); |
112 shouldThrow('createInputWithContentAttributes(null, null, "50", "25"); input.ste
pUp(2); input.stepDown(2);'); | 112 shouldBeEqualToString('createInputWithContentAttributes(null, null, "7", "22");
input.stepUp(40); input.value', '99'); |
113 shouldThrow('createInputWithContentAttributes(null, null, "7", "22"); input.step
Up(40);'); | |
114 //shouldBeEqualToString('createInputWithContentAttributes(null, null, "50", "25"
); input.stepUp(2); input.stepDown(2); input.value', '25'); | |
115 //shouldBeEqualToString('createInputWithContentAttributes(null, null, "7", "22")
; input.stepUp(40); input.value', '99'); | |
116 | 113 |
117 // Reset 'input' for follow-on tests. | 114 // Reset 'input' for follow-on tests. |
118 createRangeElement(); | 115 createRangeElement(); |
119 debug('Step=any'); | 116 debug('Step=any'); |
120 shouldThrow('stepUpExplicitBounds(null, null, "any", "1")'); | 117 shouldThrow('stepUpExplicitBounds(null, null, "any", "1")'); |
121 shouldThrow('stepDownExplicitBounds(null, null, "any", "1")'); | 118 shouldThrow('stepDownExplicitBounds(null, null, "any", "1")'); |
122 debug('Overflow/underflow'); | 119 debug('Overflow/underflow'); |
123 shouldBeEqualToString('stepUpExplicitBounds(null, "100", "1", "99")', '100'); | 120 shouldBeEqualToString('stepUpExplicitBounds(null, "100", "1", "99")', '100'); |
124 shouldThrow('stepUpExplicitBounds(null, "100", "1", "100")'); | 121 shouldBeEqualToString('stepUpExplicitBounds(null, "100", "1", "100")', '100'); |
125 shouldBeEqualToString('input.value', '100'); | 122 shouldBeEqualToString('stepUpExplicitBounds(null, "100", "1", "99", "2")', '100'
); |
126 shouldThrow('stepUpExplicitBounds(null, "100", "1", "99", "2")'); | |
127 shouldBeEqualToString('input.value', '99'); | |
128 shouldBeEqualToString('stepDownExplicitBounds("0", null, "1", "1")', '0'); | 123 shouldBeEqualToString('stepDownExplicitBounds("0", null, "1", "1")', '0'); |
129 shouldThrow('stepDownExplicitBounds("0", null, "1", "0")'); | 124 shouldBeEqualToString('stepDownExplicitBounds("0", null, "1", "0")', '0'); |
130 shouldBeEqualToString('input.value', '0'); | 125 shouldBeEqualToString('stepDownExplicitBounds("0", null, "1", "1", "2")', '0'); |
131 shouldThrow('stepDownExplicitBounds("0", null, "1", "1", "2")'); | 126 shouldBeEqualToString('stepDownExplicitBounds(null, null, "3.40282346e+38", "1",
"2")', '0'); |
132 shouldBeEqualToString('input.value', '1'); | |
133 shouldThrow('stepDownExplicitBounds(null, null, "3.40282346e+38", "1", "2")'); | |
134 shouldBeEqualToString('stepUpExplicitBounds(-100, 0, 1, -1)', '0'); | 127 shouldBeEqualToString('stepUpExplicitBounds(-100, 0, 1, -1)', '0'); |
135 shouldThrow('stepUpExplicitBounds(null, 0, 1, 0)'); | 128 shouldBeEqualToString('stepUpExplicitBounds(null, 0, 1, 0)', '0'); |
136 shouldThrow('stepUpExplicitBounds(-100, 0, 1, -1, 2)'); | 129 shouldBeEqualToString('stepUpExplicitBounds(-100, 0, 1, -1, 2)', '0'); |
137 shouldBeEqualToString('input.value', '-1'); | 130 shouldBeEqualToString('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "
2")', '0'); |
138 shouldThrow('stepUpExplicitBounds(null, null, "3.40282346e+38", "1", "2")'); | |
139 debug('stepDown()/stepUp() for stepMismatch values'); | 131 debug('stepDown()/stepUp() for stepMismatch values'); |
140 shouldBeEqualToString('stepUpExplicitBounds(null, null, 2, 1)', '4'); | 132 shouldBeEqualToString('stepUpExplicitBounds(null, null, 2, 1)', '4'); |
141 shouldBeEqualToString('input.stepDown(); input.value', '2'); | 133 shouldBeEqualToString('input.stepDown(); input.value', '2'); |
142 shouldBeEqualToString('stepUpExplicitBounds(0, null, 10, 9, 9)', '100'); | 134 shouldBeEqualToString('stepUpExplicitBounds(0, null, 10, 9, 9)', '100'); |
143 shouldBeEqualToString('stepDownExplicitBounds(0, null, 10, 19)', '10'); | 135 shouldBeEqualToString('stepDownExplicitBounds(0, null, 10, 19)', '10'); |
144 debug('value + step is <= max, but rounded result would be > max.'); | 136 debug('value + step is <= max, but rounded result would be > max.'); |
145 shouldThrow('stepUpExplicitBounds(null, 99, 10, 89)'); | 137 shouldBeEqualToString('stepUpExplicitBounds(null, 99, 10, 89)', '90'); |
| 138 shouldBeEqualToString('stepUpExplicitBounds(null, 99, 10, 89, 21)', '90'); |
| 139 shouldBeEqualToString('stepUpExplicitBounds(null, 99, 10, 77, 2)', '90'); |
146 debug('Huge value and small step'); | 140 debug('Huge value and small step'); |
147 shouldBeEqualToString('stepUpExplicitBounds(0, 1e38, 1, 1e38, 999999)', '1e+38')
; | 141 shouldBeEqualToString('stepUpExplicitBounds(0, 1e38, 1, 1e38, 999999)', '1e+38')
; |
148 shouldBeEqualToString('stepDownExplicitBounds(0, 1e38, 1, 1e38, 999999)', '1e+38
'); | 142 shouldBeEqualToString('stepDownExplicitBounds(0, 1e38, 1, 1e38, 999999)', '1e+38
'); |
149 debug('Fractional numbers'); | 143 debug('Fractional numbers'); |
150 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.33333333333333333, 0,
3)', '1'); | 144 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.33333333333333333, 0,
3)', '1'); |
151 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.1, 1)', '1.1'); | 145 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.1, 1)', '1.1'); |
152 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.1, 1, 8)', '1.8'); | 146 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.1, 1, 8)', '1.8'); |
153 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.1, 1, 10)', '2'); | 147 shouldBeEqualToString('stepUpExplicitBounds(null, null, 0.1, 1, 10)', '2'); |
154 shouldBeEqualToString('input.stepUp(); input.stepUp(); input.stepUp(); input.ste
pUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.ste
pUp(); input.stepUp(); input.value', '3'); | 148 shouldBeEqualToString('input.stepUp(); input.stepUp(); input.stepUp(); input.ste
pUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.stepUp(); input.ste
pUp(); input.stepUp(); input.value', '3'); |
155 shouldBeEqualToString('stepUpExplicitBounds(0, 1, 0.003921568627450980, 0, 255)'
, '1'); | 149 shouldBeEqualToString('stepUpExplicitBounds(0, 1, 0.003921568627450980, 0, 255)'
, '1'); |
156 shouldBeEqualToString('for (var i = 0; i < 255; i++) { input.stepDown(); }; inpu
t.value', '0'); | 150 shouldBeEqualToString('for (var i = 0; i < 255; i++) { input.stepDown(); }; inpu
t.value', '0'); |
157 shouldBeEqualToString('stepDownExplicitBounds(null, null, 0.1, 1, 8)', '0.2'); | 151 shouldBeEqualToString('stepDownExplicitBounds(null, null, 0.1, 1, 8)', '0.2'); |
158 shouldBeEqualToString('stepDownExplicitBounds(null, null, 0.1, 1)', '0.9'); | 152 shouldBeEqualToString('stepDownExplicitBounds(null, null, 0.1, 1)', '0.9'); |
159 </script> | 153 </script> |
160 </body> | 154 </body> |
161 </html> | 155 </html> |
OLD | NEW |