Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <!-- This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | - License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
michael@0 | 5 | <html> |
michael@0 | 6 | <!-- |
michael@0 | 7 | https://bugzilla.mozilla.org/show_bug.cgi?id=348681 |
michael@0 | 8 | --> |
michael@0 | 9 | |
michael@0 | 10 | <head> |
michael@0 | 11 | <title>Test for Bug 348681</title> |
michael@0 | 12 | <script type="application/javascript" src="chrome://mochikit/content/MochiKit/MochiKit.js"></script> |
michael@0 | 13 | <script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 14 | <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> |
michael@0 | 15 | <script type="text/javascript" src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
michael@0 | 16 | </head> |
michael@0 | 17 | |
michael@0 | 18 | <body onload="loaded()"> |
michael@0 | 19 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=348681">Mozilla Bug 348681</a> |
michael@0 | 20 | <p id="display"></p> |
michael@0 | 21 | <div id="content" style="display: none"> |
michael@0 | 22 | </div> |
michael@0 | 23 | |
michael@0 | 24 | <pre id="test"> |
michael@0 | 25 | <script type="application/javascript"> |
michael@0 | 26 | |
michael@0 | 27 | /** Test for Bug 348681 **/ |
michael@0 | 28 | |
michael@0 | 29 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 30 | |
michael@0 | 31 | function loaded() { |
michael@0 | 32 | SpecialPowers.pushPrefEnv({"set": [["dom.testing.selection.GetRangesForInterval", true]]}, doTest); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | var rangeChecker = { |
michael@0 | 36 | ranges: [], |
michael@0 | 37 | |
michael@0 | 38 | reset: function() { |
michael@0 | 39 | this.ranges = []; |
michael@0 | 40 | }, |
michael@0 | 41 | |
michael@0 | 42 | check: function(testID, selection) { |
michael@0 | 43 | is(selection.rangeCount, this.ranges.length, |
michael@0 | 44 | "Test "+testID+": correct number of ranges in selection"); |
michael@0 | 45 | var rangesMatch = true; |
michael@0 | 46 | var foundMsg = "Found "; |
michael@0 | 47 | var expectedMsg = "Expected "; |
michael@0 | 48 | var maxIndex = Math.max(selection.rangeCount, this.ranges.length); |
michael@0 | 49 | for (var x = 0; x < maxIndex; x++) { |
michael@0 | 50 | var expect = null; |
michael@0 | 51 | if (x < this.ranges.length) |
michael@0 | 52 | expect = this.ranges[x]; |
michael@0 | 53 | |
michael@0 | 54 | var found = null; |
michael@0 | 55 | if (x < selection.rangeCount) |
michael@0 | 56 | found = selection.getRangeAt(x); |
michael@0 | 57 | |
michael@0 | 58 | if (found) { |
michael@0 | 59 | foundMsg +="["+found.startOffset+","+found.endOffset+"] "; |
michael@0 | 60 | } |
michael@0 | 61 | if (expect) { |
michael@0 | 62 | expectedMsg +="["+expect.start+","+expect.end+"] "; |
michael@0 | 63 | } |
michael@0 | 64 | |
michael@0 | 65 | if (found && expect) { |
michael@0 | 66 | if (found.startContainer != expect.node || |
michael@0 | 67 | found.endContainer != expect.node || |
michael@0 | 68 | found.startOffset != expect.start || |
michael@0 | 69 | found.endOffset != expect.end) |
michael@0 | 70 | rangesMatch = false; |
michael@0 | 71 | } else { |
michael@0 | 72 | rangesMatch = false; |
michael@0 | 73 | } |
michael@0 | 74 | } |
michael@0 | 75 | var okMsg = "Test "+testID+": correct ranges in selection."; |
michael@0 | 76 | okMsg = okMsg + foundMsg + expectedMsg; |
michael@0 | 77 | ok(rangesMatch, okMsg); |
michael@0 | 78 | }, |
michael@0 | 79 | |
michael@0 | 80 | addExpected: function(node, start, end) { |
michael@0 | 81 | var expected = {}; |
michael@0 | 82 | expected.node = node; |
michael@0 | 83 | expected.start = start; |
michael@0 | 84 | expected.end = end; |
michael@0 | 85 | this.ranges[this.ranges.length] = expected; |
michael@0 | 86 | this.ranges.sort(function(a,b) {return a.start - b.start;}); |
michael@0 | 87 | } |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | var intervalChecker = { |
michael@0 | 91 | ranges: [], |
michael@0 | 92 | |
michael@0 | 93 | reset: function() { |
michael@0 | 94 | this.ranges = []; |
michael@0 | 95 | }, |
michael@0 | 96 | |
michael@0 | 97 | check: function(testID, testArr) { |
michael@0 | 98 | is(testArr.length, this.ranges.length, |
michael@0 | 99 | "Test "+testID+": correct number of ranges for interval"); |
michael@0 | 100 | var rangesMatch = true; |
michael@0 | 101 | var foundMsg = "Found "; |
michael@0 | 102 | var expectedMsg = "Expected "; |
michael@0 | 103 | var maxIndex = Math.max(testArr.length, this.ranges.length); |
michael@0 | 104 | for (var x = 0; x < maxIndex; x++) { |
michael@0 | 105 | var expect = null; |
michael@0 | 106 | if (x < this.ranges.length) |
michael@0 | 107 | expect = this.ranges[x]; |
michael@0 | 108 | |
michael@0 | 109 | var found = null; |
michael@0 | 110 | if (x < testArr.length) |
michael@0 | 111 | found = testArr[x]; |
michael@0 | 112 | |
michael@0 | 113 | if (found) { |
michael@0 | 114 | foundMsg +="["+found.startOffset+","+found.endOffset+"] "; |
michael@0 | 115 | } |
michael@0 | 116 | if (expect) { |
michael@0 | 117 | expectedMsg +="["+expect.start+","+expect.end+"] "; |
michael@0 | 118 | } |
michael@0 | 119 | |
michael@0 | 120 | if (found && expect) { |
michael@0 | 121 | if (found.startContainer != expect.node || |
michael@0 | 122 | found.endContainer != expect.node || |
michael@0 | 123 | found.startOffset != expect.start || |
michael@0 | 124 | found.endOffset != expect.end) |
michael@0 | 125 | rangesMatch = false; |
michael@0 | 126 | } else { |
michael@0 | 127 | rangesMatch = false; |
michael@0 | 128 | } |
michael@0 | 129 | } |
michael@0 | 130 | var okMsg = "Test "+testID+": correct ranges for interval."; |
michael@0 | 131 | okMsg = okMsg + foundMsg + expectedMsg; |
michael@0 | 132 | ok(rangesMatch, okMsg); |
michael@0 | 133 | }, |
michael@0 | 134 | |
michael@0 | 135 | addExpected: function(node, start, end) { |
michael@0 | 136 | var expected = {}; |
michael@0 | 137 | expected.node = node; |
michael@0 | 138 | expected.start = start; |
michael@0 | 139 | expected.end = end; |
michael@0 | 140 | this.ranges[this.ranges.length] = expected; |
michael@0 | 141 | this.ranges.sort(function(a,b) {return a.start - b.start;}); |
michael@0 | 142 | } |
michael@0 | 143 | } |
michael@0 | 144 | |
michael@0 | 145 | function doTest() { |
michael@0 | 146 | var testNode = document.getElementById("testparagraph").firstChild; |
michael@0 | 147 | |
michael@0 | 148 | var selection = window.getSelection(); |
michael@0 | 149 | selection.removeAllRanges(); |
michael@0 | 150 | ok(selection.rangeCount == 0, "Test 0 - No selections so far"); |
michael@0 | 151 | |
michael@0 | 152 | // Test 1. Add a single range, to ensure we've not broken anything. |
michael@0 | 153 | var range1 = document.createRange(); |
michael@0 | 154 | range1.setStart(testNode, 0); |
michael@0 | 155 | range1.setEnd(testNode, 5); |
michael@0 | 156 | selection.addRange(range1); |
michael@0 | 157 | rangeChecker.addExpected(testNode, 0, 5); |
michael@0 | 158 | rangeChecker.check(1, selection); |
michael@0 | 159 | |
michael@0 | 160 | // Test 2. Add a non-overlapping range, to ensure it gets added too. |
michael@0 | 161 | var range2 = document.createRange(); |
michael@0 | 162 | range2.setStart(testNode, 8); |
michael@0 | 163 | range2.setEnd(testNode, 10); |
michael@0 | 164 | selection.addRange(range2); |
michael@0 | 165 | rangeChecker.addExpected(testNode, 8, 10); |
michael@0 | 166 | rangeChecker.check(2, selection); |
michael@0 | 167 | |
michael@0 | 168 | // Test 3. Add the same range again. This should silently succeed. |
michael@0 | 169 | selection.addRange(range2); |
michael@0 | 170 | rangeChecker.check(3, selection); |
michael@0 | 171 | |
michael@0 | 172 | // Test 4. Add a range that is left-adjacent to an existing range. |
michael@0 | 173 | var range3 = document.createRange(); |
michael@0 | 174 | range3.setStart(testNode, 6); |
michael@0 | 175 | range3.setEnd(testNode, 8); |
michael@0 | 176 | selection.addRange(range3); |
michael@0 | 177 | rangeChecker.addExpected(testNode, 6, 8); |
michael@0 | 178 | rangeChecker.check(4, selection); |
michael@0 | 179 | |
michael@0 | 180 | // Test 5. Add a range that is right-adjacent to an existing range. |
michael@0 | 181 | selection.removeRange(range2); |
michael@0 | 182 | selection.addRange(range2); |
michael@0 | 183 | rangeChecker.check(5, selection); |
michael@0 | 184 | |
michael@0 | 185 | // Test 6. Add a range, add a second range that overlaps it. |
michael@0 | 186 | rangeChecker.reset(); |
michael@0 | 187 | selection.removeAllRanges(); |
michael@0 | 188 | selection.addRange(range2); |
michael@0 | 189 | var range4 = document.createRange(); |
michael@0 | 190 | range4.setStart(testNode, 9); |
michael@0 | 191 | range4.setEnd(testNode, 11); |
michael@0 | 192 | selection.addRange(range4); |
michael@0 | 193 | rangeChecker.addExpected(testNode, 8, 9); |
michael@0 | 194 | rangeChecker.addExpected(testNode, 9, 11); |
michael@0 | 195 | rangeChecker.check(6, selection); |
michael@0 | 196 | |
michael@0 | 197 | // Test 7. Add a range, and this time a left-hand overlap. |
michael@0 | 198 | rangeChecker.reset(); |
michael@0 | 199 | selection.removeAllRanges(); |
michael@0 | 200 | var range5 = document.createRange(); |
michael@0 | 201 | range5.setStart(testNode, 5); |
michael@0 | 202 | range5.setEnd(testNode, 7); |
michael@0 | 203 | selection.addRange(range3); |
michael@0 | 204 | selection.addRange(range5); |
michael@0 | 205 | rangeChecker.addExpected(testNode, 5, 7); |
michael@0 | 206 | rangeChecker.addExpected(testNode, 7, 8); |
michael@0 | 207 | rangeChecker.check(7, selection); |
michael@0 | 208 | |
michael@0 | 209 | // Test 8. Add a range, and add a second range wholly contained |
michael@0 | 210 | // within it. |
michael@0 | 211 | rangeChecker.reset(); |
michael@0 | 212 | selection.removeAllRanges(); |
michael@0 | 213 | var range6 = document.createRange(); |
michael@0 | 214 | range6.setStart(testNode, 0); |
michael@0 | 215 | range6.setEnd(testNode, 10); |
michael@0 | 216 | selection.addRange(range6); |
michael@0 | 217 | selection.addRange(range5); |
michael@0 | 218 | rangeChecker.addExpected(testNode, 0, 5); |
michael@0 | 219 | rangeChecker.addExpected(testNode, 5, 7); |
michael@0 | 220 | rangeChecker.addExpected(testNode, 7, 10); |
michael@0 | 221 | rangeChecker.check(8, selection); |
michael@0 | 222 | |
michael@0 | 223 | // Test 9. Add a range that will wholly contain some existing ranges. |
michael@0 | 224 | rangeChecker.reset(); |
michael@0 | 225 | selection.addRange(range6); |
michael@0 | 226 | rangeChecker.addExpected(testNode, 0, 10); |
michael@0 | 227 | rangeChecker.check(9, selection); |
michael@0 | 228 | |
michael@0 | 229 | // Test 10. This time with the last range being a partial overlap. |
michael@0 | 230 | selection.removeAllRanges(); |
michael@0 | 231 | selection.addRange(range1); |
michael@0 | 232 | selection.addRange(range3); |
michael@0 | 233 | selection.addRange(range4); |
michael@0 | 234 | selection.addRange(range6); |
michael@0 | 235 | rangeChecker.addExpected(testNode, 10, 11); |
michael@0 | 236 | rangeChecker.check(10, selection); |
michael@0 | 237 | |
michael@0 | 238 | // Test 11. Check we can add a collapsed range without problem. |
michael@0 | 239 | selection.removeAllRanges(); |
michael@0 | 240 | rangeChecker.reset(); |
michael@0 | 241 | range1.collapse(true); |
michael@0 | 242 | selection.addRange(range1); |
michael@0 | 243 | rangeChecker.addExpected(testNode, 0, 0); |
michael@0 | 244 | rangeChecker.check(11, selection); |
michael@0 | 245 | |
michael@0 | 246 | // Test 12. Check we can add a collapsed range twice without a problem. |
michael@0 | 247 | // Part 1 - No other ranges present. |
michael@0 | 248 | selection.addRange(range1); |
michael@0 | 249 | rangeChecker.check(12, selection); |
michael@0 | 250 | |
michael@0 | 251 | // Test 13. Check we can add a collapsed range twice without problem. |
michael@0 | 252 | // Part 2 - Collapsed range is before all existing ranges. |
michael@0 | 253 | selection.removeAllRanges(); |
michael@0 | 254 | rangeChecker.reset(); |
michael@0 | 255 | selection.addRange(range2); |
michael@0 | 256 | selection.addRange(range1); |
michael@0 | 257 | selection.addRange(range1); |
michael@0 | 258 | rangeChecker.addExpected(testNode, 0, 0); |
michael@0 | 259 | rangeChecker.addExpected(testNode, 8, 10); |
michael@0 | 260 | rangeChecker.check(13, selection); |
michael@0 | 261 | |
michael@0 | 262 | // Test 14. Check we can add a collapsed range twice without problem. |
michael@0 | 263 | // Part 3 - Collapsed range is after all existing ranges. |
michael@0 | 264 | selection.removeAllRanges(); |
michael@0 | 265 | rangeChecker.reset(); |
michael@0 | 266 | selection.addRange(range3); |
michael@0 | 267 | range4.collapse(false); |
michael@0 | 268 | selection.addRange(range3); |
michael@0 | 269 | selection.addRange(range4); |
michael@0 | 270 | rangeChecker.addExpected(testNode, 6, 8); |
michael@0 | 271 | rangeChecker.addExpected(testNode, 11, 11); |
michael@0 | 272 | rangeChecker.check(14, selection); |
michael@0 | 273 | |
michael@0 | 274 | // Test 15. Check that when adding a range where after overlap |
michael@0 | 275 | // adjustment an exisiting range would collapse that the collapsed range |
michael@0 | 276 | // is removed - part 1 (LHS). |
michael@0 | 277 | selection.removeAllRanges(); |
michael@0 | 278 | rangeChecker.reset(); |
michael@0 | 279 | selection.addRange(range2); |
michael@0 | 280 | var range7 = document.createRange(); |
michael@0 | 281 | range7.setStart(testNode, 6); |
michael@0 | 282 | range7.setEnd(testNode, 10); |
michael@0 | 283 | selection.addRange(range7); |
michael@0 | 284 | rangeChecker.addExpected(testNode, 6, 10); |
michael@0 | 285 | rangeChecker.check(15, selection); |
michael@0 | 286 | |
michael@0 | 287 | // Test 16. Check that when adding a range where after overlap |
michael@0 | 288 | // adjustment an exisiting range would collapse that the collapsed range |
michael@0 | 289 | // is removed - part 2 (RHS). |
michael@0 | 290 | selection.removeAllRanges(); |
michael@0 | 291 | selection.addRange(range3); |
michael@0 | 292 | selection.addRange(range7); |
michael@0 | 293 | rangeChecker.check(16, selection); |
michael@0 | 294 | |
michael@0 | 295 | // Test 17. Check GetRangesForInterval returns correct results. |
michael@0 | 296 | // Part 1 - Test interval matches a range, adjacency not allowed. |
michael@0 | 297 | selection.removeAllRanges(); |
michael@0 | 298 | selection.addRange(range2); |
michael@0 | 299 | selection.addRange(range3); |
michael@0 | 300 | var range8 = document.createRange(); |
michael@0 | 301 | range8.setStart(testNode, 10); |
michael@0 | 302 | range8.setEnd(testNode, 12); |
michael@0 | 303 | selection.addRange(range8); |
michael@0 | 304 | intervalChecker.reset(); |
michael@0 | 305 | intervalChecker.addExpected(testNode, 8, 10); |
michael@0 | 306 | var privSel = selection.QueryInterface(SpecialPowers.Ci.nsISelectionPrivate); |
michael@0 | 307 | ok(privSel, "Test 17 - QIed to instance of nsISelection2 interface"); |
michael@0 | 308 | var results = privSel.GetRangesForInterval(testNode, 8, testNode, 10, |
michael@0 | 309 | false); |
michael@0 | 310 | intervalChecker.check(17, results); |
michael@0 | 311 | |
michael@0 | 312 | // Test 18. Check GetRangesForInterval returns correct results. |
michael@0 | 313 | // Part 2 - Test interval matches a range, adjacent ranges allowed. |
michael@0 | 314 | intervalChecker.addExpected(testNode, 6, 8); |
michael@0 | 315 | intervalChecker.addExpected(testNode, 10, 12); |
michael@0 | 316 | results = privSel.GetRangesForInterval(testNode, 8, testNode, 10, |
michael@0 | 317 | true); |
michael@0 | 318 | intervalChecker.check(18, results); |
michael@0 | 319 | |
michael@0 | 320 | // Test 19. Check GetRangesForInterval returns correct results. |
michael@0 | 321 | // Part 3 - Test interval not selected. |
michael@0 | 322 | intervalChecker.reset(); |
michael@0 | 323 | results = privSel.GetRangesForInterval(testNode, 14, testNode, 16, |
michael@0 | 324 | true); |
michael@0 | 325 | intervalChecker.check(19, results); |
michael@0 | 326 | |
michael@0 | 327 | // Test 20. Check GetRangesForInterval returns correct results. |
michael@0 | 328 | // Part 4 - Test interval is not equal to, and entirely contained in |
michael@0 | 329 | // an existing range. |
michael@0 | 330 | selection.removeAllRanges(); |
michael@0 | 331 | selection.addRange(range6); |
michael@0 | 332 | intervalChecker.reset(); |
michael@0 | 333 | intervalChecker.addExpected(testNode, 0, 10); |
michael@0 | 334 | results = privSel.GetRangesForInterval(testNode, 5, testNode, 7, |
michael@0 | 335 | true); |
michael@0 | 336 | intervalChecker.check(20, results); |
michael@0 | 337 | |
michael@0 | 338 | // Test 21. Check GetRangesForInterval returns correct results. |
michael@0 | 339 | // Part 5 - Test interval is not equal to, and entirely contains an |
michael@0 | 340 | // existing range. |
michael@0 | 341 | selection.removeAllRanges(); |
michael@0 | 342 | selection.addRange(range3); |
michael@0 | 343 | intervalChecker.reset(); |
michael@0 | 344 | intervalChecker.addExpected(testNode, 6, 8); |
michael@0 | 345 | results = privSel.GetRangesForInterval(testNode, 5, testNode, 9, |
michael@0 | 346 | true); |
michael@0 | 347 | intervalChecker.check(21, results); |
michael@0 | 348 | |
michael@0 | 349 | // Test 22. Check GetRangesForInterval returns correct results. |
michael@0 | 350 | // Part 6 - Test interval is end-adjacent to range at position 0 in |
michael@0 | 351 | // the range array, and adjacencies permitted. |
michael@0 | 352 | selection.removeAllRanges(); |
michael@0 | 353 | selection.addRange(range2); |
michael@0 | 354 | intervalChecker.reset(); |
michael@0 | 355 | intervalChecker.addExpected(testNode, 8, 10); |
michael@0 | 356 | results = privSel.GetRangesForInterval(testNode, 6, testNode, 8, |
michael@0 | 357 | true); |
michael@0 | 358 | intervalChecker.check(22, results); |
michael@0 | 359 | |
michael@0 | 360 | // Test 23. Check GetRangesForInterval returns correct results. |
michael@0 | 361 | // Part 7 - Test interval is end-adjacent to range at position 0 in |
michael@0 | 362 | // the range array, and adjacencies not permitted. |
michael@0 | 363 | intervalChecker.reset(); |
michael@0 | 364 | results = privSel.GetRangesForInterval(testNode, 6, testNode, 8, |
michael@0 | 365 | false); |
michael@0 | 366 | intervalChecker.check(23, results); |
michael@0 | 367 | |
michael@0 | 368 | // Test 24. Check GetRangesForInterval returns correct results. |
michael@0 | 369 | // Part 8 - Test interval is start-adjacent to last range in array, |
michael@0 | 370 | // and adjacencies permitted. |
michael@0 | 371 | intervalChecker.addExpected(testNode, 8, 10); |
michael@0 | 372 | results = privSel.GetRangesForInterval(testNode, 10, testNode, 12, |
michael@0 | 373 | true); |
michael@0 | 374 | intervalChecker.check(24, results); |
michael@0 | 375 | |
michael@0 | 376 | // Test 25. Check GetRangesForInterval returns correct results. |
michael@0 | 377 | // Part 9 - Test interval is start-adjacent to last range in array, |
michael@0 | 378 | // and adjacencies not permitted. |
michael@0 | 379 | intervalChecker.reset(); |
michael@0 | 380 | results = privSel.GetRangesForInterval(testNode, 10, testNode, 12, |
michael@0 | 381 | false); |
michael@0 | 382 | intervalChecker.check(25, results); |
michael@0 | 383 | |
michael@0 | 384 | // Test 26. Check GetRangesForInterval returns correct results. |
michael@0 | 385 | // Part 10 - Test interval is equal to a collapsed range at position 0 |
michael@0 | 386 | // in the range array, and adjacencies permitted. |
michael@0 | 387 | selection.removeAllRanges(); |
michael@0 | 388 | selection.addRange(range4); |
michael@0 | 389 | intervalChecker.addExpected(testNode, 11, 11); |
michael@0 | 390 | results = privSel.GetRangesForInterval(testNode, 11, testNode, 11, |
michael@0 | 391 | true); |
michael@0 | 392 | intervalChecker.check(26, results); |
michael@0 | 393 | |
michael@0 | 394 | // Test 27. Check GetRangesForInterval returns correct results. |
michael@0 | 395 | // Part 11 - Test interval is equal to a collapsed range at position 0 |
michael@0 | 396 | // in the range array, and adjacencies not permitted. |
michael@0 | 397 | results = privSel.GetRangesForInterval(testNode, 11, testNode, 11, |
michael@0 | 398 | false); |
michael@0 | 399 | intervalChecker.check(27, results); |
michael@0 | 400 | |
michael@0 | 401 | // Test 28. Check GetRangesForInterval returns correct results. |
michael@0 | 402 | // Part 12 - Test interval is equal to a collapsed range at end of the |
michael@0 | 403 | // range array, and adjacencies permitted. |
michael@0 | 404 | selection.removeAllRanges(); |
michael@0 | 405 | selection.addRange(range2); |
michael@0 | 406 | selection.addRange(range4); |
michael@0 | 407 | results = privSel.GetRangesForInterval(testNode, 11, testNode, 11, |
michael@0 | 408 | true); |
michael@0 | 409 | intervalChecker.check(28, results); |
michael@0 | 410 | |
michael@0 | 411 | // Test 29. Check GetRangesForInterval returns correct results. |
michael@0 | 412 | // Part 13 - Test interval is equal to a collapsed range at end of the |
michael@0 | 413 | // range array, and adjacencies not permitted. |
michael@0 | 414 | results = privSel.GetRangesForInterval(testNode, 11, testNode, 11, |
michael@0 | 415 | false); |
michael@0 | 416 | intervalChecker.check(29, results); |
michael@0 | 417 | |
michael@0 | 418 | // Test 30. Check GetRangesForInterval returns correct results. |
michael@0 | 419 | // Part 14 - Test interval is a collapsed range contained in an |
michael@0 | 420 | // existing range. |
michael@0 | 421 | selection.removeAllRanges(); |
michael@0 | 422 | selection.addRange(range3); |
michael@0 | 423 | intervalChecker.reset(); |
michael@0 | 424 | intervalChecker.addExpected(testNode, 6, 8); |
michael@0 | 425 | results = privSel.GetRangesForInterval(testNode, 7, testNode, 7, |
michael@0 | 426 | true); |
michael@0 | 427 | intervalChecker.check(30, results); |
michael@0 | 428 | |
michael@0 | 429 | // Test 31. Check GetRangesForInterval returns correct results. |
michael@0 | 430 | // Part 15 - Test interval equals a collapsed range which is not stored |
michael@0 | 431 | // at either endpoint of the selection's range array, |
michael@0 | 432 | // adjacencies not allowed. |
michael@0 | 433 | selection.removeAllRanges(); |
michael@0 | 434 | range3.collapse(false); |
michael@0 | 435 | selection.addRange(range5); |
michael@0 | 436 | selection.addRange(range3); |
michael@0 | 437 | selection.addRange(range8); |
michael@0 | 438 | intervalChecker.reset(); |
michael@0 | 439 | intervalChecker.addExpected(testNode, 8, 8); |
michael@0 | 440 | results = privSel.GetRangesForInterval(testNode, 8, testNode, 8, |
michael@0 | 441 | false); |
michael@0 | 442 | intervalChecker.check(31, results); |
michael@0 | 443 | |
michael@0 | 444 | // Test 32. Check GetRangesForInterval returns correct results. |
michael@0 | 445 | // Part 16 - Test interval equals a collapsed range which is not stored |
michael@0 | 446 | // at either endpoint of the selection's range array, |
michael@0 | 447 | // adjacencies allowed. |
michael@0 | 448 | results = privSel.GetRangesForInterval(testNode, 8, testNode, 8, |
michael@0 | 449 | true); |
michael@0 | 450 | intervalChecker.check(32, results); |
michael@0 | 451 | |
michael@0 | 452 | // Test 33. Check GetRangesForInterval returns correct results. |
michael@0 | 453 | // Part 17 - Test interval contains a collapsed range which is not |
michael@0 | 454 | // stored at either endpoint of the selection's range array. |
michael@0 | 455 | results = privSel.GetRangesForInterval(testNode, 7, testNode, 9, |
michael@0 | 456 | false); |
michael@0 | 457 | intervalChecker.check(33, results); |
michael@0 | 458 | |
michael@0 | 459 | // Test 34. Check GetRangesForInterval returns correct results. |
michael@0 | 460 | // Part 18 - Test interval left-ovelaps an existing range. |
michael@0 | 461 | intervalChecker.reset(); |
michael@0 | 462 | intervalChecker.addExpected(testNode, 5, 7); |
michael@0 | 463 | results = privSel.GetRangesForInterval(testNode, 2, testNode, 6, |
michael@0 | 464 | true); |
michael@0 | 465 | intervalChecker.check(34, results); |
michael@0 | 466 | |
michael@0 | 467 | // Test 35. Check GetRangesForInterval returns correct results. |
michael@0 | 468 | // Part 19 - Test interval right-ovelaps an existing range. |
michael@0 | 469 | selection.removeAllRanges(); |
michael@0 | 470 | selection.addRange(range8); |
michael@0 | 471 | intervalChecker.reset(); |
michael@0 | 472 | intervalChecker.addExpected(testNode, 10, 12); |
michael@0 | 473 | results = privSel.GetRangesForInterval(testNode, 11, testNode, 13, |
michael@0 | 474 | true); |
michael@0 | 475 | intervalChecker.check(35, results); |
michael@0 | 476 | |
michael@0 | 477 | SimpleTest.finish(); |
michael@0 | 478 | } |
michael@0 | 479 | </script> |
michael@0 | 480 | </pre> |
michael@0 | 481 | |
michael@0 | 482 | <p id="testparagraph"> |
michael@0 | 483 | This will be the first child of the p node above. The intention is that it is a suitably long text node to which we can add multiple ranges in order to test the various aspects of the bug. |
michael@0 | 484 | </p> |
michael@0 | 485 | </body> |
michael@0 | 486 | </html> |