| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <head> | |
| 4 <link rel="stylesheet" href="../../../../fast/js/resources/js-test-style.css"> | |
| 5 <script src=../../../../fast/js/resources/js-test-pre.js language="javascript" t
ype="text/javascript"></script> | |
| 6 <title>Testing that searching for text starts at the active selection</title> | |
| 7 </head> | |
| 8 <body> | |
| 9 <div id="container"> | |
| 10 The _before_selection_ word is before the selection, so we shouldn't be
able to find it if span_to_select is selected. | |
| 11 <br/> | |
| 12 <span id="span_to_select">The _in_selection_ word is in the selection an
d we should always be able to find it.</span> | |
| 13 <br/> | |
| 14 The _after_selection_ word is after the selection and we should always b
e able to find that too. | |
| 15 </div> | |
| 16 <pre id="console" style="visibility: hidden;"></pre> | |
| 17 <script> | |
| 18 function log(message) | |
| 19 { | |
| 20 document.getElementById("console").appendChild(document.createTextNode(messa
ge + "\n")); | |
| 21 } | |
| 22 | |
| 23 function selectText() | |
| 24 { | |
| 25 var selection = window.getSelection(); | |
| 26 var range = document.createRange(); | |
| 27 var spanToSelect = document.getElementById('span_to_select'); | |
| 28 range.setStartBefore(spanToSelect); | |
| 29 range.setEndAfter(spanToSelect); | |
| 30 selection.addRange(range); | |
| 31 } | |
| 32 | |
| 33 if (!window.testRunner) | |
| 34 testFailed('This test requires the testRunner object'); | |
| 35 else { | |
| 36 shouldBeTrue('testRunner.findString("_before_selection_", [])'); | |
| 37 shouldBeTrue('testRunner.findString("_in_selection_", [])'); | |
| 38 shouldBeTrue('testRunner.findString("_after_selection_", [])'); | |
| 39 | |
| 40 debug('Selecting some text. This should make it not possible to find the _be
fore_selection_ word without enabling wrap-around.'); | |
| 41 selectText(); | |
| 42 | |
| 43 shouldBeFalse('testRunner.findString("_before_selection_", [])'); | |
| 44 shouldBeTrue('testRunner.findString("_in_selection_", [])'); | |
| 45 shouldBeTrue('testRunner.findString("_after_selection_", [])'); | |
| 46 } | |
| 47 | |
| 48 document.getElementById("console").style.removeProperty("visibility"); | |
| 49 | |
| 50 var successfullyParsed = true; | |
| 51 </script> | |
| 52 <script src="../../../../fast/js/resources/js-test-post.js"></script> | |
| 53 </body> | |
| 54 </html> | |
| OLD | NEW |