/embedding/test/test_bug499115.html

http://github.com/zpao/v8monkey · HTML · 100 lines · 48 code · 13 blank · 39 comment · 0 complexity · d06b37dbff4dfeaebaa74d9a37657da6 MD5 · raw file

  1. <!DOCTYPE HTML>
  2. <!-- ***** BEGIN LICENSE BLOCK *****
  3. - Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. -
  5. - The contents of this file are subject to the Mozilla Public License Version
  6. - 1.1 (the "License"); you may not use this file except in compliance with
  7. - the License. You may obtain a copy of the License at
  8. - http://www.mozilla.org/MPL/
  9. -
  10. - Software distributed under the License is distributed on an "AS IS" basis,
  11. - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. - for the specific language governing rights and limitations under the
  13. - License.
  14. -
  15. - The Original Code is nsFind test code
  16. -
  17. - The Initial Developer of the Original Code is
  18. - Graeme McCutcheon <graememcc_firefox@graeme-online.co.uk>
  19. - Portions created by the Initial Developer are Copyright (C) 2009
  20. - the Initial Developer. All Rights Reserved.
  21. -
  22. - Contributor(s):
  23. -
  24. -
  25. - Alternatively, the contents of this file may be used under the terms of
  26. - either the GNU General Public License Version 2 or later (the "GPL"), or
  27. - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  28. - in which case the provisions of the GPL or the LGPL are applicable instead
  29. - of those above. If you wish to allow use of your version of this file only
  30. - under the terms of either the GPL or the LGPL, and not to allow others to
  31. - use your version of this file under the terms of the MPL, indicate your
  32. - decision by deleting the provisions above and replace them with the notice
  33. - and other provisions required by the LGPL or the GPL. If you do not delete
  34. - the provisions above, a recipient may use your version of this file under
  35. - the terms of any one of the MPL, the GPL or the LGPL.
  36. -
  37. - ***** END LICENSE BLOCK ***** -->
  38. <html>
  39. <!--
  40. https://bugzilla.mozilla.org/show_bug.cgi?id=499115
  41. -->
  42. <head>
  43. <title>Test for Bug 499115</title>
  44. <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  45. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  46. </head>
  47. <body onload="onLoad();">
  48. <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=499115">Mozilla Bug 499115</a>
  49. <p id="display"></p>
  50. <div id="content" style="display: none">
  51. </div>
  52. <pre id="test">
  53. <script type="application/javascript">
  54. /** Test for Bug 499115 **/
  55. SimpleTest.waitForExplicitFinish();
  56. const SEARCH_TEXT="minefield";
  57. function getMatches() {
  58. var numMatches = 0;
  59. var searchRange = document.createRange();
  60. searchRange.selectNodeContents(document.body);
  61. var startPoint = searchRange.cloneRange();
  62. startPoint.collapse(true);
  63. var endPoint = searchRange.cloneRange();
  64. endPoint.collapse(false);
  65. var retRange = null;
  66. netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
  67. var finder = Components.classes["@mozilla.org/embedcomp/rangefind;1"]
  68. .createInstance(Components.interfaces.nsIFind);
  69. finder.caseSensitive = false;
  70. while ((retRange = finder.Find(SEARCH_TEXT, searchRange,
  71. startPoint, endPoint))) {
  72. numMatches++;
  73. // Start next search from end of current match
  74. startPoint = retRange.cloneRange();
  75. startPoint.collapse(false);
  76. }
  77. return numMatches;
  78. }
  79. function onLoad() {
  80. var matches = getMatches();
  81. is(matches, 2, "found second match in anonymous content");
  82. SimpleTest.finish();
  83. }
  84. </script>
  85. </pre>
  86. <input type="text" value="minefield minefield"></body>
  87. </html>