Title: [213991] trunk/Source/WebInspectorUI
Revision
213991
Author
joep...@webkit.org
Date
2017-03-15 11:15:21 -0700 (Wed, 15 Mar 2017)

Log Message

Web Inspector: REGRESSION: Elements Tab > Node Details Sidebar > Properties Section is spammed with TypeErrors
https://bugs.webkit.org/show_bug.cgi?id=153911
<rdar://problem/24520098>

Reviewed by Devin Rousso.

* UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
(WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties.nodeResolved.inspectedPage_node_collectPrototypes):
(WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties.nodeResolved):
Update due to naming conventions for code that evalutes in the inspected page.

(WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties.fillSection):
(WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties):
Create a more complete ObjectTreeView for the different sections.

* UserInterface/Views/ObjectTreePropertyTreeElement.js:
(WebInspector.ObjectTreePropertyTreeElement.prototype._updateChildren):
PureAPI behaves the same as ClassAPI and just shows own properties.

* UserInterface/Views/ObjectTreeView.js:
(WebInspector.ObjectTreeView.prototype.showOnlyProperties):
In only properties mode don't show the Prototype expander at the end.

(WebInspector.ObjectTreeView.prototype.setPrototypeNameOverride):
Allow a prototype name override at the top level. This will allow clients
to specify that the object at the top level is a Prototype object, so that
ObjectTreePropertyTreeElements can infer the right NativeFunctionParameter
information knowing that those properties are on a particular prototype.

(WebInspector.ObjectTreeView.prototype.update):
For the PureAPI use getOwnProperties instead of getDisplayableProperties.
This avoids the special handling we have for DOM native properties which
we bubble up to the top as value descriptors even though they are actually
accessor descriptors on prototypes.

(WebInspector.ObjectTreeView.prototype._updateProperties):
Pass the prototype name override onward for object properties.

Modified Paths

Diff

Modified: trunk/Source/WebInspectorUI/ChangeLog (213990 => 213991)


--- trunk/Source/WebInspectorUI/ChangeLog	2017-03-15 18:03:31 UTC (rev 213990)
+++ trunk/Source/WebInspectorUI/ChangeLog	2017-03-15 18:15:21 UTC (rev 213991)
@@ -1,3 +1,43 @@
+2017-03-15  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: REGRESSION: Elements Tab > Node Details Sidebar > Properties Section is spammed with TypeErrors
+        https://bugs.webkit.org/show_bug.cgi?id=153911
+        <rdar://problem/24520098>
+
+        Reviewed by Devin Rousso.
+
+        * UserInterface/Views/DOMNodeDetailsSidebarPanel.js:
+        (WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties.nodeResolved.inspectedPage_node_collectPrototypes):
+        (WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties.nodeResolved):
+        Update due to naming conventions for code that evalutes in the inspected page.
+
+        (WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties.fillSection):
+        (WebInspector.DOMNodeDetailsSidebarPanel.prototype._refreshProperties):
+        Create a more complete ObjectTreeView for the different sections.
+
+        * UserInterface/Views/ObjectTreePropertyTreeElement.js:
+        (WebInspector.ObjectTreePropertyTreeElement.prototype._updateChildren):
+        PureAPI behaves the same as ClassAPI and just shows own properties.
+
+        * UserInterface/Views/ObjectTreeView.js:
+        (WebInspector.ObjectTreeView.prototype.showOnlyProperties):
+        In only properties mode don't show the Prototype expander at the end.
+
+        (WebInspector.ObjectTreeView.prototype.setPrototypeNameOverride):
+        Allow a prototype name override at the top level. This will allow clients
+        to specify that the object at the top level is a Prototype object, so that
+        ObjectTreePropertyTreeElements can infer the right NativeFunctionParameter
+        information knowing that those properties are on a particular prototype.
+
+        (WebInspector.ObjectTreeView.prototype.update):
+        For the PureAPI use getOwnProperties instead of getDisplayableProperties.
+        This avoids the special handling we have for DOM native properties which
+        we bubble up to the top as value descriptors even though they are actually
+        accessor descriptors on prototypes.
+
+        (WebInspector.ObjectTreeView.prototype._updateProperties):
+        Pass the prototype name override onward for object properties.
+
 2017-03-14  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Exception when fetching computed styles can break future updates of section

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js (213990 => 213991)


--- trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js	2017-03-15 18:03:31 UTC (rev 213990)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/DOMNodeDetailsSidebarPanel.js	2017-03-15 18:15:21 UTC (rev 213991)
@@ -38,6 +38,8 @@
 
         this.element.classList.add("dom-node");
 
+        this._nodeRemoteObject = null;
+
         this._identityNodeTypeRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Type"));
         this._identityNodeNameRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Name"));
         this._identityNodeValueRow = new WebInspector.DetailsSectionSimpleRow(WebInspector.UIString("Value"));
@@ -156,10 +158,12 @@
 
     _refreshProperties()
     {
-        var domNode = this.domNode;
-        if (!domNode)
-            return;
+        if (this._nodeRemoteObject) {
+            this._nodeRemoteObject.release();
+            this._nodeRemoteObject = null;
+        }
 
+        let domNode = this.domNode;
         RuntimeAgent.releaseObjectGroup(WebInspector.DOMNodeDetailsSidebarPanel.PropertiesObjectGroupName);
         WebInspector.RemoteObject.resolveNode(domNode, WebInspector.DOMNodeDetailsSidebarPanel.PropertiesObjectGroupName, nodeResolved.bind(this));
 
@@ -172,7 +176,9 @@
             if (this.domNode !== domNode)
                 return;
 
-            function collectPrototypes()
+            this._nodeRemoteObject = object;
+
+            function inspectedPage_node_collectPrototypes()
             {
                 // This builds an object with numeric properties. This is easier than dealing with arrays
                 // with the way RemoteObject works. Start at 1 since we use parseInt later and parseInt
@@ -189,8 +195,9 @@
                 return result;
             }
 
-            object.callFunction(collectPrototypes, undefined, false, nodePrototypesReady.bind(this));
-            object.release();
+            const args = undefined;
+            const generatePreview = false;
+            object.callFunction(inspectedPage_node_collectPrototypes, args, generatePreview, nodePrototypesReady.bind(this));
         }
 
         function nodePrototypesReady(error, object, wasThrown)
@@ -214,31 +221,37 @@
             if (this.domNode !== domNode)
                 return;
 
-            var element = this._propertiesRow.element;
+            let element = this._propertiesRow.element;
             element.removeChildren();
 
-            // Get array of prototype user-friendly names.
-            for (var i = 0; i < prototypes.length; ++i) {
+            let propertyPath = new WebInspector.PropertyPath(this._nodeRemoteObject, "node");
+
+            let initialSection = true;
+            for (let i = 0; i < prototypes.length; ++i) {
                 // The only values we care about are numeric, as assigned in collectPrototypes.
                 if (!parseInt(prototypes[i].name, 10))
                     continue;
 
-                var prototype = prototypes[i].value;
-                var title = prototype.description;
-                if (title.match(/Prototype$/))
-                    title = title.replace(/Prototype$/, WebInspector.UIString(" (Prototype)"));
-                else if (title === "Object")
+                let prototype = prototypes[i].value;
+                let prototypeName = prototype.description;
+                let title = prototypeName;
+                if (/Prototype$/.test(title)) {
+                    prototypeName = prototypeName.replace(/Prototype$/, "");
+                    title = prototypeName + WebInspector.UIString(" (Prototype)");
+                } else if (title === "Object")
                     title = title + WebInspector.UIString(" (Prototype)");
 
-                // FIXME: <https://webkit.org/b/142833> Web Inspector: Node Details Sidebar Properties Section has "undefined" for all prototype properties
-
-                var objectTree = new WebInspector.ObjectTreeView(prototype, WebInspector.ObjectTreeView.Mode.Properties);
+                let mode = initialSection ? WebInspector.ObjectTreeView.Mode.Properties : WebInspector.ObjectTreeView.Mode.PureAPI;
+                let objectTree = new WebInspector.ObjectTreeView(prototype, mode, propertyPath);
                 objectTree.showOnlyProperties();
+                objectTree.setPrototypeNameOverride(prototypeName);
 
-                var detailsSection = new WebInspector.DetailsSection(prototype.description.hash + "-prototype-properties", title, null, null, true);
+                let detailsSection = new WebInspector.DetailsSection(prototype.description.hash + "-prototype-properties", title, null, null, true);
                 detailsSection.groups[0].rows = [new WebInspector.ObjectPropertiesDetailSectionRow(objectTree, detailsSection)];
 
                 element.appendChild(detailsSection.element);
+
+                initialSection = false;
             }
         }
     }

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js (213990 => 213991)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js	2017-03-15 18:03:31 UTC (rev 213990)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreePropertyTreeElement.js	2017-03-15 18:15:21 UTC (rev 213991)
@@ -306,7 +306,7 @@
         var resolvedValue = this.resolvedValue();
         if (resolvedValue.isCollectionType() && this._mode === WebInspector.ObjectTreeView.Mode.Properties)
             resolvedValue.getCollectionEntries(0, 100, this._updateChildrenInternal.bind(this, this._updateEntries, this._mode));
-        else if (this._mode === WebInspector.ObjectTreeView.Mode.ClassAPI)
+        else if (this._mode === WebInspector.ObjectTreeView.Mode.ClassAPI || this._mode === WebInspector.ObjectTreeView.Mode.PureAPI)
             resolvedValue.getOwnPropertyDescriptors(this._updateChildrenInternal.bind(this, this._updateProperties, WebInspector.ObjectTreeView.Mode.ClassAPI));
         else if (this.property.name === "__proto__")
             resolvedValue.getOwnPropertyDescriptors(this._updateChildrenInternal.bind(this, this._updateProperties, WebInspector.ObjectTreeView.Mode.PrototypeAPI));

Modified: trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js (213990 => 213991)


--- trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js	2017-03-15 18:03:31 UTC (rev 213990)
+++ trunk/Source/WebInspectorUI/UserInterface/Views/ObjectTreeView.js	2017-03-15 18:15:21 UTC (rev 213991)
@@ -39,6 +39,7 @@
         this._propertyPath = propertyPath || new WebInspector.PropertyPath(this._object, "this");
         this._expanded = false;
         this._hasLosslessPreview = false;
+        this._includeProtoProperty = true;
 
         // If ObjectTree is used outside of the console, we do not know when to release
         // WeakMap entries. Currently collapse would work. For the console, we can just
@@ -216,6 +217,8 @@
         this._inConsole = false;
 
         this._element.classList.add("properties-only");
+
+        this._includeProtoProperty = false;
     }
 
     appendTitleSuffix(suffixElement)
@@ -234,6 +237,11 @@
         this._extraProperties.push(propertyDescriptor);
     }
 
+    setPrototypeNameOverride(override)
+    {
+        this._prototypeNameOverride = override;
+    }
+
     // Protected
 
     update()
@@ -242,6 +250,8 @@
             this._object.getCollectionEntries(0, 100, this._updateChildren.bind(this, this._updateEntries));
         else if (this._object.isClass())
             this._object.classPrototype.getDisplayablePropertyDescriptors(this._updateChildren.bind(this, this._updateProperties));
+        else if (this._mode === WebInspector.ObjectTreeView.Mode.PureAPI)
+            this._object.getOwnPropertyDescriptors(this._updateChildren.bind(this, this._updateProperties));
         else
             this._object.getDisplayablePropertyDescriptors(this._updateChildren.bind(this, this._updateProperties));
     }
@@ -297,21 +307,23 @@
 
         var hadProto = false;
         for (var propertyDescriptor of properties) {
-            // COMPATIBILITY (iOS 8): Sometimes __proto__ is not a value, but a get/set property.
-            // In those cases it is actually not useful to show.
-            if (propertyDescriptor.name === "__proto__" && !propertyDescriptor.hasValue())
-                continue;
+            if (propertyDescriptor.name === "__proto__") {
+                // COMPATIBILITY (iOS 8): Sometimes __proto__ is not a value, but a get/set property.
+                // In those cases it is actually not useful to show.
+                if (!propertyDescriptor.hasValue())
+                    continue;
+                if (!this._includeProtoProperty)
+                    continue;
+                hadProto = true;
+            }
 
             if (isArray && isPropertyMode) {
                 if (propertyDescriptor.isIndexProperty())
                     this._outline.appendChild(new WebInspector.ObjectTreeArrayIndexTreeElement(propertyDescriptor, propertyPath));
                 else if (propertyDescriptor.name === "__proto__")
-                    this._outline.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, this._mode));
+                    this._outline.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, this._mode, this._prototypeNameOverride));
             } else
-                this._outline.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, this._mode));
-
-            if (propertyDescriptor.name === "__proto__")
-                hadProto = true;
+                this._outline.appendChild(new WebInspector.ObjectTreePropertyTreeElement(propertyDescriptor, propertyPath, this._mode, this._prototypeNameOverride));
         }
 
         if (!this._outline.children.length || (hadProto && this._outline.children.length === 1)) {
@@ -376,6 +388,7 @@
     Properties: Symbol("object-tree-properties"),      // Properties
     PrototypeAPI: Symbol("object-tree-prototype-api"), // API view on a live object instance, so getters can be invoked.
     ClassAPI: Symbol("object-tree-class-api"),         // API view without an object instance, can not invoke getters.
+    PureAPI: Symbol("object-tree-pure-api"),           // API view without special displayable property handling, just own properties. Getters can be invoked if the property path has a non-prototype object.
 };
 
 WebInspector.ObjectTreeView.Event = {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to