1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-04.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that the function searching works with pretty printed sources. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_pretty-print.html"; 1.12 + 1.13 +let gTab, gDebuggee, gPanel, gDebugger; 1.14 +let gSearchBox; 1.15 + 1.16 +function test() { 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + gSearchBox = gDebugger.DebuggerView.Filtering._searchbox; 1.23 + 1.24 + waitForSourceShown(gPanel, "code_ugly.js") 1.25 + .then(testUglySearch) 1.26 + .then(() => { 1.27 + const finished = waitForSourceShown(gPanel, "code_ugly.js"); 1.28 + clickPrettyPrintButton(); 1.29 + return finished; 1.30 + }) 1.31 + .then(testPrettyPrintedSearch) 1.32 + .then(() => closeDebuggerAndFinish(gPanel)) 1.33 + .then(null, aError => { 1.34 + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); 1.35 + }); 1.36 + }); 1.37 +} 1.38 + 1.39 +function testUglySearch() { 1.40 + const deferred = promise.defer(); 1.41 + 1.42 + once(gDebugger, "popupshown").then(() => { 1.43 + ok(isCaretPos(gPanel, 2, 10), 1.44 + "The bar function's non-pretty-printed location should be shown."); 1.45 + deferred.resolve(); 1.46 + }); 1.47 + 1.48 + setText(gSearchBox, "@bar"); 1.49 + return deferred.promise; 1.50 +} 1.51 + 1.52 +function clickPrettyPrintButton() { 1.53 + gDebugger.document.getElementById("pretty-print").click(); 1.54 +} 1.55 + 1.56 +function testPrettyPrintedSearch() { 1.57 + const deferred = promise.defer(); 1.58 + 1.59 + once(gDebugger, "popupshown").then(() => { 1.60 + ok(isCaretPos(gPanel, 6, 10), 1.61 + "The bar function's pretty printed location should be shown."); 1.62 + deferred.resolve(); 1.63 + }); 1.64 + 1.65 + setText(gSearchBox, "@bar"); 1.66 + return deferred.promise; 1.67 +} 1.68 + 1.69 +registerCleanupFunction(function() { 1.70 + gTab = null; 1.71 + gDebuggee = null; 1.72 + gPanel = null; 1.73 + gDebugger = null; 1.74 + gSearchBox = null; 1.75 +});