frontend/devtools/ui/InspectorView.js
function(panelName)
    {
        if (this._currentPanelLocked) {
            if (this._currentPanel !== this._panels[panelName])
                return Promise.reject(new Error("Current panel locked"));
            return Promise.resolve(this._currentPanel);
        }

        this._panelForShowPromise = this.panel(panelName);
        return this._panelForShowPromise.then(setCurrentPanelIfNecessary.bind(this, this._panelForShowPromise));

        /**
         * @param {!Promise.<!WebInspector.Panel>} panelPromise
         * @param {!WebInspector.Panel} panel
         * @return {?WebInspector.Panel}
         * @this {WebInspector.InspectorView}
         */
        function setCurrentPanelIfNecessary(panelPromise, panel)
        {
            if (this._panelForShowPromise !== panelPromise)
                return null;

            this.setCurrentPanel(panel);
            return panel;
        }
    }
function(panelName)
    {
        if (this._currentPanelLocked) {
            if (this._currentPanel !== this._panels[panelName])
                return Promise.reject(new Error("Current panel locked"));
            return Promise.resolve(this._currentPanel);
        }

        this._panelForShowPromise = this.panel(panelName);
        return this._panelForShowPromise.then(setCurrentPanelIfNecessary.bind(this, this._panelForShowPromise));

        /**
         * @param {!Promise.<!WebInspector.Panel>} panelPromise
         * @param {!WebInspector.Panel} panel
         * @return {?WebInspector.Panel}
         * @this {WebInspector.InspectorView}
         */
        function setCurrentPanelIfNecessary(panelPromise, panel)
        {
            if (this._panelForShowPromise !== panelPromise)
                return null;

            this.setCurrentPanel(panel);
            return panel;
        }
    }
The returned Promise is resolved with null if another showPanel()
gets called while this.panel(panelName) Promise is in flight.

@param {string} panelName
@return {!Promise.<?WebInspector.Panel>}