Title: [202666] trunk
Revision
202666
Author
joep...@webkit.org
Date
2016-06-29 21:19:42 -0700 (Wed, 29 Jun 2016)

Log Message

Web Inspector: API View of Native DOM APIs looks poor (TypeErrors for native getters)
https://bugs.webkit.org/show_bug.cgi?id=158334
<rdar://problem/26615366>

Reviewed by Timothy Hatcher.

Source/_javascript_Core:

* inspector/InjectedScriptSource.js:
(InjectedScript.prototype._getProperties):
(InjectedScript.prototype._propertyDescriptors):
Do not create fake value property descriptors for native accessors
unless requested. This means, getProperties for a native prototype
should return  accessors for native accessors just like it does
for normal non-native accessors (getters/setters).

(InjectedScript.prototype.getProperties):
Do not produce fake value accessors for native accessors.

(InjectedScript.prototype.getDisplayableProperties):
(InjectedScript.RemoteObject.prototype._generatePreview):
Do produce fake value accessors for native accessors.

LayoutTests:

* inspector/runtime/getProperties-expected.txt:
* inspector/runtime/getProperties.html:
Improve output for accessors now that getProperties
returns real accessor descriptors for native accessors
instead of fake value descriptors.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (202665 => 202666)


--- trunk/LayoutTests/ChangeLog	2016-06-30 04:17:33 UTC (rev 202665)
+++ trunk/LayoutTests/ChangeLog	2016-06-30 04:19:42 UTC (rev 202666)
@@ -1,5 +1,19 @@
 2016-06-29  Joseph Pecoraro  <pecor...@apple.com>
 
+        Web Inspector: API View of Native DOM APIs looks poor (TypeErrors for native getters)
+        https://bugs.webkit.org/show_bug.cgi?id=158334
+        <rdar://problem/26615366>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/runtime/getProperties-expected.txt:
+        * inspector/runtime/getProperties.html:
+        Improve output for accessors now that getProperties
+        returns real accessor descriptors for native accessors
+        instead of fake value descriptors.
+
+2016-06-29  Joseph Pecoraro  <pecor...@apple.com>
+
         Web Inspector: Wrong function name next to scope
         https://bugs.webkit.org/show_bug.cgi?id=158210
         <rdar://problem/26543093>

Modified: trunk/LayoutTests/inspector/runtime/getProperties-expected.txt (202665 => 202666)


--- trunk/LayoutTests/inspector/runtime/getProperties-expected.txt	2016-06-30 04:17:33 UTC (rev 202665)
+++ trunk/LayoutTests/inspector/runtime/getProperties-expected.txt	2016-06-30 04:19:42 UTC (rev 202666)
@@ -20,8 +20,8 @@
   __proto__ function function () {
     [native code]
 }
-  arguments object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
-  caller object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
+  arguments getter setter
+  caller getter setter
   length number 0
   name string bound Number
 Internal properties:
@@ -37,8 +37,8 @@
   __proto__ function function () {
     [native code]
 }
-  arguments object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
-  caller object TypeError: 'arguments', 'callee', and 'caller' cannot be accessed in strict mode.
+  arguments getter setter
+  caller getter setter
   length number 0
   name string bound 
 Internal properties:

Modified: trunk/LayoutTests/inspector/runtime/getProperties.html (202665 => 202666)


--- trunk/LayoutTests/inspector/runtime/getProperties.html	2016-06-30 04:17:33 UTC (rev 202665)
+++ trunk/LayoutTests/inspector/runtime/getProperties.html	2016-06-30 04:19:42 UTC (rev 202666)
@@ -80,11 +80,13 @@
         }
 
         function dumpSingleProperty(property) {
-            var {name, value} = property;
+            var {name, value, get, set} = property;
             if (value)
-                ProtocolTest.log("  " + name + " " + value.type + " " + (value.value || value.description));
+                ProtocolTest.log(`  ${name} ${value.type} ${value.value || value.description}`);
+            else if (get || set)
+                ProtocolTest.log(`  ${name} ${get ? "getter" : "-"} ${set ? "setter" : ""}`);
             else
-                ProtocolTest.log("  " + name);
+                ProtocolTest.log(`  ${name}`);
         }
 
         function NamedThingComparator(o1, o2) {

Modified: trunk/Source/_javascript_Core/ChangeLog (202665 => 202666)


--- trunk/Source/_javascript_Core/ChangeLog	2016-06-30 04:17:33 UTC (rev 202665)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-06-30 04:19:42 UTC (rev 202666)
@@ -1,3 +1,26 @@
+2016-06-29  Joseph Pecoraro  <pecor...@apple.com>
+
+        Web Inspector: API View of Native DOM APIs looks poor (TypeErrors for native getters)
+        https://bugs.webkit.org/show_bug.cgi?id=158334
+        <rdar://problem/26615366>
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/InjectedScriptSource.js:
+        (InjectedScript.prototype._getProperties):
+        (InjectedScript.prototype._propertyDescriptors):
+        Do not create fake value property descriptors for native accessors
+        unless requested. This means, getProperties for a native prototype
+        should return  accessors for native accessors just like it does
+        for normal non-native accessors (getters/setters).
+
+        (InjectedScript.prototype.getProperties):
+        Do not produce fake value accessors for native accessors.
+
+        (InjectedScript.prototype.getDisplayableProperties):
+        (InjectedScript.RemoteObject.prototype._generatePreview):
+        Do produce fake value accessors for native accessors.
+
 2016-06-29  Saam barati  <sbar...@apple.com>
 
         JSGlobalLexicalEnvironment needs a toThis implementation

Modified: trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js (202665 => 202666)


--- trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-06-30 04:17:33 UTC (rev 202665)
+++ trunk/Source/_javascript_Core/inspector/InjectedScriptSource.js	2016-06-30 04:19:42 UTC (rev 202666)
@@ -251,7 +251,7 @@
         return result;
     },
 
-    _getProperties: function(objectId, collectionMode, generatePreview)
+    _getProperties: function(objectId, collectionMode, generatePreview, nativeGettersAsValues)
     {
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
@@ -263,7 +263,7 @@
         if (isSymbol(object))
             return false;
 
-        var descriptors = this._propertyDescriptors(object, collectionMode);
+        var descriptors = this._propertyDescriptors(object, collectionMode, nativeGettersAsValues);
 
         // Go over properties, wrap object values.
         for (var i = 0; i < descriptors.length; ++i) {
@@ -287,14 +287,16 @@
 
     getProperties: function(objectId, ownProperties, generatePreview)
     {
+        var nativeGettersAsValues = false;
         var collectionMode = ownProperties ? InjectedScript.CollectionMode.OwnProperties : InjectedScript.CollectionMode.AllProperties;
-        return this._getProperties(objectId, collectionMode, generatePreview);
+        return this._getProperties(objectId, collectionMode, generatePreview, nativeGettersAsValues);
     },
 
     getDisplayableProperties: function(objectId, generatePreview)
     {
+        var nativeGettersAsValues = true;
         var collectionMode = InjectedScript.CollectionMode.OwnProperties | InjectedScript.CollectionMode.NativeGetterProperties;
-        return this._getProperties(objectId, collectionMode, generatePreview);
+        return this._getProperties(objectId, collectionMode, generatePreview, nativeGettersAsValues);
     },
 
     getInternalProperties: function(objectId, generatePreview)
@@ -570,7 +572,7 @@
         return descriptors;
     },
 
-    _propertyDescriptors: function(object, collectionMode)
+    _propertyDescriptors: function(object, collectionMode, nativeGettersAsValues)
     {
         var descriptors = [];
         var nameProcessed = new Set;
@@ -612,11 +614,7 @@
 
             // Native Getter properties.
             if (collectionMode & InjectedScript.CollectionMode.NativeGetterProperties) {
-                // FIXME: <https://webkit.org/b/140575> Web Inspector: Native Bindings Descriptors are Incomplete
-                // if (descriptor.hasOwnProperty("get") && descriptor.get && isNativeFunction(descriptor.get)) { ... }
-
                 if (possibleNativeBindingGetter) {
-                    // Possible getter property in the prototype chain.
                     descriptors.push(descriptor);
                     return;
                 }
@@ -644,15 +642,14 @@
                     continue;
                 }
 
-                if (endsWith(String(descriptor.get), "[native code]\n}") ||
-                     (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
-                    // FIXME: Some Native Bindings Descriptors are Incomplete
-                    // <https://webkit.org/b/141585> Some IDL attributes appear on the instances instead of on prototypes
-                    // Developers may create such a descriptors, so we should be resilient:
-                    // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p")
-                    var fakeDescriptor = createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, true);
-                    processDescriptor(fakeDescriptor, isOwnProperty, true);
-                    continue;
+                if (nativeGettersAsValues) {
+                    if (endsWith(String(descriptor.get), "[native code]\n}") || (!descriptor.get && descriptor.hasOwnProperty("get") && !descriptor.set && descriptor.hasOwnProperty("set"))) {
+                        // Developers may create such a descriptor, so we should be resilient:
+                        // var x = {}; Object.defineProperty(x, "p", {get:undefined}); Object.getOwnPropertyDescriptor(x, "p")
+                        var fakeDescriptor = createFakeValueDescriptor(name, symbol, descriptor, isOwnProperty, true);
+                        processDescriptor(fakeDescriptor, isOwnProperty, true);
+                        continue;
+                    }
                 }
 
                 descriptor.name = name;
@@ -1043,7 +1040,8 @@
                 return preview;
 
             // Properties.
-            var descriptors = injectedScript._propertyDescriptors(object, InjectedScript.CollectionMode.AllProperties);
+            var nativeGettersAsValues = true;
+            var descriptors = injectedScript._propertyDescriptors(object, InjectedScript.CollectionMode.AllProperties, nativeGettersAsValues);
             this._appendPropertyPreviews(object, preview, descriptors, false, propertiesThreshold, firstLevelKeys, secondLevelKeys);
             if (propertiesThreshold.indexes < 0 || propertiesThreshold.properties < 0)
                 return preview;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to