Bug 1331774 - Apply ReactDOM patch to the inspector panel; r?gl draft
authorGreg Tatum <tatum.creative@gmail.com>
Tue, 17 Jan 2017 16:22:28 -0600
changeset 462695 e83eae9c3d59f3ecc00456088dc4780a2b98744f
parent 462512 6a23526fe5168087d7e4132c0705aefcaed5f571
child 542476 85c2618c87bb04a82d5d88bb3fdb3be98a9ee1da
push id41845
push userbmo:gtatum@mozilla.com
push dateTue, 17 Jan 2017 22:23:43 +0000
reviewersgl
bugs1331774
milestone53.0a1
Bug 1331774 - Apply ReactDOM patch to the inspector panel; r?gl MozReview-Commit-ID: K0VowmTSlZ7
devtools/client/shared/vendor/react-dom.js
--- a/devtools/client/shared/vendor/react-dom.js
+++ b/devtools/client/shared/vendor/react-dom.js
@@ -131,28 +131,32 @@
 
   /**
    * Try to access the containing toolbox XUL document, but only if all of the iframes
    * in the heirarchy are XUL documents. Events dispatch differently in the case of all
    * privileged XUL documents. Events that fire in an iframe propagate up to the parent
    * frame. This does not happen when HTML is in the mix. Only return the toolbox if
    * it matches the proper case of a XUL iframe inside of a XUL document.
    *
+   * In addition to the XUL case, if the panel uses the toolbox's ReactDOM instance,
+   * this patch needs to be applied as well. This is the case for the inspector.
+   *
    * @param {HTMLElement} node - The DOM node inside of an iframe.
    * @return {XULDocument|null} The toolbox.xul document, or null.
    */
   function getToolboxDocIfXulOnly(node) {
     // This execution context doesn't know about XULDocuments, so don't get the toolbox.
     if (typeof XULDocument !== "function") {
       return null;
     }
 
     let doc = node.ownerDocument;
+    const inspectorUrl = "chrome://devtools/content/inspector/inspector.xhtml";
 
-    while (doc instanceof XULDocument) {
+    while (doc instanceof XULDocument || doc.location.href === inspectorUrl) {
       const {frameElement} = doc.defaultView;
 
       if (!frameElement) {
         // We're at the root element, and no toolbox was found.
         return null;
       }
 
       doc = frameElement.parentElement.ownerDocument;