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 567092 065c1f9254a86e8ea6b1a358525d33f95f69a324
parent 567091 363b69c1c9ab86f9515d39e242ba74c6d1d4a65e
child 567093 d5a5d59275873ef216159dfa819ccd2d6fb34883
push id55437
push userluca.greco@alcacoop.it
push dateMon, 24 Apr 2017 11:56:00 +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
@@ -2412,16 +2412,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 the rootWin and rootDoc.
+      this.rootWin = window;
       this.rootDoc = window.document;
       this.rootNode = this.document();
       this.queueMutation({
         type: "newRoot",
         target: this.rootNode.form()
       });
       return;
     }
@@ -2929,17 +2931,17 @@ function isNodeDead(node) {
  * @param {Int} whatToShow See nodeFilterConstants / inIDeepTreeWalker for
  * options.
  * @param {Function} filter A custom filter function Taking in a DOMNode
  *        and returning an Int. See WalkerActor.nodeFilter for an example.
  */
 function DocumentWalker(node, rootWin,
     whatToShow = nodeFilterConstants.SHOW_ALL,
     filter = standardTreeWalkerFilter) {
-  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;