Bug 1249119 - Prevent exception when opening inspector on a loading document. r=pbro
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 19 Oct 2016 05:26:40 -0700
changeset 428692 9ebb57bb1d766831114afb897fc13840ce8f2896
parent 428691 46b32222e682b25578d090664a9c32f389e9dae4
child 428693 47efa3e76f692a661cc2edfe0ac8e3ebf38550ac
push id33405
push userbcampen@mozilla.com
push dateMon, 24 Oct 2016 15:32:53 +0000
reviewerspbro
bugs1249119
milestone52.0a1
Bug 1249119 - Prevent exception when opening inspector on a loading document. r=pbro MozReview-Commit-ID: 9TNRUblT0SW
devtools/client/inspector/markup/views/markup-container.js
devtools/server/actors/inspector.js
--- a/devtools/client/inspector/markup/views/markup-container.js
+++ b/devtools/client/inspector/markup/views/markup-container.js
@@ -628,18 +628,20 @@ MarkupContainer.prototype = {
 
   set selected(value) {
     this.tagState.classList.remove("flash-out");
     this._selected = value;
     this.editor.selected = value;
     // Markup tree item should have accessible selected state.
     this.tagLine.setAttribute("aria-selected", value);
     if (this._selected) {
-      this.markup.getContainer(this.markup._rootNode).elt.setAttribute(
-        "aria-activedescendant", this.id);
+      let container = this.markup.getContainer(this.markup._rootNode);
+      if (container) {
+        container.elt.setAttribute("aria-activedescendant", this.id);
+      }
       this.tagLine.setAttribute("selected", "");
       this.tagState.classList.add("theme-selected");
     } else {
       this.tagLine.removeAttribute("selected");
       this.tagState.classList.remove("theme-selected");
     }
   },
 
--- a/devtools/server/actors/inspector.js
+++ b/devtools/server/actors/inspector.js
@@ -613,16 +613,19 @@ var NodeActor = exports.NodeActor = prot
   setNodeValue: function (value) {
     this.rawNode.nodeValue = value;
   },
 
   /**
    * Get a unique selector string for this node.
    */
   getUniqueSelector: function () {
+    if (Cu.isDeadWrapper(this.rawNode)) {
+      return "";
+    }
     return CssLogic.findCssSelector(this.rawNode);
   },
 
   /**
    * Scroll the selected node into view.
    */
   scrollIntoView: function () {
     this.rawNode.scrollIntoView(true);