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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Nicolas Chevobbe 2019-03-15 11:43:41 +00:00
parent acdf328bb6
commit 24dc1bfecc

View File

@ -288,8 +288,8 @@ class WebConsoleUI {
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();
}
});
@ -338,7 +338,11 @@ class WebConsoleUI {
* @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() {