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