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