Web Inspector: Generate Previews more often for RemoteObject interaction
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Feb 2015 03:50:34 +0000 (03:50 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 22 Feb 2015 03:50:34 +0000 (03:50 +0000)
https://bugs.webkit.org/show_bug.cgi?id=141875

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

Source/JavaScriptCore:

* inspector/protocol/Runtime.json:
Add generatePreview to getProperties.

* inspector/InjectedScript.cpp:
(Inspector::InjectedScript::getProperties):
(Inspector::InjectedScript::getInternalProperties):
* inspector/InjectedScript.h:
* inspector/agents/InspectorRuntimeAgent.cpp:
(Inspector::InspectorRuntimeAgent::getProperties):
* inspector/agents/InspectorRuntimeAgent.h:
Plumb the generatePreview boolean through to the injected script.

* inspector/InjectedScriptSource.js:
Add generatePreview for getProperties.
Fix callFunctionOn to generatePreviews if asked.

Source/WebInspectorUI:

* UserInterface/Models/PropertyDescriptor.js:
(WebInspector.PropertyDescriptor.fromPayload):
Fix InternalPropertyDescriptor ingestion. There was no ".internal"
property on these objects, so take a flag.

* UserInterface/Protocol/RemoteObject.js:
(WebInspector.RemoteObject.prototype._getPropertyDescriptors):
Fix InternalPropertyDescriptor ingestion by specifying during
importing the internal properties. Also, get previews.

(WebInspector.RemoteObject.prototype.callFunction):
Always get previews when using callFunctionOn.

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

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/Models/PropertyDescriptor.js
Source/WebInspectorUI/UserInterface/Protocol/RemoteObject.js

index 5f6c421..d635344 100644 (file)
@@ -1,3 +1,26 @@
+2015-02-21  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Generate Previews more often for RemoteObject interaction
+        https://bugs.webkit.org/show_bug.cgi?id=141875
+
+        Reviewed by Timothy Hatcher.
+
+        * inspector/protocol/Runtime.json:
+        Add generatePreview to getProperties.
+
+        * inspector/InjectedScript.cpp:
+        (Inspector::InjectedScript::getProperties):
+        (Inspector::InjectedScript::getInternalProperties):
+        * inspector/InjectedScript.h:
+        * inspector/agents/InspectorRuntimeAgent.cpp:
+        (Inspector::InspectorRuntimeAgent::getProperties):
+        * inspector/agents/InspectorRuntimeAgent.h:
+        Plumb the generatePreview boolean through to the injected script.
+
+        * inspector/InjectedScriptSource.js:
+        Add generatePreview for getProperties.
+        Fix callFunctionOn to generatePreviews if asked.
+
 2015-02-20  Mark Lam  <mark.lam@apple.com>
 
         Refactor JSWrapperMap.mm to defer creation of the ObjC JSValue until the latest possible moment.
index 24e80fd..b87e0cc 100644 (file)
@@ -107,12 +107,13 @@ 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, bool ownAndGetterProperties, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
+void InjectedScript::getProperties(ErrorString& errorString, const String& objectId, bool ownProperties, bool ownAndGetterProperties, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>* properties)
 {
     Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getProperties"), inspectorEnvironment()->functionCallHandler());
     function.appendArgument(objectId);
     function.appendArgument(ownProperties);
     function.appendArgument(ownAndGetterProperties);
+    function.appendArgument(generatePreview);
 
     RefPtr<InspectorValue> result;
     makeCall(function, &result);
@@ -124,10 +125,11 @@ void InjectedScript::getProperties(ErrorString& errorString, const String& objec
     *properties = BindingTraits<Array<Inspector::Protocol::Runtime::PropertyDescriptor>>::runtimeCast(WTF::move(result));
 }
 
-void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, RefPtr<Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>* properties)
+void InjectedScript::getInternalProperties(ErrorString& errorString, const String& objectId, bool generatePreview, RefPtr<Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>* properties)
 {
     Deprecated::ScriptFunctionCall function(injectedScriptObject(), ASCIILiteral("getInternalProperties"), inspectorEnvironment()->functionCallHandler());
     function.appendArgument(objectId);
+    function.appendArgument(generatePreview);
 
     RefPtr<InspectorValue> result;
     makeCall(function, &result);
index 3a1aafd..8d297df 100644 (file)
@@ -56,8 +56,8 @@ 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, bool ownAndGetterProperties, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
-    void getInternalProperties(ErrorString&, const String& objectId, RefPtr<Protocol::Array<Protocol::Runtime::InternalPropertyDescriptor>>* result);
+    void getProperties(ErrorString&, const String& objectId, bool ownProperties, bool ownAndGetterProperties, bool generatePreview, RefPtr<Protocol::Array<Protocol::Runtime::PropertyDescriptor>>* result);
+    void getInternalProperties(ErrorString&, const String& objectId, bool generatePreview, RefPtr<Protocol::Array<Protocol::Runtime::InternalPropertyDescriptor>>* result);
     void getCollectionEntries(ErrorString&, const String& objectId, const String& objectGroup, int startIndex, int numberToFetch, RefPtr<Protocol::Array<Protocol::Runtime::CollectionEntry>>* entries);
 
     Ref<Protocol::Array<Protocol::Debugger::CallFrame>> wrapCallFrames(const Deprecated::ScriptValue&);
index f7ac382..d7a1f41 100644 (file)
@@ -196,7 +196,7 @@ InjectedScript.prototype = {
         return result;
     },
 
-    getProperties: function(objectId, ownProperties, ownAndGetterProperties)
+    getProperties: function(objectId, ownProperties, ownAndGetterProperties, generatePreview)
     {
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
@@ -224,7 +224,7 @@ InjectedScript.prototype = {
             if ("set" in descriptor)
                 descriptor.set = this._wrapObject(descriptor.set, objectGroupName);
             if ("value" in descriptor)
-                descriptor.value = this._wrapObject(descriptor.value, objectGroupName);
+                descriptor.value = this._wrapObject(descriptor.value, objectGroupName, false, generatePreview);
             if (!("configurable" in descriptor))
                 descriptor.configurable = false;
             if (!("enumerable" in descriptor))
@@ -234,7 +234,7 @@ InjectedScript.prototype = {
         return descriptors;
     },
 
-    getInternalProperties: function(objectId)
+    getInternalProperties: function(objectId, generatePreview)
     {
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
@@ -254,7 +254,7 @@ InjectedScript.prototype = {
         for (var i = 0; i < descriptors.length; ++i) {
             var descriptor = descriptors[i];
             if ("value" in descriptor)
-                descriptor.value = this._wrapObject(descriptor.value, objectGroupName);
+                descriptor.value = this._wrapObject(descriptor.value, objectGroupName, false, generatePreview);
         }
 
         return descriptors;
@@ -319,7 +319,7 @@ InjectedScript.prototype = {
         return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, expression, objectGroup, false, injectCommandLineAPI, returnByValue, generatePreview);
     },
 
-    callFunctionOn: function(objectId, expression, args, returnByValue)
+    callFunctionOn: function(objectId, expression, args, returnByValue, generatePreview)
     {
         var parsedObjectId = this._parseObjectId(objectId);
         var object = this._objectForId(parsedObjectId);
@@ -346,7 +346,7 @@ InjectedScript.prototype = {
 
             return {
                 wasThrown: false,
-                result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue)
+                result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup, returnByValue, generatePreview)
             };
         } catch (e) {
             return this._createThrownValue(e, objectGroup);
index f453935..aab02f9 100644 (file)
@@ -160,7 +160,7 @@ void InspectorRuntimeAgent::callFunctionOn(ErrorString& errorString, const Strin
     }
 }
 
-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)
+void InspectorRuntimeAgent::getProperties(ErrorString& errorString, const String& objectId, const bool* const ownProperties, const bool* const ownAndGetterProperties, const bool* const generatePreview, 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()) {
@@ -171,8 +171,8 @@ void InspectorRuntimeAgent::getProperties(ErrorString& errorString, const String
     ScriptDebugServer::PauseOnExceptionsState previousPauseOnExceptionsState = setPauseOnExceptionsState(m_scriptDebugServer, ScriptDebugServer::DontPauseOnExceptions);
     muteConsole();
 
-    injectedScript.getProperties(errorString, objectId, asBool(ownProperties), asBool(ownAndGetterProperties), &result);
-    injectedScript.getInternalProperties(errorString, objectId, &internalProperties);
+    injectedScript.getProperties(errorString, objectId, asBool(ownProperties), asBool(ownAndGetterProperties), asBool(generatePreview), &result);
+    injectedScript.getInternalProperties(errorString, objectId, asBool(generatePreview), &internalProperties);
 
     unmuteConsole();
     setPauseOnExceptionsState(m_scriptDebugServer, previousPauseOnExceptionsState);
index 8713ec2..fd7b585 100644 (file)
@@ -63,7 +63,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, 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 getProperties(ErrorString&, const String& objectId, const bool* ownProperties, const bool* ownAndGetterProperties, const bool* generatePreview, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::PropertyDescriptor>>& result, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::InternalPropertyDescriptor>>& internalProperties) override final;
     virtual void getCollectionEntries(ErrorString&, const String& objectId, const String* objectGroup, const int* startIndex, const int* numberToFetch, RefPtr<Inspector::Protocol::Array<Inspector::Protocol::Runtime::CollectionEntry>>& entries) override final;
     virtual void releaseObjectGroup(ErrorString&, const String& objectGroup) override final;
     virtual void run(ErrorString&) override;
index 2f67b2e..f07d9c5 100644 (file)
             "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 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." }
+                { "name": "ownAndGetterProperties", "optional": true, "type": "boolean", "description": "If true, returns properties belonging to the object itself, and getters in its prototype chain." },
+                { "name": "generatePreview", "type": "boolean", "optional": true, "description": "Whether preview should be generated for property values." }
             ],
             "returns": [
                 { "name": "result", "type": "array", "items": { "$ref": "PropertyDescriptor"}, "description": "Object properties." },
index 36f19ad..c19fae2 100644 (file)
@@ -1,3 +1,23 @@
+2015-02-21  Joseph Pecoraro  <pecoraro@apple.com>
+
+        Web Inspector: Generate Previews more often for RemoteObject interaction
+        https://bugs.webkit.org/show_bug.cgi?id=141875
+
+        Reviewed by Timothy Hatcher.
+
+        * UserInterface/Models/PropertyDescriptor.js:
+        (WebInspector.PropertyDescriptor.fromPayload):
+        Fix InternalPropertyDescriptor ingestion. There was no ".internal"
+        property on these objects, so take a flag.
+
+        * UserInterface/Protocol/RemoteObject.js:
+        (WebInspector.RemoteObject.prototype._getPropertyDescriptors):
+        Fix InternalPropertyDescriptor ingestion by specifying during
+        importing the internal properties. Also, get previews.
+
+        (WebInspector.RemoteObject.prototype.callFunction):
+        Always get previews when using callFunctionOn.
+
 2015-02-20  Ronald Jett  <rjett@apple.com>
 
         Web Inspector: Add a setting for clearing the console on page reload
index 9fef369..60b3b03 100644 (file)
@@ -48,8 +48,8 @@ WebInspector.PropertyDescriptor = function(descriptor, isOwnProperty, wasThrown,
     this._internal = isInternalProperty || false;
 };
 
-// Runtime.PropertyDescriptor or Runtime.InternalPropertyDescriptor.
-WebInspector.PropertyDescriptor.fromPayload = function(payload)
+// Runtime.PropertyDescriptor or Runtime.InternalPropertyDescriptor (second argument).
+WebInspector.PropertyDescriptor.fromPayload = function(payload, internal)
 {
     if (payload.value)
         payload.value = WebInspector.RemoteObject.fromPayload(payload.value);
@@ -58,13 +58,13 @@ WebInspector.PropertyDescriptor.fromPayload = function(payload)
     if (payload.set)
         payload.set = WebInspector.RemoteObject.fromPayload(payload.set);
 
-    if (payload.internal) {
+    if (internal) {
         console.assert(payload.value);
         payload.writable = payload.configurable = payload.enumerable = false;
         payload.isOwn = true;
     }
 
-    return new WebInspector.PropertyDescriptor(payload, payload.isOwn, payload.wasThrown, payload.internal);
+    return new WebInspector.PropertyDescriptor(payload, payload.isOwn, payload.wasThrown, internal);
 };
 
 WebInspector.PropertyDescriptor.prototype = {
index b0eb66c..c20fc02 100644 (file)
@@ -174,13 +174,16 @@ WebInspector.RemoteObject.prototype = {
                 return;
             }
 
-            if (internalProperties)
-                properties = properties.concat(internalProperties);
-
             var descriptors = properties.map(function(payload) {
                 return WebInspector.PropertyDescriptor.fromPayload(payload);
             });
 
+            if (internalProperties) {
+                descriptors = descriptors.concat(internalProperties.map(function(payload) {
+                    return WebInspector.PropertyDescriptor.fromPayload(payload, true);
+                }));
+            }
+
             callback(descriptors);
         }
 
@@ -208,7 +211,7 @@ WebInspector.RemoteObject.prototype = {
             return;
         }
 
-        RuntimeAgent.getProperties(this._objectId, ownProperties, ownAndGetterProperties, remoteObjectBinder);
+        RuntimeAgent.getProperties(this._objectId, ownProperties, ownAndGetterProperties, true, remoteObjectBinder);
     },
 
     // FIXME: Phase out these functions. They return RemoteObjectProperty instead of PropertyDescriptors.
@@ -388,7 +391,7 @@ WebInspector.RemoteObject.prototype = {
             callback((error || wasThrown) ? null : WebInspector.RemoteObject.fromPayload(result));
         }
 
-        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, undefined, mycallback);
+        RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), args, true, undefined, true, mycallback);
     },
 
     callFunctionJSON: function(functionDeclaration, args, callback)