|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that while searching for files, the sources list remains unchanged. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_editor-mode.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 let gSources, 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 gSources = gDebugger.DebuggerView.Sources; |
|
20 gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; |
|
21 |
|
22 waitForSourceShown(gPanel, "-01.js") |
|
23 .then(superGenericSearch) |
|
24 .then(verifySourcesPane) |
|
25 .then(kindaInterpretableSearch) |
|
26 .then(verifySourcesPane) |
|
27 .then(incrediblySpecificSearch) |
|
28 .then(verifySourcesPane) |
|
29 .then(returnAndHide) |
|
30 .then(verifySourcesPane) |
|
31 .then(() => closeDebuggerAndFinish(gPanel)) |
|
32 .then(null, aError => { |
|
33 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
34 }); |
|
35 }); |
|
36 } |
|
37 |
|
38 function waitForMatchFoundAndResultsShown() { |
|
39 return promise.all([ |
|
40 once(gDebugger, "popupshown"), |
|
41 waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FILE_SEARCH_MATCH_FOUND) |
|
42 ]).then(() => promise.all([ |
|
43 ensureSourceIs(gPanel, "-01.js"), |
|
44 ensureCaretAt(gPanel, 1) |
|
45 ])); |
|
46 } |
|
47 |
|
48 function waitForResultsHidden() { |
|
49 return once(gDebugger, "popuphidden").then(() => promise.all([ |
|
50 ensureSourceIs(gPanel, "-01.js"), |
|
51 ensureCaretAt(gPanel, 1) |
|
52 ])); |
|
53 } |
|
54 |
|
55 function superGenericSearch() { |
|
56 let finished = waitForMatchFoundAndResultsShown(); |
|
57 setText(gSearchBox, "."); |
|
58 return finished; |
|
59 } |
|
60 |
|
61 function kindaInterpretableSearch() { |
|
62 let finished = waitForMatchFoundAndResultsShown(); |
|
63 typeText(gSearchBox, "-0"); |
|
64 return finished; |
|
65 } |
|
66 |
|
67 function incrediblySpecificSearch() { |
|
68 let finished = waitForMatchFoundAndResultsShown(); |
|
69 typeText(gSearchBox, "1.js"); |
|
70 return finished; |
|
71 } |
|
72 |
|
73 function returnAndHide() { |
|
74 let finished = waitForResultsHidden(); |
|
75 EventUtils.sendKey("RETURN", gDebugger); |
|
76 return finished; |
|
77 } |
|
78 |
|
79 function verifySourcesPane() { |
|
80 is(gSources.itemCount, 3, |
|
81 "There should be 3 items present in the sources container."); |
|
82 is(gSources.visibleItems.length, 3, |
|
83 "There should be no hidden items in the sources container."); |
|
84 |
|
85 ok(gSources.getItemForAttachment(e => e.label == "code_script-switching-01.js"), |
|
86 "The first source's label should be correct."); |
|
87 ok(gSources.getItemForAttachment(e => e.label == "code_test-editor-mode"), |
|
88 "The second source's label should be correct."); |
|
89 ok(gSources.getItemForAttachment(e => e.label == "doc_editor-mode.html"), |
|
90 "The third source's label should be correct."); |
|
91 } |
|
92 |
|
93 registerCleanupFunction(function() { |
|
94 gTab = null; |
|
95 gDebuggee = null; |
|
96 gPanel = null; |
|
97 gDebugger = null; |
|
98 gSources = null; |
|
99 gSearchBox = null; |
|
100 }); |