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 608376 950154355f21646f4db823339a91cd6b095fc0b3
parent 608374 e654f451fd7b8957c1b467c12b1554aeb8acc7fc
child 637281 1206059c18b27c78cbe903a862b919e5d4db4417
push id68251
push userjodvarko@mozilla.com
push dateThu, 13 Jul 2017 14:27:57 +0000
reviewersbgrins
bugs1326937
milestone56.0a1
Bug 1326937 - Avoid an exception due to a missing sidebar; r=bgrins MozReview-Commit-ID: EuyrE4ZBYen
devtools/client/webconsole/jsterm.js
--- a/devtools/client/webconsole/jsterm.js
+++ b/devtools/client/webconsole/jsterm.js
@@ -581,16 +581,21 @@ JSTerm.prototype = {
    *        option is not used, then the variables view opens in the sidebar.
    *        - 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) {
+    // Bail out if the side bar doesn't exist.
+    if (!this.hud.document.querySelector("#webconsole-sidebar")) {
+      return Promise.resolve(null);
+    }
+
     let onContainerReady = (window) => {
       let container = window.document.querySelector("#variables");
       let view = this._variablesView;
       if (!view || options.targetElement) {
         let viewOptions = {
           container: container,
           hideFilterInput: options.hideFilterInput,
         };