|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test that we highlight matching calls and returns on hover. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 |
|
12 function test() { |
|
13 SpecialPowers.pushPrefEnv({'set': [["devtools.debugger.tracer", true]]}, () => { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 |
|
20 waitForSourceShown(gPanel, "code_tracing-01.js") |
|
21 .then(() => startTracing(gPanel)) |
|
22 .then(clickButton) |
|
23 .then(() => waitForClientEvents(aPanel, "traces")) |
|
24 .then(highlightCall) |
|
25 .then(testReturnHighlighted) |
|
26 .then(unhighlightCall) |
|
27 .then(testNoneHighlighted) |
|
28 .then(() => stopTracing(gPanel)) |
|
29 .then(() => { |
|
30 const deferred = promise.defer(); |
|
31 SpecialPowers.popPrefEnv(deferred.resolve); |
|
32 return deferred.promise; |
|
33 }) |
|
34 .then(() => closeDebuggerAndFinish(gPanel)) |
|
35 .then(null, aError => { |
|
36 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
37 }); |
|
38 }); |
|
39 }); |
|
40 } |
|
41 |
|
42 function clickButton() { |
|
43 EventUtils.sendMouseEvent({ type: "click" }, |
|
44 gDebuggee.document.querySelector("button"), |
|
45 gDebuggee); |
|
46 } |
|
47 |
|
48 function highlightCall() { |
|
49 const callTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0]; |
|
50 EventUtils.sendMouseEvent({ type: "mouseover" }, |
|
51 callTrace, |
|
52 gDebugger); |
|
53 } |
|
54 |
|
55 function testReturnHighlighted() { |
|
56 const returnTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[1]; |
|
57 ok(Array.indexOf(returnTrace.querySelector(".trace-item").classList, "selected-matching") >= 0, |
|
58 "The corresponding return log should be highlighted."); |
|
59 } |
|
60 |
|
61 function unhighlightCall() { |
|
62 const callTrace = filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0]; |
|
63 EventUtils.sendMouseEvent({ type: "mouseout" }, |
|
64 callTrace, |
|
65 gDebugger); |
|
66 } |
|
67 |
|
68 function testNoneHighlighted() { |
|
69 const highlightedTraces = filterTraces(gPanel, t => t.querySelector(".selected-matching")); |
|
70 is(highlightedTraces.length, 0, "Shouldn't have any highlighted traces"); |
|
71 } |
|
72 |
|
73 registerCleanupFunction(function() { |
|
74 gTab = null; |
|
75 gDebuggee = null; |
|
76 gPanel = null; |
|
77 gDebugger = null; |
|
78 }); |