Bug 448909 - Need more controls WHATWG Video tag (followup patch). r=mconnor
[wine-gecko.git] / embedding / test / test_nsFind.html
blobe15ee611a44bf0e59ca536f91ae45aacfa73e879
1 <!DOCTYPE HTML>
2 <html>
3 <!--
4 https://bugzilla.mozilla.org/show_bug.cgi?id=450048
5 -->
6 <head>
7 <title>Test for nsFind::Find()</title>
8 <script type="application/javascript" src="/MochiKit/MochiKit.js"></script>
9 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
11 </head>
12 <body>
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=450048">Mozilla Bug 450048</a>
14 <p id="display">This is the text to search i<b>n&shy;t</b>o</p>
15 <div id="content" style="display: none">
17 </div>
18 <pre id="test">
19 <script type="application/javascript">
21 /** Test for Bug 450048 **/
23 // Check nsFind class and its nsIFind interface.
25 netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
27 var rf = Components.classes["@mozilla.org/embedcomp/rangefind;1"]
28 .getService(Components.interfaces.nsIFind);
30 var display = window.document.getElementById("display");
31 var searchRange = window.document.createRange();
32 searchRange.setStart(display, 0);
33 searchRange.setEnd(display, display.childNodes.length);
34 var startPt = searchRange;
35 var endPt = searchRange;
37 // Check |null| detection on |aPatText| parameter.
38 try {
39 rf.Find(null, searchRange, startPt, endPt);
41 ok(false, "Missing NS_ERROR_NULL_POINTER exception");
42 } catch (e if (e instanceof Components.interfaces.nsIException &&
43 e.result == Components.results.NS_ERROR_NULL_POINTER)) {
44 ok(true, null);
47 // Check |null| detection on |aSearchRange| parameter.
48 try {
49 rf.Find("", null, startPt, endPt);
51 ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
52 } catch (e if (e instanceof Components.interfaces.nsIException &&
53 e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
54 ok(true, null);
57 // Check |null| detection on |aStartPoint| parameter.
58 try {
59 rf.Find("", searchRange, null, endPt);
61 ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
62 } catch (e if (e instanceof Components.interfaces.nsIException &&
63 e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
64 ok(true, null);
67 // Check |null| detection on |aEndPoint| parameter.
68 try {
69 rf.Find("", searchRange, startPt, null);
71 ok(false, "Missing NS_ERROR_ILLEGAL_VALUE exception");
72 } catch (e if (e instanceof Components.interfaces.nsIException &&
73 e.result == Components.results.NS_ERROR_ILLEGAL_VALUE)) {
74 ok(true, null);
77 var searchValue, retRange;
79 rf.findBackwards = false;
81 rf.caseSensitive = false;
83 searchValue = "TexT";
84 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
85 ok(retRange, "\"" + searchValue + "\" not found (not caseSensitive)");
87 rf.caseSensitive = true;
89 // searchValue = "TexT";
90 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
91 ok(!retRange, "\"" + searchValue + "\" found (caseSensitive)");
93 searchValue = "text";
94 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
95 ok(retRange, "\"" + searchValue + "\" not found");
97 // Matches |i<b>n&shy;t</b>o|.
98 searchValue = "into";
99 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
100 ok(retRange, "\"" + searchValue + "\" not found");
102 // Matches inside |search|.
103 searchValue = "ear";
104 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
105 ok(retRange, "\"" + searchValue + "\" not found");
107 // Set new start point (to end of last search).
108 startPt = retRange.endContainer.ownerDocument.createRange();
109 startPt.setStart(retRange.endContainer, retRange.endOffset);
110 startPt.setEnd(retRange.endContainer, retRange.endOffset);
112 searchValue = "t";
113 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
114 ok(retRange, "\"" + searchValue + "\" not found (forward)");
116 searchValue = "the";
117 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
118 ok(!retRange, "\"" + searchValue + "\" found (forward)");
120 rf.findBackwards = true;
122 // searchValue = "the";
123 retRange = rf.Find(searchValue, searchRange, startPt, endPt);
124 ok(retRange, "\"" + searchValue + "\" not found (backward)");
125 </script>
126 </pre>
127 </body>
128 </html>