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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 | 83 |
84 evalAndLog("element.value = '0123456789'"); | 84 evalAndLog("element.value = '0123456789'"); |
85 evalAndLog("element.setSelectionRange(6, 9)"); | 85 evalAndLog("element.setSelectionRange(6, 9)"); |
86 evalAndLog("element.setRangeText('AB', 1, 1, 'invalid')"); // Invalid select
Mode values default to preserve. | 86 evalAndLog("element.setRangeText('AB', 1, 1, 'invalid')"); // Invalid select
Mode values default to preserve. |
87 shouldBeEqualToString("element.value", "0AB123456789"); | 87 shouldBeEqualToString("element.value", "0AB123456789"); |
88 shouldBe("element.selectionStart", "8"); | 88 shouldBe("element.selectionStart", "8"); |
89 shouldBe("element.selectionEnd", "11"); | 89 shouldBe("element.selectionEnd", "11"); |
90 | 90 |
91 evalAndLog("element.value = '0123456789'"); | 91 evalAndLog("element.value = '0123456789'"); |
92 evalAndLog("element.setSelectionRange(6, 9)"); | 92 evalAndLog("element.setSelectionRange(6, 9)"); |
93 evalAndLog("element.setRangeText('AB', 1, 1, undefined)"); // Undefined sele
ctMode also default to preserve. | |
94 shouldBeEqualToString("element.value", "0AB123456789"); | |
95 shouldBe("element.selectionStart", "8"); | |
96 shouldBe("element.selectionEnd", "11"); | |
97 | |
98 evalAndLog("element.value = '0123456789'"); | |
99 evalAndLog("element.setSelectionRange(6, 9)"); | |
100 evalAndLog("element.setRangeText('A', 1, 3, 'preserve')"); | 93 evalAndLog("element.setRangeText('A', 1, 3, 'preserve')"); |
101 shouldBeEqualToString("element.value", "0A3456789"); | 94 shouldBeEqualToString("element.value", "0A3456789"); |
102 shouldBe("element.selectionStart", "5"); | 95 shouldBe("element.selectionStart", "5"); |
103 shouldBe("element.selectionEnd", "8"); | 96 shouldBe("element.selectionEnd", "8"); |
104 | 97 |
105 evalAndLog("element.value = '0123456789'"); | 98 evalAndLog("element.value = '0123456789'"); |
106 evalAndLog("element.setSelectionRange(2, 6)"); | 99 evalAndLog("element.setSelectionRange(2, 6)"); |
107 evalAndLog("element.setRangeText('A', 1, 4, 'preserve')"); | 100 evalAndLog("element.setRangeText('A', 1, 4, 'preserve')"); |
108 shouldBeEqualToString("element.value", "0A456789"); | 101 shouldBeEqualToString("element.value", "0A456789"); |
109 shouldBe("element.selectionStart", "1"); | 102 shouldBe("element.selectionStart", "1"); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 shouldThrow("element.value = '0123456789XYZ'"); | 149 shouldThrow("element.value = '0123456789XYZ'"); |
157 else | 150 else |
158 evalAndLog("element.value = '0123456789XYZ'"); | 151 evalAndLog("element.value = '0123456789XYZ'"); |
159 var initialValue = element.value; | 152 var initialValue = element.value; |
160 shouldThrow("element.setRangeText('ABC', 0, 0)"); | 153 shouldThrow("element.setRangeText('ABC', 0, 0)"); |
161 // setRangeText() shouldn't do anything on non-text form controls. | 154 // setRangeText() shouldn't do anything on non-text form controls. |
162 shouldBeEqualToString("element.value", initialValue); | 155 shouldBeEqualToString("element.value", initialValue); |
163 } | 156 } |
164 | 157 |
165 | 158 |
OLD | NEW |