Bug 1326937 - Avoid an exception due to a missing sidebar; r=bgrins draft
authorJan Odvarko <odvarko@gmail.com>
Fri, 30 Jun 2017 17:49:08 -0700
changeset 607556 270d2014f8b9e1649adb3f63fee2d9c5d8677498
parent 607555 d1c03ff86965d1676b5b288075971dedacd060a7
child 637060 59b507e6b34dccff3ecafde3b0244aa91c7f3adc
push id68018
push userjodvarko@mozilla.com
push dateWed, 12 Jul 2017 10:42:27 +0000
reviewersbgrins
bugs1326937
milestone56.0a1
Bug 1326937 - Avoid an exception due to a missing sidebar; r=bgrins MozReview-Commit-ID: I19qA3KO8NQ
devtools/client/webconsole/jsterm.js
--- a/devtools/client/webconsole/jsterm.js
+++ b/devtools/client/webconsole/jsterm.js
@@ -582,16 +582,20 @@ JSTerm.prototype = {
    *        - autofocus: optional boolean, |true| if you want to give focus to
    *        the variables view window after open, |false| otherwise.
    * @return object
    *         A promise object that is resolved when the variables view has
    *         opened. The new variables view instance is given to the callbacks.
    */
   openVariablesView: function (options) {
     let onContainerReady = (window) => {
+      if (!window) {
+        return null;
+      }
+
       let container = window.document.querySelector("#variables");
       let view = this._variablesView;
       if (!view || options.targetElement) {
         let viewOptions = {
           container: container,
           hideFilterInput: options.hideFilterInput,
         };
         view = this._createVariablesView(viewOptions);
@@ -640,31 +644,40 @@ JSTerm.prototype = {
   /**
    * Create the Web Console sidebar.
    *
    * @see devtools/framework/sidebar.js
    * @private
    */
   _createSidebar: function () {
     let tabbox = this.hud.document.querySelector("#webconsole-sidebar");
-    this.sidebar = new ToolSidebar(tabbox, this, "webconsole");
-    this.sidebar.show();
-    this.emit("sidebar-opened");
+
+    // The side bar doesn't exist in the new Console front-end.
+    if (tabbox) {
+      this.sidebar = new ToolSidebar(tabbox, this, "webconsole");
+      this.sidebar.show();
+      this.emit("sidebar-opened");
+    }
   },
 
   /**
    * Add the variables view tab to the sidebar.
    *
    * @private
    * @return object
    *         A promise object for the adding of the new tab.
    */
   _addVariablesViewSidebarTab: function () {
     let deferred = promise.defer();
 
+    if (!this.sidebar) {
+      deferred.resolve();
+      return deferred.promise;
+    }
+
     let onTabReady = () => {
       let window = this.sidebar.getWindowForTab("variablesview");
       deferred.resolve(window);
     };
 
     let tabPanel = this.sidebar.getTabPanel("variablesview");
     if (tabPanel) {
       if (this.sidebar.getCurrentTabID() == "variablesview") {