|
1 <?xml version="1.0"?> |
|
2 |
|
3 <!-- This Source Code Form is subject to the terms of the Mozilla Public |
|
4 - License, v. 2.0. If a copy of the MPL was not distributed with this |
|
5 - file, You can obtain one at http://mozilla.org/MPL/2.0/. --> |
|
6 |
|
7 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
8 |
|
9 <window id="409624test" |
|
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
11 width="600" |
|
12 height="600" |
|
13 title="409624 test"> |
|
14 |
|
15 <script type="application/javascript" |
|
16 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"/> |
|
17 |
|
18 <script type="application/javascript"><![CDATA[ |
|
19 var gFindBar = null; |
|
20 var gBrowser; |
|
21 |
|
22 var imports = ["SimpleTest", "ok", "is"]; |
|
23 for each (var name in imports) { |
|
24 window[name] = window.opener.wrappedJSObject[name]; |
|
25 } |
|
26 |
|
27 function finish() { |
|
28 window.close(); |
|
29 SimpleTest.finish(); |
|
30 } |
|
31 |
|
32 function startTest() { |
|
33 gFindBar = document.getElementById("FindToolbar"); |
|
34 gBrowser = document.getElementById("content"); |
|
35 gBrowser.addEventListener("pageshow", onPageShow, false); |
|
36 gBrowser.loadURI('data:text/html,<h2>Text mozilla</h2><input id="inp" type="text" />'); |
|
37 } |
|
38 |
|
39 function onPageShow() { |
|
40 gBrowser.removeEventListener("pageshow", onPageShow, false); |
|
41 gFindBar.clear(); |
|
42 let textbox = gFindBar.getElement("findbar-textbox"); |
|
43 |
|
44 // canClear / clear should work regardless of whether or not editor has |
|
45 // been lazily initialised yet |
|
46 ok(!gFindBar.canClear, "canClear property false when findbar empty"); |
|
47 textbox.value = "mozilla"; |
|
48 ok(gFindBar.canClear, "canClear property true when findbar value set without editor init"); |
|
49 gFindBar.clear(); |
|
50 is(textbox.value, '', "findbar input value cleared after clear() call without editor init"); |
|
51 ok(!gFindBar.canClear, "canClear property false after clear() call"); |
|
52 |
|
53 gFindBar.open(); |
|
54 let matchCaseCheckbox = gFindBar.getElement("find-case-sensitive"); |
|
55 if (!matchCaseCheckbox.hidden && matchCaseCheckbox.checked) |
|
56 matchCaseCheckbox.click(); |
|
57 ok(!matchCaseCheckbox.checked, "case-insensitivity correctly set"); |
|
58 |
|
59 // Simulate typical input |
|
60 textbox.focus(); |
|
61 gFindBar.clear(); |
|
62 sendChar("m"); |
|
63 ok(gFindBar.canClear, "canClear property true after input"); |
|
64 let preSelection = gBrowser.contentWindow.getSelection(); |
|
65 ok(!preSelection.isCollapsed, "Found item and selected range"); |
|
66 gFindBar.clear(); |
|
67 is(textbox.value, '', "findbar input value cleared after clear() call"); |
|
68 let postSelection = gBrowser.contentWindow.getSelection(); |
|
69 ok(postSelection.isCollapsed, "item found deselected after clear() call"); |
|
70 let fp = gFindBar.getElement("find-previous"); |
|
71 ok(fp.disabled, "find-previous button disabled after clear() call"); |
|
72 let fn = gFindBar.getElement("find-next"); |
|
73 ok(fn.disabled, "find-next button disabled after clear() call"); |
|
74 |
|
75 // Test status updated after a search for text not in page |
|
76 textbox.focus(); |
|
77 sendChar("x"); |
|
78 gFindBar.clear(); |
|
79 let ftext = gFindBar.getElement("find-status"); |
|
80 is(ftext.textContent, "", "status text disabled after clear() call"); |
|
81 |
|
82 // Test input empty with undo stack non-empty |
|
83 textbox.focus(); |
|
84 sendChar("m"); |
|
85 sendKey("BACK_SPACE"); |
|
86 ok(gFindBar.canClear, "canClear property true when undo available"); |
|
87 gFindBar.clear(); |
|
88 gFindBar.close(); |
|
89 |
|
90 finish(); |
|
91 } |
|
92 |
|
93 SimpleTest.waitForFocus(startTest, window); |
|
94 ]]></script> |
|
95 |
|
96 <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
|
97 <findbar id="FindToolbar" browserid="content"/> |
|
98 </window> |