| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 | 2 |
| 3 function testAddRange(exception, range, endpoints, qualifier, testName) { | 3 function testAddRange(exception, range, endpoints, qualifier, testName) { |
| 4 if (!isSelectableNode(endpoints[0]) || !isSelectableNode(endpoints[2])) { |
| 5 test(function() { |
| 6 assert_equals(exception, null, "Test setup must not throw exceptions
"); |
| 7 |
| 8 assertSelectionNoChange(function() { selection.addRange(range); }); |
| 9 assert_equals(range.startContainer, endpoints[0], |
| 10 "addRange() must not modify the startContainer of the Range it's
given"); |
| 11 assert_equals(range.startOffset, endpoints[1], |
| 12 "addRange() must not modify the startOffset of the Range it's gi
ven"); |
| 13 assert_equals(range.endContainer, endpoints[2], |
| 14 "addRange() must not modify the endContainer of the Range it's g
iven"); |
| 15 assert_equals(range.endOffset, endpoints[3], |
| 16 "addRange() must not modify the endOffset of the Range it's give
n"); |
| 17 }, testName + ": " + qualifier + " addRange() must do nothing"); |
| 18 return; |
| 19 } |
| 20 |
| 4 test(function() { | 21 test(function() { |
| 5 assert_equals(exception, null, "Test setup must not throw exceptions"); | 22 assert_equals(exception, null, "Test setup must not throw exceptions"); |
| 6 | 23 |
| 7 selection.addRange(range); | 24 selection.addRange(range); |
| 8 | 25 |
| 9 assert_equals(range.startContainer, endpoints[0], | 26 assert_equals(range.startContainer, endpoints[0], |
| 10 "addRange() must not modify the startContainer of the Range it's giv
en"); | 27 "addRange() must not modify the startContainer of the Range it's giv
en"); |
| 11 assert_equals(range.startOffset, endpoints[1], | 28 assert_equals(range.startOffset, endpoints[1], |
| 12 "addRange() must not modify the startOffset of the Range it's given"
); | 29 "addRange() must not modify the startOffset of the Range it's given"
); |
| 13 assert_equals(range.endContainer, endpoints[2], | 30 assert_equals(range.endContainer, endpoints[2], |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 throw "Sanity check: the second Range we created must have t
he desired endContainer"; | 186 throw "Sanity check: the second Range we created must have t
he desired endContainer"; |
| 170 } | 187 } |
| 171 if (range2.endOffset !== endpoints2[3]) { | 188 if (range2.endOffset !== endpoints2[3]) { |
| 172 throw "Sanity check: the second Range we created must have t
he desired endOffset"; | 189 throw "Sanity check: the second Range we created must have t
he desired endOffset"; |
| 173 } | 190 } |
| 174 } catch (e) { | 191 } catch (e) { |
| 175 exception = e; | 192 exception = e; |
| 176 } | 193 } |
| 177 | 194 |
| 178 testAddRange(exception, range1, endpoints1, "first", testName); | 195 testAddRange(exception, range1, endpoints1, "first", testName); |
| 179 testAddRange(exception, range2, endpoints2, "second", testName); | 196 if (selection.rangeCount > 0) |
| 197 testAddRange(exception, range2, endpoints2, "second", testName); |
| 180 } | 198 } |
| 181 } | 199 } |
| 182 } | 200 } |
| 183 | 201 |
| OLD | NEW |