4 <script src=../../resources/js-test.js
language=
"javascript" type=
"text/javascript"></script>
5 <title>Testing that searching for text starts at the active selection
</title>
9 The _before_selection_ word is before the selection, so we shouldn't be able to find it if span_to_select is selected.
11 <span id=
"span_to_select">The _in_selection_ word is in the selection and we should always be able to find it.
</span>
13 The _after_selection_ word is after the selection and we should always be able to find that too.
15 <pre id=
"console" style=
"visibility: hidden;"></pre>
19 document
.getElementById("console").appendChild(document
.createTextNode(message
+ "\n"));
24 var selection
= window
.getSelection();
25 var range
= document
.createRange();
26 var spanToSelect
= document
.getElementById('span_to_select');
27 range
.setStartBefore(spanToSelect
);
28 range
.setEndAfter(spanToSelect
);
29 selection
.addRange(range
);
32 if (!window
.testRunner
)
33 testFailed('This test requires the testRunner object');
35 shouldBeTrue('testRunner.findString("_before_selection_", [])');
36 shouldBeTrue('testRunner.findString("_in_selection_", [])');
37 shouldBeTrue('testRunner.findString("_after_selection_", [])');
39 debug('Selecting some text. This should make it not possible to find the _before_selection_ word without enabling wrap-around.');
42 shouldBeFalse('testRunner.findString("_before_selection_", [])');
43 shouldBeTrue('testRunner.findString("_in_selection_", [])');
44 shouldBeTrue('testRunner.findString("_after_selection_", [])');
47 document
.getElementById("console").style
.removeProperty("visibility");
49 var successfullyParsed
= true;