|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that the searchbox popup is displayed when focusing the searchbox, |
|
6 * and hidden when the user starts typing. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 let gSearchBox, gSearchBoxPanel; |
|
13 |
|
14 function test() { |
|
15 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
16 gTab = aTab; |
|
17 gDebuggee = aDebuggee; |
|
18 gPanel = aPanel; |
|
19 gDebugger = gPanel.panelWin; |
|
20 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
|
21 gSearchBoxPanel = gDebugger.DebuggerView.Filtering._searchboxHelpPanel; |
|
22 |
|
23 waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1) |
|
24 .then(showPopup) |
|
25 .then(hidePopup) |
|
26 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
27 .then(null, aError => { |
|
28 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
29 }); |
|
30 |
|
31 gDebuggee.firstCall(); |
|
32 }); |
|
33 } |
|
34 |
|
35 function showPopup() { |
|
36 is(gSearchBoxPanel.state, "closed", |
|
37 "The search box panel shouldn't be visible yet."); |
|
38 |
|
39 let finished = once(gSearchBoxPanel, "popupshown"); |
|
40 EventUtils.sendMouseEvent({ type: "click" }, gSearchBox, gDebugger); |
|
41 return finished; |
|
42 } |
|
43 |
|
44 function hidePopup() { |
|
45 is(gSearchBoxPanel.state, "open", |
|
46 "The search box panel should be visible after searching started."); |
|
47 |
|
48 let finished = once(gSearchBoxPanel, "popuphidden"); |
|
49 setText(gSearchBox, "#"); |
|
50 return finished; |
|
51 } |
|
52 |
|
53 registerCleanupFunction(function() { |
|
54 gTab = null; |
|
55 gDebuggee = null; |
|
56 gPanel = null; |
|
57 gDebugger = null; |
|
58 gSearchBox = null; |
|
59 gSearchBoxPanel = null; |
|
60 }); |