Bug 1093349 - Add prettyPrinting and blackBoxing traits and hide buttons in debugger conditionally. r=past, a=me
authorJames Long <longster@gmail.com>
Wed, 05 Nov 2014 10:16:00 -0500
changeset 214474 85786620f4af73e074858da7cb03eeaae2e33f96
parent 214473 ebb8c73555a128ae7e3d4723254bfde7ef27dce4
child 214475 b82e0ba1f833d0880fe7f8ac50ae176530abd773
push id51494
push userkwierso@gmail.com
push dateFri, 07 Nov 2014 03:08:20 +0000
treeherdermozilla-inbound@c4b831696f15 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast, me
bugs1093349
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1093349 - Add prettyPrinting and blackBoxing traits and hide buttons in debugger conditionally. r=past, a=me
browser/devtools/debugger/debugger-controller.js
browser/devtools/debugger/debugger-panes.js
browser/devtools/debugger/test/browser.ini
browser/devtools/debugger/test/browser_dbg_hide-toolbar-buttons.js
toolkit/devtools/server/actors/root.js
--- a/browser/devtools/debugger/debugger-controller.js
+++ b/browser/devtools/debugger/debugger-controller.js
@@ -210,32 +210,44 @@ let DebuggerController = {
       yield this._startChromeDebugging(chromeDebugger);
     } else {
       yield this._startDebuggingTab();
 
       if (Prefs.tracerEnabled && traceActor) {
         yield this._startTracingTab(traceActor);
       }
     }
+
+    this._hideUnsupportedFeatures();
   }),
 
   /**
    * Disconnects the debugger client and removes event handlers as necessary.
    */
   disconnect: function() {
     // Return early if the client didn't even have a chance to instantiate.
     if (!this.client) {
       return;
     }
 
     this._connected = false;
     this.client = null;
     this.activeThread = null;
   },
 
+  _hideUnsupportedFeatures: function() {
+    if (this.client.mainRoot.traits.noPrettyPrinting) {
+      DebuggerView.Sources.hidePrettyPrinting();
+    }
+
+    if (this.client.mainRoot.traits.noBlackBoxing) {
+      DebuggerView.Sources.hideBlackBoxing();
+    }
+  },
+
   /**
    * Called for each location change in the debugged tab.
    *
    * @param string aType
    *        Packet type.
    * @param object aPacket
    *        Packet received from the server.
    */
--- a/browser/devtools/debugger/debugger-panes.js
+++ b/browser/devtools/debugger/debugger-panes.js
@@ -541,16 +541,34 @@ SourcesView.prototype = Heritage.extend(
       this._toggleBreakpointsButton.setAttribute("checked", true);
       this._onDisableAll();
     } else {
       this._toggleBreakpointsButton.removeAttribute("checked");
       this._onEnableAll();
     }
   },
 
+  hidePrettyPrinting: function() {
+    this._prettyPrintButton.style.display = 'none';
+
+    if (this._blackBoxButton.style.display === 'none') {
+      let sep = document.querySelector('#sources-toolbar .devtools-separator');
+      sep.style.display = 'none';
+    }
+  },
+
+  hideBlackBoxing: function() {
+    this._blackBoxButton.style.display = 'none';
+
+    if (this._prettyPrintButton.style.display === 'none') {
+      let sep = document.querySelector('#sources-toolbar .devtools-separator');
+      sep.style.display = 'none';
+    }
+  },
+
   /**
    * Marks a breakpoint as selected in this sources container.
    *
    * @param object aItem
    *        The breakpoint item to select.
    */
   _selectBreakpoint: function(aItem) {
     if (this._selectedBreakpointItem == aItem) {
--- a/browser/devtools/debugger/test/browser.ini
+++ b/browser/devtools/debugger/test/browser.ini
@@ -230,16 +230,18 @@ skip-if = e10s
 [browser_dbg_file-reload.js]
 skip-if = e10s
 [browser_dbg_function-display-name.js]
 skip-if = e10s
 [browser_dbg_global-method-override.js]
 skip-if = e10s
 [browser_dbg_globalactor.js]
 skip-if = e10s
+[browser_dbg_hide-toolbar-buttons.js]
+skip-if = e10s
 [browser_dbg_hit-counts-01.js]
 skip-if = e10s
 [browser_dbg_hit-counts-02.js]
 skip-if = e10s
 [browser_dbg_host-layout.js]
 skip-if = e10s
 [browser_dbg_iframes.js]
 skip-if = e10s
new file mode 100644
--- /dev/null
+++ b/browser/devtools/debugger/test/browser_dbg_hide-toolbar-buttons.js
@@ -0,0 +1,32 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+/**
+ * Bug 1093349: Test that the pretty-printing and blackboxing buttons
+ * are hidden if the server doesn't support them
+ */
+
+const TAB_URL = EXAMPLE_URL + "doc_auto-pretty-print-01.html";
+
+let devtools = Cu.import("resource://gre/modules/devtools/Loader.jsm", {}).devtools;
+let { RootActor } = devtools.require("devtools/server/actors/root");
+
+function test() {
+  let gTab, gDebuggee, gPanel, gDebugger;
+  let gEditor, gSources, gBreakpoints, gBreakpointsAdded, gBreakpointsRemoving;
+
+  RootActor.prototype.traits.noBlackBoxing = true;
+  RootActor.prototype.traits.noPrettyPrinting = true;
+
+  initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
+    let document = aPanel.panelWin.document;
+    let ppButton = document.querySelector('#pretty-print');
+    let bbButton = document.querySelector('#black-box');
+    let sep = document.querySelector('#sources-toolbar .devtools-separator');
+
+    is(ppButton.style.display, 'none', 'The pretty-print button is hidden');
+    is(bbButton.style.display, 'none', 'The blackboxing button is hidden');
+    is(sep.style.display, 'none', 'The separator is hidden');
+    closeDebuggerAndFinish(aPanel)
+  });
+}
--- a/toolkit/devtools/server/actors/root.js
+++ b/toolkit/devtools/server/actors/root.js
@@ -140,17 +140,21 @@ RootActor.prototype = {
     bulk: true,
     // Whether the style rule actor implements the modifySelector method
     // that modifies the rule's selector
     selectorEditable: true,
     // Whether the page style actor implements the addNewRule method that
     // adds new rules to the page
     addNewRule: true,
     // Whether the dom node actor implements the getUniqueSelector method
-    getUniqueSelector: true
+    getUniqueSelector: true,
+    // Whether the debugger server supports
+    // blackboxing/pretty-printing (not supported in Fever Dream yet)
+    noBlackBoxing: false,
+    noPrettyPrinting: false
   },
 
   /**
    * Return a 'hello' packet as specified by the Remote Debugging Protocol.
    */
   sayHello: function() {
     return {
       from: this.actorID,