Bug 935788 - Fix Pretty Print button when attempting to prettify non-js files; r=vporof, a=bajaj
authorNick Fitzgerald <fitzgen@gmail.com>
Mon, 18 Nov 2013 13:27:15 -0800
changeset 166518 c0c46ae54ed7bf3b2768e7ed3d5b7a9b5b810937
parent 166517 97f50dda2d9a7e99b50cdb8e40568bb01ebc33e5
child 166519 bc542226210744ae19a81c47589b9b57d80e7c96
push id3066
push userakeybl@mozilla.com
push dateMon, 09 Dec 2013 19:58:46 +0000
treeherdermozilla-beta@a31a0dce83aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersvporof, bajaj
bugs935788
milestone27.0a2
Bug 935788 - Fix Pretty Print button when attempting to prettify non-js files; r=vporof, a=bajaj
browser/devtools/debugger/debugger-panes.js
browser/devtools/debugger/test/browser.ini
browser/devtools/debugger/test/browser_dbg_pretty-print-12.js
--- a/browser/devtools/debugger/debugger-panes.js
+++ b/browser/devtools/debugger/debugger-panes.js
@@ -399,17 +399,18 @@ SourcesView.prototype = Heritage.extend(
     if (gThreadClient.source(source).isPrettyPrinted) {
       this._prettyPrintButton.removeAttribute("checked");
     } else {
       this._prettyPrintButton.setAttribute("checked", true);
     }
 
     DebuggerController.SourceScripts.togglePrettyPrint(source)
       .then(resetEditor, printError)
-      .then(DebuggerView.showEditor);
+      .then(DebuggerView.showEditor)
+      .then(this.updateToolbarButtonsState);
   },
 
   /**
    * Marks a breakpoint as selected in this sources container.
    *
    * @param object aItem
    *        The breakpoint item to select.
    */
--- a/browser/devtools/debugger/test/browser.ini
+++ b/browser/devtools/debugger/test/browser.ini
@@ -123,16 +123,17 @@ skip-if = true
 [browser_dbg_pretty-print-04.js]
 [browser_dbg_pretty-print-05.js]
 [browser_dbg_pretty-print-06.js]
 [browser_dbg_pretty-print-07.js]
 [browser_dbg_pretty-print-08.js]
 [browser_dbg_pretty-print-09.js]
 [browser_dbg_pretty-print-10.js]
 [browser_dbg_pretty-print-11.js]
+[browser_dbg_pretty-print-12.js]
 [browser_dbg_progress-listener-bug.js]
 [browser_dbg_reload-preferred-script-01.js]
 [browser_dbg_reload-preferred-script-02.js]
 [browser_dbg_reload-preferred-script-03.js]
 [browser_dbg_reload-same-script.js]
 [browser_dbg_scripts-switching-01.js]
 [browser_dbg_scripts-switching-02.js]
 [browser_dbg_scripts-switching-03.js]
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_pretty-print-12.js
@@ -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;
+});