|
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="263683test" |
|
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="263683 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/html,<h2>Text mozilla</h2><input id="inp" type="text" />'); |
|
39 } |
|
40 |
|
41 function onPageShow() { |
|
42 gFindBar.open(); |
|
43 var search = "mozilla"; |
|
44 gFindBar._findField.value = search; |
|
45 var matchCase = gFindBar.getElement("find-case-sensitive"); |
|
46 if (matchCase.checked) |
|
47 matchCase.doCommand(); |
|
48 |
|
49 gFindBar._find(); |
|
50 var highlightButton = gFindBar.getElement("highlight"); |
|
51 if (!highlightButton.checked) |
|
52 highlightButton.click(); |
|
53 |
|
54 var controller = gFindBar.browser.docShell.QueryInterface(Ci.nsIInterfaceRequestor) |
|
55 .getInterface(Ci.nsISelectionDisplay) |
|
56 .QueryInterface(Ci.nsISelectionController); |
|
57 ok('SELECTION_FIND' in controller, "Correctly detects new selection type"); |
|
58 var selection = controller.getSelection(controller.SELECTION_FIND); |
|
59 |
|
60 ok(selection.rangeCount == 1, "Correctly added a match to the selection type"); |
|
61 ok(selection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match"); |
|
62 highlightButton.click(); |
|
63 ok(selection.rangeCount == 0, "Correctly removed the range"); |
|
64 |
|
65 var input = gBrowser.contentDocument.getElementById("inp"); |
|
66 input.value = search; |
|
67 |
|
68 highlightButton.click(); |
|
69 |
|
70 var inputController = input.editor.selectionController; |
|
71 var inputSelection = inputController.getSelection(inputController.SELECTION_FIND); |
|
72 |
|
73 ok(inputSelection.rangeCount == 1, "Correctly added a match from input to the selection type"); |
|
74 ok(inputSelection.getRangeAt(0).toString().toLowerCase() == search, "Added the correct match"); |
|
75 highlightButton.click(); |
|
76 ok(inputSelection.rangeCount == 0, "Correctly removed the range"); |
|
77 finish(); |
|
78 } |
|
79 ]]></script> |
|
80 |
|
81 <browser type="content-primary" flex="1" id="content" src="about:blank"/> |
|
82 <findbar id="FindToolbar" browserid="content"/> |
|
83 </window> |