2009-06-26 12:46:31 +04:00
|
|
|
<!DOCTYPE HTML>
|
2012-05-21 15:12:37 +04:00
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
2009-06-26 12:46:31 +04:00
|
|
|
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=499115
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 499115</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body onload="onLoad();">
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=499115">Mozilla Bug 499115</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 499115 **/
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
const SEARCH_TEXT="minefield";
|
|
|
|
|
|
|
|
function getMatches() {
|
|
|
|
var numMatches = 0;
|
|
|
|
|
|
|
|
var searchRange = document.createRange();
|
|
|
|
searchRange.selectNodeContents(document.body);
|
|
|
|
|
|
|
|
var startPoint = searchRange.cloneRange();
|
|
|
|
startPoint.collapse(true);
|
|
|
|
|
|
|
|
var endPoint = searchRange.cloneRange();
|
|
|
|
endPoint.collapse(false);
|
|
|
|
|
|
|
|
var retRange = null;
|
|
|
|
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
|
|
|
var finder = Components.classes["@mozilla.org/embedcomp/rangefind;1"]
|
|
|
|
.createInstance(Components.interfaces.nsIFind);
|
|
|
|
|
|
|
|
finder.caseSensitive = false;
|
|
|
|
|
|
|
|
while ((retRange = finder.Find(SEARCH_TEXT, searchRange,
|
|
|
|
startPoint, endPoint))) {
|
|
|
|
numMatches++;
|
|
|
|
|
|
|
|
// Start next search from end of current match
|
|
|
|
startPoint = retRange.cloneRange();
|
|
|
|
startPoint.collapse(false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return numMatches;
|
|
|
|
}
|
|
|
|
|
|
|
|
function onLoad() {
|
|
|
|
var matches = getMatches();
|
|
|
|
is(matches, 2, "found second match in anonymous content");
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
<input type="text" value="minefield minefield"></body>
|
|
|
|
</html>
|