PageRenderTime 18ms CodeModel.GetById 8ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/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
 39<html>
 40<!--
 41https://bugzilla.mozilla.org/show_bug.cgi?id=499115
 42-->
 43<head>
 44  <title>Test for Bug 499115</title>
 45  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 46  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 47</head>
 48<body onload="onLoad();">
 49  <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=499115">Mozilla Bug 499115</a>
 50  <p id="display"></p>
 51  <div id="content" style="display: none">
 52  </div>
 53  <pre id="test">
 54    <script type="application/javascript">
 55
 56      /** Test for Bug 499115 **/
 57      SimpleTest.waitForExplicitFinish();
 58
 59      const SEARCH_TEXT="minefield";
 60
 61      function getMatches() {
 62        var numMatches = 0;
 63
 64        var searchRange = document.createRange();
 65        searchRange.selectNodeContents(document.body);
 66
 67        var startPoint = searchRange.cloneRange();
 68        startPoint.collapse(true);
 69
 70        var endPoint = searchRange.cloneRange();
 71        endPoint.collapse(false);
 72
 73        var retRange = null;
 74        netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
 75        var finder = Components.classes["@mozilla.org/embedcomp/rangefind;1"]
 76                               .createInstance(Components.interfaces.nsIFind);
 77
 78        finder.caseSensitive = false;
 79
 80        while ((retRange = finder.Find(SEARCH_TEXT, searchRange,
 81                                       startPoint, endPoint))) {
 82          numMatches++;
 83
 84          // Start next search from end of current match
 85          startPoint = retRange.cloneRange();
 86          startPoint.collapse(false);
 87        }
 88
 89        return numMatches;
 90       }
 91
 92       function onLoad() {
 93         var matches = getMatches();
 94         is(matches, 2, "found second match in anonymous content");
 95         SimpleTest.finish();
 96       }
 97   </script>
 98  </pre>
 99<input type="text" value="minefield minefield"></body>
100</html>