Bug 1460223 - Handle computedStyle.display failures for non-elements. r=gl, a=jcristau
authorPatrick Brosset <pbrosset@mozilla.com>
Tue, 15 May 2018 10:20:03 +0200
changeset 463638 e7ba266cc17b
parent 463637 13fdf7dee914
child 463639 b5ad20486d35
push id1724
push userjcristau@mozilla.com
push date2018-06-05 17:15 +0000
treeherdermozilla-release@a0b222c551f5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgl, jcristau
bugs1460223
milestone60.0.2
Bug 1460223 - Handle computedStyle.display failures for non-elements. r=gl, a=jcristau MozReview-Commit-ID: 9raK8Tkl4GI
devtools/server/actors/inspector/node.js
devtools/shared/fronts/node.js
--- a/devtools/server/actors/inspector/node.js
+++ b/devtools/server/actors/inspector/node.js
@@ -224,35 +224,39 @@ const NodeActor = protocol.ActorClassWit
       return null;
     }
 
     let style = this.computedStyle;
     if (!style) {
       return null;
     }
 
-    return style.display;
+    let display = null;
+    try {
+      display = style.display;
+    } catch (e) {
+      // Fails for <scrollbar> elements.
+    }
+    return display;
   },
 
   /**
-   * Is the node's display computed style value other than "none"
+   * Is the node currently displayed?
    */
   get isDisplayed() {
-    // Consider all non-element nodes as displayed.
-    if (InspectorActorUtils.isNodeDead(this) ||
-        this.rawNode.nodeType !== Ci.nsIDOMNode.ELEMENT_NODE) {
+    let type = this.displayType;
+
+    // Consider all non-elements or elements with no display-types to be displayed.
+    if (!type) {
       return true;
     }
 
-    let style = this.computedStyle;
-    if (!style) {
-      return true;
-    }
-
-    return style.display !== "none";
+    // Otherwise consider elements to be displayed only if their display-types is other
+    // than "none"".
+    return type !== "none";
   },
 
   /**
    * Are there event listeners that are listening on this node? This method
    * uses all parsers registered via event-parsers.js.registerEventParser() to
    * check if there are any event listeners.
    */
   get _hasEventListeners() {
--- a/devtools/shared/fronts/node.js
+++ b/devtools/shared/fronts/node.js
@@ -331,19 +331,17 @@ const NodeFront = FrontClassWithSpec(nod
     return this.pseudoClassLocks.some(locked => locked === pseudo);
   },
 
   get displayType() {
     return this._form.displayType;
   },
 
   get isDisplayed() {
-    // The NodeActor's form contains the isDisplayed information as a boolean
-    // starting from FF32. Before that, the property is missing
-    return "isDisplayed" in this._form ? this._form.isDisplayed : true;
+    return this._form.isDisplayed;
   },
 
   get isTreeDisplayed() {
     let parent = this;
     while (parent) {
       if (!parent.isDisplayed) {
         return false;
       }