Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Test that we can jump to function definitions by clicking on logs.
6 */
8 const TAB_URL = EXAMPLE_URL + "doc_tracing-01.html";
10 let gTab, gDebuggee, gPanel, gDebugger;
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;
20 waitForSourceShown(gPanel, "code_tracing-01.js")
21 .then(() => startTracing(gPanel))
22 .then(clickButton)
23 .then(() => waitForClientEvents(aPanel, "traces"))
24 .then(() => {
25 // Switch away from the JS file so we can make sure that clicking on a
26 // log will switch us back to the correct JS file.
27 aPanel.panelWin.DebuggerView.Sources.selectedValue = TAB_URL;
28 return ensureSourceIs(aPanel, TAB_URL, true);
29 })
30 .then(() => {
31 const finished = waitForSourceShown(gPanel, "code_tracing-01.js");
32 clickTraceLog();
33 return finished;
34 })
35 .then(testCorrectLine)
36 .then(() => stopTracing(gPanel))
37 .then(() => {
38 const deferred = promise.defer();
39 SpecialPowers.popPrefEnv(deferred.resolve);
40 return deferred.promise;
41 })
42 .then(() => closeDebuggerAndFinish(gPanel))
43 .then(null, aError => {
44 ok(false, "Got an error: " + aError.message + "\n" + aError.stack);
45 });
46 });
47 });
48 }
50 function clickButton() {
51 EventUtils.sendMouseEvent({ type: "click" },
52 gDebuggee.document.querySelector("button"),
53 gDebuggee);
54 }
56 function clickTraceLog() {
57 filterTraces(gPanel, t => t.querySelector(".trace-name[value=main]"))[0].click();
58 }
60 function testCorrectLine() {
61 is(gDebugger.DebuggerView.editor.getCursor().line, 19,
62 "The editor should have the function definition site's line selected.");
63 }
65 registerCleanupFunction(function() {
66 gTab = null;
67 gDebuggee = null;
68 gPanel = null;
69 gDebugger = null;
70 });