Bug 1392873 - Fix missing all-tabs-menu when detaching devtools to a separate window r?honza draft
authorRicky Chien <ricky060709@gmail.com>
Wed, 23 Aug 2017 14:18:21 +0800
changeset 652686 09968aad4545af0e5717c28ac58033bad37f6506
parent 652622 2306e153fba9ca55726ffcce889eaca7a479c29f
child 728142 8f9366bb79a87e4f6df1921eae780fa7eb10e86d
push id76114
push userbmo:rchien@mozilla.com
push dateFri, 25 Aug 2017 02:49:25 +0000
reviewershonza
bugs1392873
milestone57.0a1
Bug 1392873 - Fix missing all-tabs-menu when detaching devtools to a separate window r?honza
devtools/client/inspector/toolsidebar.js
devtools/client/netmonitor/src/components/tabbox-panel.js
devtools/client/shared/components/tabs/tabbar.js
--- a/devtools/client/inspector/toolsidebar.js
+++ b/devtools/client/inspector/toolsidebar.js
@@ -71,16 +71,17 @@ ToolSidebar.prototype = {
 
   // Rendering
 
   render: function () {
     let Tabbar = this.React.createFactory(this.browserRequire(
       "devtools/client/shared/components/tabs/tabbar"));
 
     let sidebar = Tabbar({
+      menuDocument: this._toolPanel._toolbox.doc,
       showAllTabsMenu: true,
       onSelect: this.handleSelectionChange.bind(this),
     });
 
     this._tabbar = this.ReactDOM.render(sidebar, this._tabbox);
   },
 
   /**
--- a/devtools/client/netmonitor/src/components/tabbox-panel.js
+++ b/devtools/client/netmonitor/src/components/tabbox-panel.js
@@ -45,16 +45,17 @@ function TabboxPanel({
 }) {
   if (!request) {
     return null;
   }
 
   return (
     Tabbar({
       activeTabId,
+      menuDocument: window.parent.document,
       onSelect: selectTab,
       renderOnlySelected: true,
       showAllTabsMenu: true,
     },
       TabPanel({
         id: "headers",
         title: HEADERS_TITLE,
       },
--- a/devtools/client/shared/components/tabs/tabbar.js
+++ b/devtools/client/shared/components/tabs/tabbar.js
@@ -20,24 +20,26 @@ const { div } = DOM;
 /**
  * Renders Tabbar component.
  */
 let Tabbar = createClass({
   displayName: "Tabbar",
 
   propTypes: {
     children: PropTypes.array,
+    menuDocument: PropTypes.object,
     onSelect: PropTypes.func,
     showAllTabsMenu: PropTypes.bool,
     activeTabId: PropTypes.string,
     renderOnlySelected: PropTypes.bool,
   },
 
   getDefaultProps: function () {
     return {
+      menuDocument: window.parent.document,
       showAllTabsMenu: false,
     };
   },
 
   getInitialState: function () {
     let { activeTabId, children = [] } = this.props;
     let tabs = this.createTabs(children);
     let activeTab = tabs.findIndex((tab, index) => tab.id === activeTabId);
@@ -192,17 +194,17 @@ let Tabbar = createClass({
     // XXX Missing menu API for specifying target (anchor)
     // and relative position to it. See also:
     // https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XUL/Method/openPopup
     // https://bugzilla.mozilla.org/show_bug.cgi?id=1274551
     let rect = target.getBoundingClientRect();
     let screenX = target.ownerDocument.defaultView.mozInnerScreenX;
     let screenY = target.ownerDocument.defaultView.mozInnerScreenY;
     menu.popup(rect.left + screenX, rect.bottom + screenY,
-      { doc: window.parent.document });
+      { doc: this.props.menuDocument });
 
     return menu;
   },
 
   // Rendering
 
   renderTab: function (tab) {
     if (typeof tab.panel === "function") {