Bug 1535305 - Guard this.jsterm access in webconsole-ui.js. r=Honza.
authorNicolas Chevobbe <nchevobbe@mozilla.com>
Fri, 15 Mar 2019 11:43:41 +0000
changeset 522031 ad59be7ee0c20a42f70989bcce84308fdd66619a
parent 522030 36132f5347e8b31f4fe5b28d0bd182f6fe606237
child 522032 6343f4a4d75eca45559003206bce65c8c3c14f3e
push id10871
push usercbrindusan@mozilla.com
push dateMon, 18 Mar 2019 15:49:32 +0000
treeherdermozilla-beta@018abdd16060 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1535305
milestone67.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 1535305 - Guard this.jsterm access in webconsole-ui.js. r=Honza. Depending on the load, this.jsterm might not be set when switching to the console panel, and can cause a crash (blank tab). This patch checks that this.jsterm exists before taking further actions. Differential Revision: https://phabricator.services.mozilla.com/D23511
devtools/client/webconsole/webconsole-ui.js
--- a/devtools/client/webconsole/webconsole-ui.js
+++ b/devtools/client/webconsole/webconsole-ui.js
@@ -283,18 +283,18 @@ class WebConsoleUI {
 
       shortcuts.on(l10n.getStr("webconsole.close.key"),
                    this.window.top.close.bind(this.window.top));
 
       ZoomKeys.register(this.window);
       shortcuts.on("CmdOrCtrl+Alt+R", quickRestart);
     } else if (Services.prefs.getBoolPref(PREF_SIDEBAR_ENABLED)) {
       shortcuts.on("Esc", event => {
-        if (!this.jsterm.autocompletePopup || !this.jsterm.autocompletePopup.isOpen) {
-          this.wrapper.dispatchSidebarClose();
+        this.wrapper.dispatchSidebarClose();
+        if (this.jsterm) {
           this.jsterm.focus();
         }
       });
     }
   }
 
   /**
    * Handler for page location changes.
@@ -333,17 +333,21 @@ class WebConsoleUI {
   }
 
   /**
    * Sets the focus to JavaScript input field when the web console tab is
    * selected or when there is a split console present.
    * @private
    */
   _onPanelSelected() {
-    this.jsterm.focus();
+    // We can only focus when we have the jsterm reference. This is fine because if the
+    // jsterm is not mounted yet, it will be focused in JSTerm's componentDidMount.
+    if (this.jsterm) {
+      this.jsterm.focus();
+    }
   }
 
   _onChangeSplitConsoleState() {
     this.wrapper.dispatchSplitConsoleCloseButtonToggle();
   }
 
   /**
    * Handler for the tabNavigated notification.