embedding/test/test_bug499115.html

branch
TOR_BUG_9701
changeset 15
b8a032363ba2
equal deleted inserted replaced
-1:000000000000 0:74fcce36d560
1 <!DOCTYPE HTML>
2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
3 - License, v. 2.0. If a copy of the MPL was not distributed with this
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
5
6 <html>
7 <!--
8 https://bugzilla.mozilla.org/show_bug.cgi?id=499115
9 -->
10 <head>
11 <title>Test for Bug 499115</title>
12 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
14 </head>
15 <body onload="onLoad();">
16 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=499115">Mozilla Bug 499115</a>
17 <p id="display"></p>
18 <div id="content" style="display: none">
19 </div>
20 <pre id="test">
21 <script type="application/javascript">
22
23 /** Test for Bug 499115 **/
24 SimpleTest.waitForExplicitFinish();
25
26 const SEARCH_TEXT="minefield";
27
28 function getMatches() {
29 var numMatches = 0;
30
31 var searchRange = document.createRange();
32 searchRange.selectNodeContents(document.body);
33
34 var startPoint = searchRange.cloneRange();
35 startPoint.collapse(true);
36
37 var endPoint = searchRange.cloneRange();
38 endPoint.collapse(false);
39
40 var retRange = null;
41 var finder = SpecialPowers.Cc["@mozilla.org/embedcomp/rangefind;1"]
42 .createInstance(SpecialPowers.Ci.nsIFind);
43
44 finder.caseSensitive = false;
45
46 while ((retRange = finder.Find(SEARCH_TEXT, searchRange,
47 startPoint, endPoint))) {
48 numMatches++;
49
50 // Start next search from end of current match
51 startPoint = retRange.cloneRange();
52 startPoint.collapse(false);
53 }
54
55 return numMatches;
56 }
57
58 function onLoad() {
59 var matches = getMatches();
60 is(matches, 2, "found second match in anonymous content");
61 SimpleTest.finish();
62 }
63 </script>
64 </pre>
65 <input type="text" value="minefield minefield"></body>
66 </html>

mercurial