diff --git a/browser/devtools/framework/sidebar.js b/browser/devtools/framework/sidebar.js index 9e2ac74b04d..b7b6612334d 100644 --- a/browser/devtools/framework/sidebar.js +++ b/browser/devtools/framework/sidebar.js @@ -327,17 +327,35 @@ ToolSidebar.prototype = { }), /** - * Show or hide a specific tab + * Show or hide a specific tab and tabpanel. + * @param {Boolean} isVisible True to show the tab/tabpanel, False to hide it. + * @param {String} id The ID of the tab to be hidden. + * @param {String} tabPanelId Optionally pass the ID for the tabPanel if it + * can't be retrieved using the tab ID. This is useful when tabs and tabpanels + * existed before the widget was created. */ - toggleTab: function(id, isVisible) { + toggleTab: function(isVisible, id, tabPanelId) { + // Toggle the tab. let tab = this.getTab(id); if (!tab) { return; } tab.hidden = !isVisible; + + // Toggle the item in the allTabs menu. if (this._allTabsBtn) { this._allTabsBtn.querySelector("#sidebar-alltabs-item-" + id).hidden = !isVisible; } + + // Toggle the corresponding tabPanel, if one can be found either with the id + // or the provided tabPanelId. + let tabPanel = this.getTabPanel(id); + if (!tabPanel && tabPanelId) { + tabPanel = this.getTabPanel(tabPanelId); + } + if (tabPanel) { + tabPanel.hidden = !isVisible; + } }, /** diff --git a/browser/devtools/inspector/inspector-panel.js b/browser/devtools/inspector/inspector-panel.js index 23a0b343c3d..04aa83af526 100644 --- a/browser/devtools/inspector/inspector-panel.js +++ b/browser/devtools/inspector/inspector-panel.js @@ -313,7 +313,9 @@ InspectorPanel.prototype = { */ setupSidebar: function InspectorPanel_setupSidebar() { let tabbox = this.panelDoc.querySelector("#inspector-sidebar"); - this.sidebar = new ToolSidebar(tabbox, this, "inspector"); + this.sidebar = new ToolSidebar(tabbox, this, "inspector", { + showAllTabsMenu: true + }); let defaultTab = Services.prefs.getCharPref("devtools.inspector.activeSidebar"); diff --git a/browser/devtools/netmonitor/netmonitor-controller.js b/browser/devtools/netmonitor/netmonitor-controller.js index f8859072d5a..46f016bf67a 100644 --- a/browser/devtools/netmonitor/netmonitor-controller.js +++ b/browser/devtools/netmonitor/netmonitor-controller.js @@ -119,6 +119,7 @@ const promise = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise; const EventEmitter = require("devtools/toolkit/event-emitter"); const Editor = require("devtools/sourceeditor/editor"); const {Tooltip} = require("devtools/shared/widgets/Tooltip"); +const {ToolSidebar} = require("devtools/framework/sidebar"); XPCOMUtils.defineLazyModuleGetter(this, "Chart", "resource:///modules/devtools/Chart.jsm"); diff --git a/browser/devtools/netmonitor/netmonitor-view.js b/browser/devtools/netmonitor/netmonitor-view.js index ee032acf3bd..118d7b0cfc7 100644 --- a/browser/devtools/netmonitor/netmonitor-view.js +++ b/browser/devtools/netmonitor/netmonitor-view.js @@ -2001,6 +2001,9 @@ CustomRequestView.prototype = { function NetworkDetailsView() { dumpn("NetworkDetailsView was instantiated"); + // The ToolSidebar requires the panel object to be able to emit events. + EventEmitter.decorate(this); + this._onTabSelect = this._onTabSelect.bind(this); }; @@ -2025,6 +2028,10 @@ NetworkDetailsView.prototype = { dumpn("Initializing the NetworkDetailsView"); this.widget = $("#event-details-pane"); + this.sidebar = new ToolSidebar(this.widget, this, "netmonitor", { + disableTelemetry: true, + showAllTabsMenu: true + }); this._headers = new VariablesView($("#all-headers"), Heritage.extend(GENERIC_VARIABLES_VIEW_SETTINGS, { @@ -2065,7 +2072,7 @@ NetworkDetailsView.prototype = { */ destroy: function() { dumpn("Destroying the NetworkDetailsView"); - + this.sidebar.destroy(); $("tabpanels", this.widget).removeEventListener("select", this._onTabSelect); }, @@ -2090,8 +2097,7 @@ NetworkDetailsView.prototype = { let isHtml = RequestsMenuView.prototype.isHtml({ attachment: aData }); // Show the "Preview" tabpanel only for plain HTML responses. - $("#preview-tab").hidden = !isHtml; - $("#preview-tabpanel").hidden = !isHtml; + this.sidebar.toggleTab(isHtml, "preview-tab", "preview-tabpanel"); // Show the "Security" tab only for requests that // 1) are https (state != insecure)