Web Inspector: Expanding event objects in console shows undefined for most values...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jan 2015 00:34:57 +0000 (00:34 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 21 Jan 2015 00:34:57 +0000 (00:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137306

Patch by Joseph Pecoraro <pecoraro@apple.com> on 2015-01-20
Reviewed by Timothy Hatcher.

Source/JavaScriptCore:

Provide another optional parameter to getProperties, to gather a list
of all own and getter properties.

* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::getProperties):
* inspector/InjectedScript.h:
* inspector/InjectedScriptSource.js:
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getProperties):
* inspector/agents/InspectorRuntimeAgent.h:
* inspector/protocol/Runtime.json:

Source/WebInspectorUI:

When first expanding an object, show all the object's own properties and any
getter properties that may be on its prototype chain. Now, we only fetch
own properties, for __proto__ properties.

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject.prototype.getOwnProperties):
(WebInspector.RemoteObject.prototype.getOwnAndGetterProperties):
(WebInspector.RemoteObject.prototype.getAllProperties):
(WebInspector.RemoteObject.prototype.get hasChildren): Deleted.
* UserInterface/Views/ObjectPropertiesSection.js:
(WebInspector.ObjectPropertiesSection):
(WebInspector.ObjectPropertiesSection.prototype.update):
(WebInspector.ObjectPropertyTreeElement.prototype.onpopulate):

LayoutTests:

* inspector/model/remote-object-get-properties-expected.txt: Added.
* inspector/model/remote-object-get-properties.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@178768 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
LayoutTests/ChangeLog
LayoutTests/inspector/model/remote-object-get-properties-expected.txt [new file with mode: 0644]
LayoutTests/inspector/model/remote-object-get-properties.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/InjectedScript.cpp
Source/JavaScriptCore/inspector/InjectedScript.h
Source/JavaScriptCore/inspector/InjectedScriptSource.js
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.cpp
Source/JavaScriptCore/inspector/agents/InspectorRuntimeAgent.h
Source/JavaScriptCore/inspector/protocol/Runtime.json
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js
Source/WebInspectorUI/UserInterface/Views/ObjectPropertiesSection.js

index c7494a9..fa4b1bd 100644 (file)
@@ -1,5 +1,15 @@
 2015-01-20  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Expanding event objects in console shows undefined for most values, it should have real values
+        https://bugs.webkit.org/show_bug.cgi?id=137306
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/model/remote-object-get-properties-expected.txt: Added.
+        * inspector/model/remote-object-get-properties.html: Added.
+
+2015-01-20  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Should show dynamic specificity values
         https://bugs.webkit.org/show_bug.cgi?id=140647
 
diff --git a/LayoutTests/inspector/model/remote-object-get-properties-expected.txt b/LayoutTests/inspector/model/remote-object-get-properties-expected.txt
new file mode 100644 (file)
index 0000000..f93e9a3
--- /dev/null
@@ -0,0 +1,186 @@
+
+-----------------------------------------------------
+EXPRESSION: window.simpleObject
+objectId: {"injectedScriptId":1,"id":1}
+type: object
+description: Object
+
+OWN PROPERTIES:
+    a
+    b
+    __proto__
+
+OWN AND GETTER PROPERTIES:
+    a
+    b
+    __proto__
+
+ALL PROPERTIES:
+    a
+    b
+    toString
+    toLocaleString
+    valueOf
+    hasOwnProperty
+    propertyIsEnumerable
+    isPrototypeOf
+    __defineGetter__
+    __defineSetter__
+    __lookupGetter__
+    __lookupSetter__
+    constructor
+    __proto__
+-----------------------------------------------------
+
+-----------------------------------------------------
+EXPRESSION: window.loadEvent
+objectId: {"injectedScriptId":1,"id":16}
+type: object
+description: Event
+
+OWN PROPERTIES:
+    clipboardData
+    __proto__
+
+OWN AND GETTER PROPERTIES:
+    clipboardData
+    type
+    target
+    currentTarget
+    eventPhase
+    bubbles
+    cancelable
+    timeStamp
+    defaultPrevented
+    srcElement
+    returnValue
+    cancelBubble
+    __proto__
+
+ALL PROPERTIES:
+    clipboardData
+    constructor
+    type
+    target
+    currentTarget
+    eventPhase
+    bubbles
+    cancelable
+    timeStamp
+    defaultPrevented
+    srcElement
+    returnValue
+    cancelBubble
+    NONE
+    CAPTURING_PHASE
+    AT_TARGET
+    BUBBLING_PHASE
+    MOUSEDOWN
+    MOUSEUP
+    MOUSEOVER
+    MOUSEOUT
+    MOUSEMOVE
+    MOUSEDRAG
+    CLICK
+    DBLCLICK
+    KEYDOWN
+    KEYUP
+    KEYPRESS
+    DRAGDROP
+    FOCUS
+    BLUR
+    SELECT
+    CHANGE
+    stopPropagation
+    preventDefault
+    initEvent
+    stopImmediatePropagation
+    toString
+    toLocaleString
+    valueOf
+    hasOwnProperty
+    propertyIsEnumerable
+    isPrototypeOf
+    __defineGetter__
+    __defineSetter__
+    __lookupGetter__
+    __lookupSetter__
+    __proto__
+-----------------------------------------------------
+
+-----------------------------------------------------
+EXPRESSION: window.complexObject
+objectId: {"injectedScriptId":1,"id":41}
+type: object
+description: SuperFoo
+
+OWN PROPERTIES:
+    _bar
+    _foo
+    __proto__
+
+OWN AND GETTER PROPERTIES:
+    _bar
+    _foo
+    getterProperty
+    foo
+    bar
+    __proto__
+
+ALL PROPERTIES:
+    _bar
+    _foo
+    constructor
+    get getterProperty
+    set getterProperty
+    get foo
+    set foo
+    BAR_CONSTANT
+    get bar
+    set bar
+    get setterOnly
+    set setterOnly
+    toString
+    toLocaleString
+    valueOf
+    hasOwnProperty
+    propertyIsEnumerable
+    isPrototypeOf
+    __defineGetter__
+    __defineSetter__
+    __lookupGetter__
+    __lookupSetter__
+    __proto__
+-----------------------------------------------------
+
+-----------------------------------------------------
+EXPRESSION: window.badGetterObject
+objectId: {"injectedScriptId":1,"id":60}
+type: object
+description: ClassWithBadGetter
+
+OWN PROPERTIES:
+    __proto__
+
+OWN AND GETTER PROPERTIES:
+    badGetter
+    __proto__
+
+ALL PROPERTIES:
+    constructor
+    get badGetter
+    set badGetter
+    toString
+    toLocaleString
+    valueOf
+    hasOwnProperty
+    propertyIsEnumerable
+    isPrototypeOf
+    __defineGetter__
+    __defineSetter__
+    __lookupGetter__
+    __lookupSetter__
+    __proto__
+-----------------------------------------------------
+DONE
+
diff --git a/LayoutTests/inspector/model/remote-object-get-properties.html b/LayoutTests/inspector/model/remote-object-get-properties.html
new file mode 100644 (file)
index 0000000..b99b1bb
--- /dev/null
@@ -0,0 +1,114 @@
+<!doctype html>
+<html>
+<head>
+<script type="text/javascript" src="../../http/tests/inspector/inspector-test.js"></script>
+<script>
+// ------------------------------
+//   Setup Test Prototype Chain
+// ------------------------------
+
+function SuperBar() { this._bar = 10; }
+SuperBar.prototype = {
+    __proto__: Object.prototype,
+    constructor: SuperBar,
+    BAR_CONSTANT: 99,
+    get getterProperty() { return 20; },
+    get bar() { return this._bar; },
+    set setterOnly(x) {},
+};
+
+function SuperFoo() { SuperBar.call(this); this._foo = 5; }
+SuperFoo.prototype = {
+    __proto__: SuperBar.prototype,
+    constructor: SuperFoo,
+    get getterProperty() { return 10; },
+    get foo() { return this._foo; }
+};
+
+function ClassWithBadGetter() {}
+ClassWithBadGetter.prototype = {
+    __proto__: Object.prototype,
+    constructor: ClassWithBadGetter,
+    get badGetter() { throw "throw in getter"; }
+};
+
+
+// --------------------
+//   Objects to Debug
+// --------------------
+
+// window.loadEvent is set inside of <body onload="..."> below.
+var simpleObject = {a:1, b:"string"};
+var complexObject = new SuperFoo;
+var badGetterObject = new ClassWithBadGetter;
+
+
+// --------
+//   test
+// --------
+
+function test()
+{
+    var currentStepIndex = 0;
+    var steps = [
+        {expression: "window.simpleObject"},
+        {expression: "window.loadEvent"},
+        {expression: "window.complexObject"},
+        {expression: "window.badGetterObject"},
+    ]
+
+    function runNextStep() {
+        if (currentStepIndex >= steps.length) {
+            InspectorTest.log("DONE");
+            InspectorTest.completeTest();
+            return;
+        }
+
+        var step = steps[currentStepIndex++];
+        InspectorTest.log("");
+        InspectorTest.log("-----------------------------------------------------");
+        InspectorTest.log("EXPRESSION: " + step.expression);
+
+        WebInspector.runtimeManager.evaluateInInspectedWindow(step.expression, "test", false, true, false, function(remoteObject, wasThrown) {
+            InspectorTest.assert(remoteObject instanceof WebInspector.RemoteObject);
+            InspectorTest.log("objectId: " + remoteObject.objectId);
+            InspectorTest.log("type: " + remoteObject.type);
+            if (remoteObject.subtype)
+                InspectorTest.log("subtype: " + remoteObject.subtype);
+            InspectorTest.log("description: " + remoteObject.description);
+            remoteObject.getOwnProperties(function(properties) {
+                InspectorTest.log("\nOWN PROPERTIES:");
+                for (var property of properties) {
+                    InspectorTest.assert(property instanceof WebInspector.RemoteObjectProperty);
+                    InspectorTest.log("    " + property.name);
+                }
+            });
+
+            remoteObject.getOwnAndGetterProperties(function(properties) {
+                InspectorTest.log("\nOWN AND GETTER PROPERTIES:");
+                for (var property of properties) {
+                    InspectorTest.assert(property instanceof WebInspector.RemoteObjectProperty);
+                    InspectorTest.log("    " + property.name);
+                }
+            });
+
+            remoteObject.getAllProperties(function(properties) {
+                InspectorTest.log("\nALL PROPERTIES:");
+                for (var property of properties) {
+                    InspectorTest.assert(property instanceof WebInspector.RemoteObjectProperty);
+                    InspectorTest.log("    " + property.name);
+                }
+
+                InspectorTest.log("-----------------------------------------------------");
+                runNextStep();
+            });
+        });
+    }
+
+    runNextStep();
+}
+</script>
+</head>
+<body onload="window.loadEvent = event; runTest()">
+</body>
+</html>
index bc990e2..b9f2399 100644 (file)
@@ -1,5 +1,24 @@
 2015-01-20  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Expanding event objects in console shows undefined for most values, it should have real values
+        https://bugs.webkit.org/show_bug.cgi?id=137306
+
+        Reviewed by Timothy Hatcher.
+
+        Provide another optional parameter to getProperties, to gather a list
+        of all own and getter properties.
+
+        * inspector/InjectedScript.cpp:
+        (Inspector::InjectedScript::getProperties):
+        * inspector/InjectedScript.h:
+        * inspector/InjectedScriptSource.js:
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::getProperties):
+        * inspector/agents/InspectorRuntimeAgent.h:
+        * inspector/protocol/Runtime.json:
+
+2015-01-20  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Should show dynamic specificity values
         https://bugs.webkit.org/show_bug.cgi?id=140647
 
index 3b83d08..70242b0 100644 (file)
@@ -109,11 +109,12 @@ void InjectedScript::getFunctionDetails(ErrorString& errorString, const String&
     *result = BindingTraits<Inspector::Protocol::Debugger::FunctionDetails>::runtimeCast(WTF::move(resultValue));
 }
 
-void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
+void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool ownAndGetterProperties, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
 {
     Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler());
     function.appendArgument(objectId);
     function.appendArgument(ownProperties);
+    function.appendArgument(ownAndGetterProperties);
 
     RefPtr<InspectorValue> result;
     makeCall(function, &result);
index 29092b0..69236c8 100644 (file)
@@ -59,7 +59,7 @@ public:
     void callFunctionOn(ErrorString&, const String& objectId, const String& expression, const String& arguments, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
     void evaluateOnCallFrame(ErrorString&, const Deprecated::ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, bool returnByValue, bool generatePreview, RefPtr<Protocol::Runtime::RemoteObject>* result, Protocol::OptOutput<bool>* wasThrown);
     void getFunctionDetails(ErrorString&, const String& functionId, RefPtr<Protocol::Debugger::FunctionDetails>* result);
-    void getProperties(ErrorString&, const String& objectId, bool ownProperties, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
+    void getProperties(ErrorString&, const String& objectId, bool ownProperties, bool ownAndGetterProperties, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
     void getInternalProperties(ErrorString&, const String& objectId, RefPtr<Protocol::Array<Protocol::Runtime::InternalPropertyDescriptor>>* result);
 
     Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&);
index bf0ddc6..c7517a3 100644 (file)
@@ -226,12 +226,7 @@ InjectedScript.prototype = {
         return result;
     },
 
-    /**
-     * @param {string} objectId
-     * @param {boolean} ownProperties
-     * @return {Array.<RuntimeAgent.PropertyDescriptor>|boolean}
-     */
-    getProperties: function(objectId, ownProperties)
+    getProperties: function(objectId, ownProperties, ownAndGetterProperties)
     {
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
@@ -239,7 +234,8 @@ InjectedScript.prototype = {
 
         if (!this._isDefined(object))
             return false;
-        var descriptors = this._propertyDescriptors(object, ownProperties);
+
+        var descriptors = this._propertyDescriptors(object, ownProperties, ownAndGetterProperties);
 
         // Go over properties, wrap object values.
         for (var i = 0; i < descriptors.length; ++i) {
@@ -255,6 +251,7 @@ InjectedScript.prototype = {
             if (!("enumerable" in descriptor))
                 descriptor.enumerable = false;
         }
+
         return descriptors;
     },
 
@@ -328,70 +325,6 @@ InjectedScript.prototype = {
     },
 
     /**
-     * @param {Object} object
-     * @param {boolean} ownProperties
-     * @return {Array.<Object>}
-     */
-    _propertyDescriptors: function(object, ownProperties)
-    {
-        var descriptors = [];
-        var nameProcessed = {};
-        nameProcessed["__proto__"] = null;
-        for (var o = object; this._isDefined(o); o = o.__proto__) {
-            var names = Object.getOwnPropertyNames(/** @type {!Object} */ (o));
-            for (var i = 0; i < names.length; ++i) {
-                var name = names[i];
-                if (nameProcessed[name])
-                    continue;
-
-                try {
-                    nameProcessed[name] = true;
-                    var descriptor = Object.getOwnPropertyDescriptor(/** @type {!Object} */ (object), name);
-                    if (!descriptor) {
-                        // Not all bindings provide proper descriptors. Fall back to the writable, configurable property.
-                        try {
-                            descriptor = { name: name, value: object[name], writable: false, configurable: false, enumerable: false};
-                            if (o === object)
-                                descriptor.isOwn = true;
-                            descriptors.push(descriptor);
-                        } catch (e) {
-                            // Silent catch.
-                        }
-                        continue;
-                    }
-                    if (descriptor.hasOwnProperty("get") && descriptor.hasOwnProperty("set") && !descriptor.get && !descriptor.set) {
-                        // Not all bindings provide proper descriptors. Fall back to the writable, configurable property.
-                        try {
-                            descriptor = { name: name, value: object[name], writable: false, configurable: false, enumerable: false};
-                            if (o === object)
-                                descriptor.isOwn = true;
-                            descriptors.push(descriptor);
-                        } catch (e) {
-                            // Silent catch.
-                        }
-                        continue;
-                    }
-                } catch (e) {
-                    var descriptor = {};
-                    descriptor.value = e;
-                    descriptor.wasThrown = true;
-                }
-
-                descriptor.name = name;
-                if (o === object)
-                    descriptor.isOwn = true;
-                descriptors.push(descriptor);
-            }
-            if (ownProperties) {
-                if (object.__proto__)
-                    descriptors.push({ name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false, isOwn: true});
-                break;
-            }
-        }
-        return descriptors;
-    },
-
-    /**
      * @param {string} expression
      * @param {string} objectGroup
      * @param {boolean} injectCommandLineAPI
@@ -689,6 +622,109 @@ InjectedScript.prototype = {
         return module;
     },
 
+    _propertyDescriptors: function(object, ownProperties, ownAndGetterProperties)
+    {
+        // Modes:
+        //  - ownProperties - only own properties and __proto__
+        //  - ownAndGetterProperties - own properties, __proto__, and getters in the prototype chain
+        //  - neither - get all properties in the prototype chain, exclude __proto__
+
+        var descriptors = [];
+        var nameProcessed = {};
+        nameProcessed["__proto__"] = null;
+
+        function createFakeValueDescriptor(name, descriptor, isOwnProperty)
+        {
+            try {
+                return {name: name, value: object[name], writable: descriptor.writable, configurable: descriptor.configurable, enumerable: descriptor.enumerable};
+            } catch (e) {
+                var errorDescriptor = {name: name, value: e, wasThrown: true};
+                if (isOwnProperty)
+                    errorDescriptor.isOwn = true;
+                return errorDescriptor;
+            }
+        }
+
+        function processDescriptor(descriptor, isOwnProperty)
+        {
+            // Own properties only.
+            if (ownProperties) {
+                if (isOwnProperty)
+                    descriptors.push(descriptor);
+                return;
+            }
+
+            // Own and getter properties.
+            if (ownAndGetterProperties) {
+                if (isOwnProperty) {
+                    // Own property, include the descriptor as is.
+                    descriptors.push(descriptor);
+                } else if (descriptor.hasOwnProperty("get") && descriptor.get) {
+                    // Getter property in the prototype chain. Create a fake value descriptor.
+                    descriptors.push(createFakeValueDescriptor(descriptor.name, descriptor, isOwnProperty));
+                } else if (descriptor.possibleNativeBindingGetter) {
+                    // Possible getter property in the prototype chain.
+                    descriptors.push(descriptor);
+                }
+                return;
+            }
+
+            // All properties.
+            descriptors.push(descriptor);
+        }
+
+        function processPropertyNames(o, names, isOwnProperty)
+        {
+            for (var i = 0; i < names.length; ++i) {
+                var name = names[i];
+                if (nameProcessed[name] || name === "__proto__")
+                    continue;
+
+                nameProcessed[name] = true;
+
+                var descriptor = Object.getOwnPropertyDescriptor(o, name);
+                if (!descriptor) {
+                    // FIXME: Bad descriptor. Can we get here?
+                    // Fall back to very restrictive settings.
+                    var fakeDescriptor = createFakeValueDescriptor(name, {writable: false, configurable: false, enumerable: false}, isOwnProperty);
+                    processDescriptor(fakeDescriptor, isOwnProperty);
+                    continue;
+                }
+
+                if (descriptor.hasOwnProperty("get") && descriptor.hasOwnProperty("set") && !descriptor.get && !descriptor.set) {
+                    // FIXME: <https://webkit.org/b/140575> Web Inspector: Native Bindings Descriptors are Incomplete
+                    // 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, descriptor, isOwnProperty);
+                    fakeDescriptor.possibleNativeBindingGetter = true; // Native bindings.
+                    processDescriptor(fakeDescriptor, isOwnProperty);
+                    continue;
+                }
+
+                descriptor.name = name;
+                if (isOwnProperty)
+                    descriptor.isOwn = true;
+                processDescriptor(descriptor, isOwnProperty);
+            }
+        }
+
+        // Iterate prototype chain.
+        for (var o = object; this._isDefined(o); o = o.__proto__) {
+            var isOwnProperty = o === object;
+            processPropertyNames(o, Object.getOwnPropertyNames(o), isOwnProperty);
+            if (ownProperties)
+                break;
+        }
+        
+        // Include __proto__ at the end.
+        try {
+            if (object.__proto__)
+                descriptors.push({name: "__proto__", value: object.__proto__, writable: true, configurable: true, enumerable: false, isOwn: true});
+        } catch (e) {}
+
+        return descriptors;
+    },
+
     /**
      * @param {*} object
      * @return {boolean}
index 15ad746..b1a5994 100644 (file)
@@ -163,7 +163,7 @@ void InspectorRuntimeAgent::callFunctionOn(ErrorString& errorString, const Strin
     }
 }
 
-void InspectorRuntimeAgent::getProperties(ErrorString& errorString, const String& objectId, const bool* const ownProperties, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties)
+void InspectorRuntimeAgent::getProperties(ErrorString& errorString, const String& objectId, const bool* const ownProperties, const bool* const ownAndGetterProperties, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties)
 {
     InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
     if (injectedScript.hasNoValue()) {
@@ -174,7 +174,7 @@ void InspectorRuntimeAgent::getProperties(ErrorString& errorString, const String
     ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
     muteConsole();
 
-    injectedScript.getProperties(errorString, objectId, ownProperties ? *ownProperties : false, &result);
+    injectedScript.getProperties(errorString, objectId, ownProperties ? *ownProperties : false, ownAndGetterProperties ? *ownAndGetterProperties : false, &result);
     injectedScript.getInternalProperties(errorString, objectId, &internalProperties);
 
     unmuteConsole();
index 2e028a1..e92dfae 100644 (file)
@@ -65,7 +65,7 @@ public:
     virtual void evaluate(ErrorString&, const String& expression, const String* objectGroup, const bool* includeCommandLineAPI, const bool* doNotPauseOnExceptionsAndMuteConsole, const int* executionContextId, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown) override final;
     virtual void callFunctionOn(ErrorString&, const String& objectId, const String& expression, const RefPtr<Inspector::InspectorArray>&& optionalArguments, const bool* doNotPauseOnExceptionsAndMuteConsole, const bool* returnByValue, const bool* generatePreview, RefPtr<Inspector::Protocol::Runtime::RemoteObject>& result, Inspector::Protocol::OptOutput<bool>* wasThrown) override final;
     virtual void releaseObject(ErrorString&, const ErrorString& objectId) override final;
-    virtual void getProperties(ErrorString&, const String& objectId, const bool* ownProperties, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
+    virtual void getProperties(ErrorString&, const String& objectId, const bool* ownProperties, const bool* ownAndGetterProperties, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
     virtual void releaseObjectGroup(ErrorString&, const String& objectGroup) override final;
     virtual void run(ErrorString&) override;
     virtual void getRuntimeTypesForVariablesAtOffsets(ErrorString&, const RefPtr<Inspector::InspectorArray>&& locations, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::TypeDescription>>&) override;
index 69ad782..a795b92 100644 (file)
             "name": "getProperties",
             "parameters": [
                 { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to return properties for." },
-                { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the element itself, not to its prototype chain." }
+                { "name": "ownProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging only to the object itself, not to its prototype chain." },
+                { "name": "ownAndGetterProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging to the object itself, and getters in its prototype chain." }
             ],
             "returns": [
                 { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor"}, "description": "Object properties." },
index 016d890..82983b4 100644 (file)
@@ -1,5 +1,26 @@
 2015-01-20  Joseph Pecoraro  <pecoraro@apple.com>
 
+        Web Inspector: Expanding event objects in console shows undefined for most values, it should have real values
+        https://bugs.webkit.org/show_bug.cgi?id=137306
+
+        Reviewed by Timothy Hatcher.
+
+        When first expanding an object, show all the object's own properties and any
+        getter properties that may be on its prototype chain. Now, we only fetch
+        own properties, for __proto__ properties.
+
+        * UserInterface/Protocol/RemoteObject.js:
+        (WebInspector.RemoteObject.prototype.getOwnProperties):
+        (WebInspector.RemoteObject.prototype.getOwnAndGetterProperties):
+        (WebInspector.RemoteObject.prototype.getAllProperties):
+        (WebInspector.RemoteObject.prototype.get hasChildren): Deleted.
+        * UserInterface/Views/ObjectPropertiesSection.js:
+        (WebInspector.ObjectPropertiesSection):
+        (WebInspector.ObjectPropertiesSection.prototype.update):
+        (WebInspector.ObjectPropertyTreeElement.prototype.onpopulate):
+
+2015-01-20  Joseph Pecoraro  <pecoraro@apple.com>
+
         Web Inspector: Should show dynamic specificity values
         https://bugs.webkit.org/show_bug.cgi?id=140647
 
index fcd4fb6..2bbf435 100644 (file)
@@ -113,15 +113,20 @@ WebInspector.RemoteObject.prototype = {
 
     getOwnProperties: function(callback)
     {
-        this._getProperties(true, callback);
+        this._getProperties(true, false, callback);
+    },
+
+    getOwnAndGetterProperties: function(callback)
+    {
+        this._getProperties(false, true, callback);
     },
 
     getAllProperties: function(callback)
     {
-        this._getProperties(false, callback);
+        this._getProperties(false, false, callback);
     },
 
-    _getProperties: function(ownProperties, callback)
+    _getProperties: function(ownProperties, ownAndGetterProperties, callback)
     {
         if (!this._objectId) {
             callback([]);
@@ -147,7 +152,32 @@ WebInspector.RemoteObject.prototype = {
             }
             callback(result);
         }
-        RuntimeAgent.getProperties(this._objectId, ownProperties, remoteObjectBinder);
+
+        // COMPATIBILITY (iOS 8): RuntimeAgent.getProperties did not support ownerAndGetterProperties.
+        // Here we do our best to reimplement it by getting all properties and reducing them down.
+        if (ownAndGetterProperties && !RuntimeAgent.getProperties.supports("ownAndGetterProperties")) {
+            RuntimeAgent.getProperties(this._objectId, function(error, allProperties) {
+                var ownOrGetterPropertiesList = [];
+                if (allProperties) {
+                    for (var property of allProperties) {
+                        if (property.isOwn || property.get || property.name === "__proto__") {
+                            // Own property or getter property in prototype chain.
+                            ownOrGetterPropertiesList.push(property);
+                        } else if (property.value && property.name !== property.name.toUpperCase()) {
+                            var type = property.value.type;
+                            if (type && type !== "function" && property.name !== "constructor") {
+                                // Possible native binding getter property converted to a value. Also, no CONSTANT name style and not "constructor".
+                                ownOrGetterPropertiesList.push(property);
+                            }
+                        }
+                    }
+                }
+                remoteObjectBinder(error, ownOrGetterPropertiesList);
+            }); 
+            return;
+        }
+
+        RuntimeAgent.getProperties(this._objectId, ownProperties, ownAndGetterProperties, remoteObjectBinder);
     },
 
     setPropertyValue: function(name, value, callback)
index 350c0fa..8113db7 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPlaceholder, ignoreHasOwnProperty, extraProperties, treeElementConstructor)
+WebInspector.ObjectPropertiesSection = function(object, title, subtitle, emptyPlaceholder, getAllProperties, extraProperties, treeElementConstructor)
 {
     this.emptyPlaceholder = (emptyPlaceholder || WebInspector.UIString("No Properties"));
     this.object = object;
-    this.ignoreHasOwnProperty = ignoreHasOwnProperty;
+    this.getAllProperties = getAllProperties;
     this.extraProperties = extraProperties;
     this.treeElementConstructor = treeElementConstructor || WebInspector.ObjectPropertyTreeElement;
     this.editable = true;
@@ -50,10 +50,10 @@ WebInspector.ObjectPropertiesSection.prototype = {
                 return;
             self.updateProperties(properties);
         }
-        if (this.ignoreHasOwnProperty)
+        if (this.getAllProperties)
             this.object.getAllProperties(callback);
         else
-            this.object.getOwnProperties(callback);
+            this.object.getOwnAndGetterProperties(callback);
     },
 
     updateProperties: function(properties, rootTreeElementConstructor, rootPropertyComparer)
@@ -163,7 +163,11 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
                 this.appendChild(new this.treeOutline.section.treeElementConstructor(properties[i]));
             }
         };
-        this.property.value.getOwnProperties(callback.bind(this));
+
+        if (this.property.name === "__proto__")
+            this.property.value.getOwnProperties(callback.bind(this));
+        else
+            this.property.value.getOwnAndGetterProperties(callback.bind(this));
     },
 
     ondblclick: function(event)