Bug 450048 - "nsFind.cpp(961) : warning C4309: 'initializing' : truncation of constant value"; class/interface test; r+sr=jst
authorSerge Gautherie <sgautherie.bz@free.fr>
Tue, 23 Sep 2008 03:32:13 +0200
changeset 19528 d863285d009398ac733fb867aec8bb7a740a1d6f
parent 19527 aa0321d6a38d2187935f0b1bb44aedf604d1becf
child 19529 ec4d1b4c63e95b1d3ba43f7d709708f1d56a0d04
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs450048
milestone1.9.1b1pre
Bug 450048 - "nsFind.cpp(961) : warning C4309: 'initializing' : truncation of constant value"; class/interface test; r+sr=jst
embedding/components/find/public/nsIFind.idl
embedding/test/Makefile.in
embedding/test/test_nsFind.html
--- a/embedding/components/find/public/nsIFind.idl
+++ b/embedding/components/find/public/nsIFind.idl
@@ -46,31 +46,27 @@ interface nsIFind : nsISupports
 {
   attribute boolean findBackwards;
   attribute boolean caseSensitive;
 
   /**
    * Use "find entire words" mode by setting to a word breaker
    * or null, to disable "entire words" mode.
    */
-  attribute nsIWordBreaker wordBreaker;
+  [noscript] attribute nsIWordBreaker wordBreaker;
 
   /**
    * Find some text in the current context. The implementation is
    * responsible for performing the find and highlighting the text.
    *
    * @param aPatText     The text to search for.
    * @param aSearchRange A Range specifying domain of search.
    * @param aStartPoint  A Range specifying search start point.
    *                     If not collapsed, we'll start from
    *                     end (forward) or start (backward).
-   *                     May be null; if so, we'll start at the start
-   *                     (forward) or end (back) of aSearchRange.
    * @param aEndPoint    A Range specifying search end point.
    *                     If not collapsed, we'll end at
    *                     end (forward) or start (backward).
-   *                     May be null; if so, we'll end at the end
-   *                     (forward) or start (back) of aSearchRange.
    * @retval             A range spanning the match that was found (or null).
    */
   nsIDOMRange Find(in wstring aPatText, in nsIDOMRange aSearchRange,
                    in nsIDOMRange aStartPoint, in nsIDOMRange aEndPoint);
 };
--- a/embedding/test/Makefile.in
+++ b/embedding/test/Makefile.in
@@ -38,15 +38,16 @@ DEPTH		= ../..
 topsrcdir	= @top_srcdir@
 srcdir		= @srcdir@
 VPATH		= @srcdir@
 relativesrcdir  = embedding/test
 
 include $(DEPTH)/config/autoconf.mk
 include $(topsrcdir)/config/rules.mk
 
-_TEST_FILES =	test_bug293834.html \
-		bug293834_form.html \
-		$(NULL)
+_TEST_FILES = \
+	test_bug293834.html \
+	bug293834_form.html \
+	test_nsFind.html \
+	$(NULL)
 
 libs:: $(_TEST_FILES)
 	$(INSTALL) $(foreach f,$^,"$f") $(DEPTH)/_tests/testing/mochitest/tests/$(relativesrcdir)
-
new file mode 100644
--- /dev/null
+++ b/embedding/test/test_nsFind.html
@@ -0,0 +1,128 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=450048
+-->
+<head>
+  <title>Test for nsFind::Find()</title>
+  <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
+  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
+<p id="display">This is the text to search i<b>n&shy;t</b>o</p>
+<div id="content" style="display: none">
+  
+</div>
+<pre id="test">
+<script type="application/javascript">
+
+/** Test for Bug 450048 **/
+
+  // Check nsFind class and its nsIFind interface.
+
+  netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
+
+  var rf = Components.classes["@mozilla.org/embedcomp/rangefind;1"]
+                     .getService(Components.interfaces.nsIFind);
+
+  var display = window.document.getElementById("display");
+  var searchRange = window.document.createRange();
+  searchRange.setStart(display, 0);
+  searchRange.setEnd(display, display.childNodes.length);
+  var startPt = searchRange;
+  var endPt = searchRange;
+
+  // Check |null| detection on |aPatText| parameter.
+  try {
+    rf.Find(null, searchRange, startPt, endPt);
+
+    ok(false, "Missing NS_ERROR_NULL_POINTER exception");
+  } catch (e if (e instanceof Components.interfaces.nsIException &&
+                 e.result == Components.results.NS_ERROR_NULL_POINTER)) {
+    ok(true, null);
+  }
+
+  // Check |null| detection on |aSearchRange| parameter.
+  try {
+    rf.Find("", null, startPt, endPt);
+
+    ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
+  } catch (e if (e instanceof Components.interfaces.nsIException &&
+                 e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
+    ok(true, null);
+  }
+
+  // Check |null| detection on |aStartPoint| parameter.
+  try {
+    rf.Find("", searchRange, null, endPt);
+
+    ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
+  } catch (e if (e instanceof Components.interfaces.nsIException &&
+                 e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
+    ok(true, null);
+  }
+
+  // Check |null| detection on |aEndPoint| parameter.
+  try {
+    rf.Find("", searchRange, startPt, null);
+
+    ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
+  } catch (e if (e instanceof Components.interfaces.nsIException &&
+                 e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
+    ok(true, null);
+  }
+
+  var searchValue, retRange;
+
+  rf.findBackwards = false;
+
+  rf.caseSensitive = false;
+
+  searchValue = "TexT";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(retRange, "\"" + searchValue + "\" not found (not caseSensitive)");
+
+  rf.caseSensitive = true;
+
+  // searchValue = "TexT";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(!retRange, "\"" + searchValue + "\" found (caseSensitive)");
+
+  searchValue = "text";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(retRange, "\"" + searchValue + "\" not found");
+
+  // Matches |i<b>n&shy;t</b>o|.
+  searchValue = "into";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(retRange, "\"" + searchValue + "\" not found");
+
+  // Matches inside |search|.
+  searchValue = "ear";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(retRange, "\"" + searchValue + "\" not found");
+
+  // Set new start point (to end of last search).
+  startPt = retRange.endContainer.ownerDocument.createRange();
+  startPt.setStart(retRange.endContainer, retRange.endOffset);
+  startPt.setEnd(retRange.endContainer, retRange.endOffset);
+
+  searchValue = "t";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(retRange, "\"" + searchValue + "\" not found (forward)");
+
+  searchValue = "the";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(!retRange, "\"" + searchValue + "\" found (forward)");
+
+  rf.findBackwards = true;
+
+  // searchValue = "the";
+  retRange = rf.Find(searchValue, searchRange, startPt, endPt);
+  ok(retRange, "\"" + searchValue + "\" not found (backward)");
+</script>
+</pre>
+</body>
+</html>