Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / text-iterator / findString-start-search-after-selection.html
bloba5aa71494170e1efb78ace6ee513a32b0312b448
1 <!DOCTYPE html>
2 <html>
3 <head>
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>
6 </head>
7 <body>
8 <div id="container">
9 The _before_selection_ word is before the selection, so we shouldn't be able to find it if span_to_select is selected.
10 <br/>
11 <span id="span_to_select">The _in_selection_ word is in the selection and we should always be able to find it.</span>
12 <br/>
13 The _after_selection_ word is after the selection and we should always be able to find that too.
14 </div>
15 <pre id="console" style="visibility: hidden;"></pre>
16 <script>
17 function log(message)
19 document.getElementById("console").appendChild(document.createTextNode(message + "\n"));
22 function selectText()
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');
34 else {
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.');
40 selectText();
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;
50 </script>
51 </body>
52 </html>