|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that sources aren't selected by default when finding a match. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 let gSearchBox; |
|
12 |
|
13 function test() { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
|
20 |
|
21 gDebugger.DebuggerView.FilteredSources._autoSelectFirstItem = false; |
|
22 gDebugger.DebuggerView.FilteredFunctions._autoSelectFirstItem = false; |
|
23 |
|
24 waitForSourceShown(gPanel, "-01.js") |
|
25 .then(superGenericFileSearch) |
|
26 .then(() => ensureSourceIs(aPanel, "-01.js")) |
|
27 .then(() => ensureCaretAt(aPanel, 1)) |
|
28 |
|
29 .then(superAccurateFileSearch) |
|
30 .then(() => ensureSourceIs(aPanel, "-01.js")) |
|
31 .then(() => ensureCaretAt(aPanel, 1)) |
|
32 .then(() => pressKeyToHide("RETURN")) |
|
33 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode", true)) |
|
34 .then(() => ensureCaretAt(aPanel, 1)) |
|
35 |
|
36 .then(superGenericFileSearch) |
|
37 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) |
|
38 .then(() => ensureCaretAt(aPanel, 1)) |
|
39 .then(() => pressKey("UP")) |
|
40 .then(() => ensureSourceIs(aPanel, "doc_editor-mode", true)) |
|
41 .then(() => ensureCaretAt(aPanel, 1)) |
|
42 .then(() => pressKeyToHide("RETURN")) |
|
43 .then(() => ensureSourceIs(aPanel, "doc_editor-mode")) |
|
44 .then(() => ensureCaretAt(aPanel, 1)) |
|
45 |
|
46 .then(superAccurateFileSearch) |
|
47 .then(() => ensureSourceIs(aPanel, "doc_editor-mode")) |
|
48 .then(() => ensureCaretAt(aPanel, 1)) |
|
49 .then(() => typeText(gSearchBox, ":")) |
|
50 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode", true)) |
|
51 .then(() => ensureCaretAt(aPanel, 1)) |
|
52 .then(() => typeText(gSearchBox, "5")) |
|
53 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) |
|
54 .then(() => ensureCaretAt(aPanel, 5)) |
|
55 .then(() => pressKey("DOWN")) |
|
56 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) |
|
57 .then(() => ensureCaretAt(aPanel, 6)) |
|
58 |
|
59 .then(superGenericFunctionSearch) |
|
60 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) |
|
61 .then(() => ensureCaretAt(aPanel, 6)) |
|
62 .then(() => pressKey("RETURN")) |
|
63 .then(() => ensureSourceIs(aPanel, "code_test-editor-mode")) |
|
64 .then(() => ensureCaretAt(aPanel, 4, 10)) |
|
65 |
|
66 .then(() => closeDebuggerAndFinish(gPanel)) |
|
67 .then(null, aError => { |
|
68 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
69 }); |
|
70 }); |
|
71 } |
|
72 |
|
73 function waitForMatchFoundAndResultsShown(aName) { |
|
74 return promise.all([ |
|
75 once(gDebugger, "popupshown"), |
|
76 waitForDebuggerEvents(gPanel, gDebugger.EVENTS[aName]) |
|
77 ]); |
|
78 } |
|
79 |
|
80 function waitForResultsHidden() { |
|
81 return once(gDebugger, "popuphidden"); |
|
82 } |
|
83 |
|
84 function superGenericFunctionSearch() { |
|
85 let finished = waitForMatchFoundAndResultsShown("FUNCTION_SEARCH_MATCH_FOUND"); |
|
86 setText(gSearchBox, "@"); |
|
87 return finished; |
|
88 } |
|
89 |
|
90 function superGenericFileSearch() { |
|
91 let finished = waitForMatchFoundAndResultsShown("FILE_SEARCH_MATCH_FOUND"); |
|
92 setText(gSearchBox, "."); |
|
93 return finished; |
|
94 } |
|
95 |
|
96 function superAccurateFileSearch() { |
|
97 let finished = waitForMatchFoundAndResultsShown("FILE_SEARCH_MATCH_FOUND"); |
|
98 setText(gSearchBox, "editor"); |
|
99 return finished; |
|
100 } |
|
101 |
|
102 function pressKey(aKey) { |
|
103 EventUtils.sendKey(aKey, gDebugger); |
|
104 } |
|
105 |
|
106 function pressKeyToHide(aKey) { |
|
107 let finished = waitForResultsHidden(); |
|
108 EventUtils.sendKey(aKey, gDebugger); |
|
109 return finished; |
|
110 } |
|
111 |
|
112 registerCleanupFunction(function() { |
|
113 gTab = null; |
|
114 gDebuggee = null; |
|
115 gPanel = null; |
|
116 gDebugger = null; |
|
117 gSearchBox = null; |
|
118 }); |