1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-05.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 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 + * Make sure that prettifying HTML sources doesn't do anything. 1.9 + */ 1.10 + 1.11 +const TAB_URL = EXAMPLE_URL + "doc_included-script.html"; 1.12 + 1.13 +let gTab, gDebuggee, gPanel, gDebugger; 1.14 +let gEditor, gSources, gControllerSources; 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 + gEditor = gDebugger.DebuggerView.editor; 1.23 + gSources = gDebugger.DebuggerView.Sources; 1.24 + gControllerSources = gDebugger.DebuggerController.SourceScripts; 1.25 + 1.26 + Task.spawn(function() { 1.27 + yield waitForSourceShown(gPanel, TAB_URL); 1.28 + 1.29 + // From this point onward, the source editor's text should never change. 1.30 + gEditor.once("change", () => { 1.31 + ok(false, "The source editor text shouldn't have changed."); 1.32 + }); 1.33 + 1.34 + is(gSources.selectedValue, TAB_URL, 1.35 + "The correct source is currently selected."); 1.36 + ok(gEditor.getText().contains("myFunction"), 1.37 + "The source shouldn't be pretty printed yet."); 1.38 + 1.39 + clickPrettyPrintButton(); 1.40 + 1.41 + let { source } = gSources.selectedItem.attachment; 1.42 + try { 1.43 + yield gControllerSources.togglePrettyPrint(source); 1.44 + ok(false, "The promise for a prettified source should be rejected!"); 1.45 + } catch ([source, error]) { 1.46 + is(error, "Can't prettify non-javascript files.", 1.47 + "The promise was correctly rejected with a meaningful message."); 1.48 + } 1.49 + 1.50 + let [source, text] = yield gControllerSources.getText(source); 1.51 + is(gSources.selectedValue, TAB_URL, 1.52 + "The correct source is still selected."); 1.53 + ok(gEditor.getText().contains("myFunction"), 1.54 + "The displayed source hasn't changed."); 1.55 + ok(text.contains("myFunction"), 1.56 + "The cached source text wasn't altered in any way."); 1.57 + 1.58 + yield closeDebuggerAndFinish(gPanel); 1.59 + }); 1.60 + }); 1.61 +} 1.62 + 1.63 +function clickPrettyPrintButton() { 1.64 + gDebugger.document.getElementById("pretty-print").click(); 1.65 +} 1.66 + 1.67 +function prepareDebugger(aPanel) { 1.68 + aPanel._view.Sources.preferredSource = TAB_URL; 1.69 +} 1.70 + 1.71 +registerCleanupFunction(function() { 1.72 + gTab = null; 1.73 + gDebuggee = null; 1.74 + gPanel = null; 1.75 + gDebugger = null; 1.76 + gEditor = null; 1.77 + gSources = null; 1.78 + gControllerSources = null; 1.79 +});