Bug 935788 - Fix Pretty Print button when attempting to prettify non-js files; r=vporof

This commit is contained in:
Nick Fitzgerald 2013-11-12 10:38:38 -08:00
parent ddf57b88c9
commit 42d24937fe
3 changed files with 57 additions and 1 deletions

View File

@ -404,7 +404,8 @@ SourcesView.prototype = Heritage.extend(WidgetMethods, {
DebuggerController.SourceScripts.togglePrettyPrint(source) DebuggerController.SourceScripts.togglePrettyPrint(source)
.then(resetEditor, printError) .then(resetEditor, printError)
.then(DebuggerView.showEditor); .then(DebuggerView.showEditor)
.then(this.updateToolbarButtonsState);
}, },
/** /**

View File

@ -128,6 +128,7 @@ skip-if = true
[browser_dbg_pretty-print-09.js] [browser_dbg_pretty-print-09.js]
[browser_dbg_pretty-print-10.js] [browser_dbg_pretty-print-10.js]
[browser_dbg_pretty-print-11.js] [browser_dbg_pretty-print-11.js]
[browser_dbg_pretty-print-12.js]
[browser_dbg_progress-listener-bug.js] [browser_dbg_progress-listener-bug.js]
[browser_dbg_reload-preferred-script-01.js] [browser_dbg_reload-preferred-script-01.js]
[browser_dbg_reload-preferred-script-02.js] [browser_dbg_reload-preferred-script-02.js]

View File

@ -0,0 +1,54 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Make sure that we don't leave the pretty print button checked when we fail to
* pretty print a source (because it isn't a JS file, for example).
*/
const TAB_URL = EXAMPLE_URL + "doc_blackboxing.html";
let gTab, gDebuggee, gPanel, gDebugger;
let gEditor, gSources;
function test() {
initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
gTab = aTab;
gDebuggee = aDebuggee;
gPanel = aPanel;
gDebugger = gPanel.panelWin;
gEditor = gDebugger.DebuggerView.editor;
gSources = gDebugger.DebuggerView.Sources;
waitForSourceShown(gPanel, "")
.then(() => {
let shown = ensureSourceIs(gPanel, TAB_URL, true)
gSources.selectedValue = TAB_URL;
return shown;
})
.then(clickPrettyPrintButton)
.then(testButtonIsntChecked)
.then(() => closeDebuggerAndFinish(gPanel))
.then(null, aError => {
ok(false, "Got an error: " + DevToolsUtils.safeErrorString(aError));
});
});
}
function clickPrettyPrintButton() {
gDebugger.document.getElementById("pretty-print").click();
}
function testButtonIsntChecked() {
is(gDebugger.document.getElementById("pretty-print").checked, false,
"The button shouldn't be checked after trying to pretty print a non-js file.");
}
registerCleanupFunction(function() {
gTab = null;
gDebuggee = null;
gPanel = null;
gDebugger = null;
gEditor = null;
gSources = null;
});