OLD | NEW |
1 function runTestsShouldPass(tagName, attributes) | 1 function runTestsShouldPass(tagName, attributes) |
2 { | 2 { |
3 attributes = attributes || {}; | 3 attributes = attributes || {}; |
4 window.element = document.createElement(tagName); | 4 window.element = document.createElement(tagName); |
5 for (var key in attributes) | 5 for (var key in attributes) |
6 element.setAttribute(key, attributes[key]); | 6 element.setAttribute(key, attributes[key]); |
7 document.body.appendChild(element); | 7 document.body.appendChild(element); |
8 debug("<hr>"); | 8 debug("<hr>"); |
9 debug("Running tests on " + tagName + " with attributes: " + JSON.stringify(
attributes) + "\n"); | 9 debug("Running tests on " + tagName + " with attributes: " + JSON.stringify(
attributes) + "\n"); |
10 debug("setRangeText() with only one parameter."); | 10 debug("setRangeText() with only one parameter."); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 if (element.getAttribute("type") == "file") | 155 if (element.getAttribute("type") == "file") |
156 shouldThrow("element.value = '0123456789XYZ'"); | 156 shouldThrow("element.value = '0123456789XYZ'"); |
157 else | 157 else |
158 evalAndLog("element.value = '0123456789XYZ'"); | 158 evalAndLog("element.value = '0123456789XYZ'"); |
159 var initialValue = element.value; | 159 var initialValue = element.value; |
160 shouldThrow("element.setRangeText('ABC', 0, 0)"); | 160 shouldThrow("element.setRangeText('ABC', 0, 0)"); |
161 // setRangeText() shouldn't do anything on non-text form controls. | 161 // setRangeText() shouldn't do anything on non-text form controls. |
162 shouldBeEqualToString("element.value", initialValue); | 162 shouldBeEqualToString("element.value", initialValue); |
163 } | 163 } |
164 | 164 |
| 165 function runTestsShouldNotThrow(tagName, attributes) |
| 166 { |
| 167 attributes = attributes || {}; |
| 168 window.element = document.createElement(tagName); |
| 169 for (var key in attributes) |
| 170 element.setAttribute(key, attributes[key]); |
165 | 171 |
| 172 document.body.appendChild(element); |
| 173 debug("<hr>"); |
| 174 debug("Running tests on " + tagName + " with attributes: " + JSON.stringify(
attributes) + "\n"); |
| 175 |
| 176 var initialValue = element.value; |
| 177 if (element.getAttribute("type") == "file") |
| 178 shouldThrow("element.value = '0123456789'"); |
| 179 else |
| 180 evalAndLog("element.value = '0123456789'"); |
| 181 evalAndLog("element.setSelectionRange(2, 5)"); |
| 182 evalAndLog("element.setRangeText('432')"); |
| 183 |
| 184 // setRangeText() shouldn't do anything on non-text form controls. |
| 185 if (element.getAttribute("type") == "color") |
| 186 shouldBeEqualToString("element.value", "#000000"); |
| 187 else |
| 188 shouldBeEqualToString("element.value", initialValue); |
| 189 shouldNotBe("element.value", "0143256789"); |
| 190 } |
| 191 |
OLD | NEW |