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 * Make sure that we have the correct line selected after pretty printing.
6 */
8 const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html";
10 let gTab, gDebuggee, gPanel, gDebugger;
12 function test() {
13 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
14 gTab = aTab;
15 gDebuggee = aDebuggee;
16 gPanel = aPanel;
17 gDebugger = gPanel.panelWin;
19 waitForSourceShown(gPanel, "code_ugly.js")
20 .then(runCodeAndPause)
21 .then(() => {
22 const sourceShown = waitForSourceShown(gPanel, "code_ugly.js");
23 const caretUpdated = waitForCaretUpdated(gPanel, 7);
24 const finished = promise.all([sourceShown, caretUpdated]);
25 clickPrettyPrintButton();
26 return finished;
27 })
28 .then(resumeDebuggerThenCloseAndFinish.bind(null, gPanel))
29 .then(null, aError => {
30 ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
31 });
32 });
33 }
35 function runCodeAndPause() {
36 const deferred = promise.defer();
37 once(gDebugger.gThreadClient, "paused").then(deferred.resolve);
38 // Have to executeSoon so that we don't pause before this function returns.
39 executeSoon(gDebuggee.foo);
40 return deferred.promise;
41 }
43 function clickPrettyPrintButton() {
44 gDebugger.document.getElementById("pretty-print").click();
45 }
47 registerCleanupFunction(function() {
48 gTab = null;
49 gDebuggee = null;
50 gPanel = null;
51 gDebugger = null;
52 });