Bug 1302702 - Fix inspector panel deadwrapper exceptions on addon reloads. draft
authorLuca Greco <lgreco@mozilla.com>
Mon, 24 Apr 2017 13:49:10 +0200
changeset 579753 09fac56bbaf090954a730ebdcaf80f0c6cafafaf
parent 579752 f593fc6df43e62384fc44561e377aa99d444115b
child 579754 a83edbc482e3bce36f6ca447fad07ab0e5cee475
push id59363
push userluca.greco@alcacoop.it
push dateWed, 17 May 2017 19:17:20 +0000
bugs1302702
milestone55.0a1
Bug 1302702 - Fix inspector panel deadwrapper exceptions on addon reloads. MozReview-Commit-ID: DPaUiLeTyCC
devtools/server/actors/inspector.js
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -2441,16 +2441,18 @@ var WalkerActor = protocol.ActorClassWit
     }
     if (isTopLevel) {
       // If we initialize the inspector while the document is loading,
       // we may already have a root document set in the constructor.
       if (this.rootDoc && !Cu.isDeadWrapper(this.rootDoc) &&
           this.rootDoc.defaultView) {
         this.onFrameUnload({ window: this.rootDoc.defaultView });
       }
+      // Update all DOM objects references to target the new document.
+      this.rootWin = window;
       this.rootDoc = window.document;
       this.rootNode = this.document();
       this.queueMutation({
         type: "newRoot",
         target: this.rootNode.form()
       });
       return;
     }
@@ -2982,17 +2984,17 @@ function isNodeDead(node) {
  *        Either SKIP_TO_PARENT or SKIP_TO_SIBLING. If the provided node is not compatible
  *        with the filter function for this walker, try to find a compatible one either
  *        in the parents or in the siblings of the node.
  */
 function DocumentWalker(node, rootWin,
     whatToShow = nodeFilterConstants.SHOW_ALL,
     filter = standardTreeWalkerFilter,
     skipTo = SKIP_TO_PARENT) {
-  if (!rootWin.location) {
+  if (Cu.isDeadWrapper(rootWin) || !rootWin.location) {
     throw new Error("Got an invalid root window in DocumentWalker");
   }
 
   this.walker = Cc["@mozilla.org/inspector/deep-tree-walker;1"]
     .createInstance(Ci.inIDeepTreeWalker);
   this.walker.showAnonymousContent = true;
   this.walker.showSubDocuments = true;
   this.walker.showDocumentsAsNodes = true;