|
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="331215test" |
|
10 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" |
|
11 width="600" |
|
12 height="600" |
|
13 onload="SimpleTest.executeSoon(startTest);" |
|
14 title="331215 test"> |
|
15 |
|
16 <script type="application/javascript"><![CDATA[ |
|
17 const Ci = Components.interfaces; |
|
18 const Cc = Components.classes; |
|
19 const Cr = Components.results; |
|
20 |
|
21 var gFindBar = null; |
|
22 var gBrowser; |
|
23 |
|
24 var imports = ["SimpleTest", "ok"]; |
|
25 for each (var name in imports) { |
|
26 window[name] = window.opener.wrappedJSObject[name]; |
|
27 } |
|
28 |
|
29 function finish() { |
|
30 window.close(); |
|
31 SimpleTest.finish(); |
|
32 } |
|
33 |
|
34 function startTest() { |
|
35 gFindBar = document.getElementById("FindToolbar"); |
|
36 gBrowser = document.getElementById("content"); |
|
37 gBrowser.addEventListener("pageshow", onPageShow, false); |
|
38 gBrowser.loadURI("data:text/plain,latest"); |
|
39 } |
|
40 |
|
41 function onPageShow() { |
|
42 document.getElementById("cmd_find").doCommand(); |
|
43 enterStringIntoFindField("test"); |
|
44 document.commandDispatcher |
|
45 .getControllerForCommand("cmd_moveTop") |
|
46 .doCommand("cmd_moveTop"); |
|
47 enterStringIntoFindField("l"); |
|
48 ok(gFindBar._findField.getAttribute("status") == "notfound", |
|
49 "Findfield status attribute should have been 'notfound'" + |
|
50 " after entering ltest"); |
|
51 enterStringIntoFindField("a"); |
|
52 ok(gFindBar._findField.getAttribute("status") != "notfound", |
|
53 "Findfield status attribute should not have been 'notfound'" + |
|
54 " after entering latest"); |
|
55 finish(); |
|
56 } |
|
57 |
|
58 function enterStringIntoFindField(aString) { |
|
59 for (var i=0; i < aString.length; i++) { |
|
60 var event = document.createEvent("KeyEvents"); |
|
61 event.initKeyEvent("keypress", true, true, null, false, false, |
|
62 false, false, 0, aString.charCodeAt(i)); |
|
63 gFindBar._findField.inputField.dispatchEvent(event); |
|
64 } |
|
65 } |
|
66 ]]></script> |
|
67 |
|
68 <commandset> |
|
69 <command id="cmd_find" oncommand="document.getElementById('FindToolbar').onFindCommand();"/> |
|
70 </commandset> |
|
71 <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
|
72 <findbar id="FindToolbar" browserid="content"/> |
|
73 </window> |