|
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="429723Test" |
|
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
11 width="600" |
|
12 height="600" |
|
13 onload="onLoad();" |
|
14 title="429723 test"> |
|
15 |
|
16 <script type="application/javascript"><![CDATA[ |
|
17 var gFindBar = null; |
|
18 var gBrowser; |
|
19 |
|
20 function ok(condition, message) { |
|
21 window.opener.wrappedJSObject.SimpleTest.ok(condition, message); |
|
22 } |
|
23 |
|
24 function finish() { |
|
25 window.close(); |
|
26 window.opener.wrappedJSObject.SimpleTest.finish(); |
|
27 } |
|
28 |
|
29 function onLoad() { |
|
30 var _delayedOnLoad = function() { |
|
31 gFindBar = document.getElementById("FindToolbar"); |
|
32 gBrowser = document.getElementById("content"); |
|
33 gBrowser.addEventListener("pageshow", onPageShow, false); |
|
34 gBrowser.loadURI("data:text/html,<h2 id='h2'>mozilla</h2>"); |
|
35 } |
|
36 setTimeout(_delayedOnLoad, 1000); |
|
37 } |
|
38 |
|
39 function enterStringIntoFindField(aString) { |
|
40 for (var i=0; i < aString.length; i++) { |
|
41 var event = document.createEvent("KeyEvents"); |
|
42 event.initKeyEvent("keypress", true, true, null, false, false, |
|
43 false, false, 0, aString.charCodeAt(i)); |
|
44 gFindBar._findField.inputField.dispatchEvent(event); |
|
45 } |
|
46 } |
|
47 |
|
48 function onPageShow() { |
|
49 gBrowser.removeEventListener("pageshow", onPageShow, false); |
|
50 var findField = gFindBar._findField; |
|
51 document.getElementById("cmd_find").doCommand(); |
|
52 |
|
53 var matchCaseCheckbox = gFindBar.getElement("find-case-sensitive"); |
|
54 if (!matchCaseCheckbox.hidden & matchCaseCheckbox.checked) |
|
55 matchCaseCheckbox.click(); |
|
56 |
|
57 // Perform search |
|
58 var searchStr = "z"; |
|
59 enterStringIntoFindField(searchStr); |
|
60 |
|
61 // Highlight search term |
|
62 var highlight = gFindBar.getElement("highlight"); |
|
63 if (!highlight.checked) |
|
64 highlight.click(); |
|
65 |
|
66 // Delete search term |
|
67 var event = document.createEvent("KeyEvents"); |
|
68 event.initKeyEvent("keypress", true, true, null, false, false, |
|
69 false, false, KeyEvent.DOM_VK_BACK_SPACE, 0); |
|
70 gFindBar._findField.inputField.dispatchEvent(event); |
|
71 |
|
72 var notRed = !findField.hasAttribute("status") || |
|
73 (findField.getAttribute("status") != "notfound"); |
|
74 ok(notRed, "Find Bar textbox is correct colour"); |
|
75 finish(); |
|
76 } |
|
77 ]]></script> |
|
78 |
|
79 <commandset> |
|
80 <command id="cmd_find" oncommand="document.getElementById('FindToolbar').onFindCommand();"/> |
|
81 </commandset> |
|
82 <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
|
83 <findbar id="FindToolbar" browserid="content"/> |
|
84 </window> |