|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that the function searching works with pretty printed sources. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.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 waitForSourceShown(gPanel, "code_ugly.js") |
|
22 .then(testUglySearch) |
|
23 .then(() => { |
|
24 const finished = waitForSourceShown(gPanel, "code_ugly.js"); |
|
25 clickPrettyPrintButton(); |
|
26 return finished; |
|
27 }) |
|
28 .then(testPrettyPrintedSearch) |
|
29 .then(() => closeDebuggerAndFinish(gPanel)) |
|
30 .then(null, aError => { |
|
31 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
32 }); |
|
33 }); |
|
34 } |
|
35 |
|
36 function testUglySearch() { |
|
37 const deferred = promise.defer(); |
|
38 |
|
39 once(gDebugger, "popupshown").then(() => { |
|
40 ok(isCaretPos(gPanel, 2, 10), |
|
41 "The bar function's non-pretty-printed location should be shown."); |
|
42 deferred.resolve(); |
|
43 }); |
|
44 |
|
45 setText(gSearchBox, "@bar"); |
|
46 return deferred.promise; |
|
47 } |
|
48 |
|
49 function clickPrettyPrintButton() { |
|
50 gDebugger.document.getElementById("pretty-print").click(); |
|
51 } |
|
52 |
|
53 function testPrettyPrintedSearch() { |
|
54 const deferred = promise.defer(); |
|
55 |
|
56 once(gDebugger, "popupshown").then(() => { |
|
57 ok(isCaretPos(gPanel, 6, 10), |
|
58 "The bar function's pretty printed location should be shown."); |
|
59 deferred.resolve(); |
|
60 }); |
|
61 |
|
62 setText(gSearchBox, "@bar"); |
|
63 return deferred.promise; |
|
64 } |
|
65 |
|
66 registerCleanupFunction(function() { |
|
67 gTab = null; |
|
68 gDebuggee = null; |
|
69 gPanel = null; |
|
70 gDebugger = null; |
|
71 gSearchBox = null; |
|
72 }); |