Diff
Modified: trunk/LayoutTests/ChangeLog (91471 => 91472)
--- trunk/LayoutTests/ChangeLog 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/LayoutTests/ChangeLog 2011-07-21 15:49:30 UTC (rev 91472)
@@ -1,3 +1,15 @@
+2011-07-21 Pavel Feldman <[email protected]>
+
+ Web Inspector: RuntimeAgent.evaluateOn should not require "return X;" syntax.
+ https://bugs.webkit.org/show_bug.cgi?id=64691
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/protocol/runtime-agent-expected.txt:
+ * inspector/protocol/runtime-agent.html:
+ * inspector/runtime/runtime-callFunctionOn-expected.txt: Added.
+ * inspector/runtime/runtime-callFunctionOn.html: Added.
+
2011-07-21 John Knottenbelt <[email protected]>
[Chromium] Mark fast/frames/meta-refresh-user-gesture.html as crashy.
Modified: trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt (91471 => 91472)
--- trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt 2011-07-21 15:49:30 UTC (rev 91472)
@@ -56,14 +56,14 @@
}
-----------------------------------------------------------
-RuntimeAgent.evaluateOn(<string>,"this.assignedByEvaluateOn = \"evaluateOn function works fine\";")
+RuntimeAgent.callFunctionOn(<string>,"function() { this.assignedByCallFunctionOn = \"callFunctionOn function works fine\"; return this.assignedByCallFunctionOn; }")
request:
{
- method : "Runtime.evaluateOn"
+ method : "Runtime.callFunctionOn"
params : {
objectId : <string>
- _expression_ : "this.assignedByEvaluateOn = "evaluateOn function works fine";"
+ functionDeclaration : "function() { this.assignedByCallFunctionOn = "callFunctionOn function works fine"; return this.assignedByCallFunctionOn; }"
}
id : <number>
}
@@ -72,8 +72,8 @@
{
result : {
result : {
- type : "undefined"
- description : "undefined"
+ type : "string"
+ description : "callFunctionOn function works fine"
}
}
id : <number>
@@ -139,10 +139,10 @@
result : {
result : [
{
- name : "assignedByEvaluateOn"
+ name : "assignedByCallFunctionOn"
value : {
type : "string"
- description : "evaluateOn function works fine"
+ description : "callFunctionOn function works fine"
}
}
{
@@ -209,7 +209,7 @@
Coverage for RuntimeAgent
{
evaluate : "checked"
- evaluateOn : "checked"
+ callFunctionOn : "checked"
getProperties : "checked"
setPropertyValue : "checked"
releaseObject : "checked"
Modified: trunk/LayoutTests/inspector/protocol/runtime-agent.html (91471 => 91472)
--- trunk/LayoutTests/inspector/protocol/runtime-agent.html 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/LayoutTests/inspector/protocol/runtime-agent.html 2011-07-21 15:49:30 UTC (rev 91472)
@@ -20,7 +20,7 @@
var testSuite = [
["RuntimeAgent", "evaluate", 'testObject', 'test', false],
["RuntimeAgent", "evaluate", 'testObject', 'test'],
- ["RuntimeAgent", "evaluateOn", result.objectId, 'this.assignedByEvaluateOn = "evaluateOn function works fine";'],
+ ["RuntimeAgent", "callFunctionOn", result.objectId, 'function() { this.assignedByCallFunctionOn = "callFunctionOn function works fine"; return this.assignedByCallFunctionOn; }'],
["RuntimeAgent", "setPropertyValue", result.objectId, 'assignedBySetPropertyValue', 'true'],
["RuntimeAgent", "setPropertyValue", result.objectId, 'removedBySetPropertyValue', ''],
["RuntimeAgent", "getProperties", result.objectId, false],
Added: trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn-expected.txt (0 => 91472)
--- trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn-expected.txt 2011-07-21 15:49:30 UTC (rev 91472)
@@ -0,0 +1,11 @@
+Tests RuntimeAgent.callFunctionOn usages.
+
+
+Running: testThis
+3
+
+Running: testArguments
+{"a":1,"b":2}
+{"a":1,"b":2}
+{"c":1,"d":2}
+
Property changes on: trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn.html (0 => 91472)
--- trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn.html (rev 0)
+++ trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn.html 2011-07-21 15:49:30 UTC (rev 91472)
@@ -0,0 +1,67 @@
+<html>
+<head>
+<script src=""
+<script>
+
+function test()
+{
+ var obj1, obj2;
+
+ InspectorTest.runTestSuite([
+ function testThis(next)
+ {
+ RuntimeAgent.evaluate("({ a : 1, b : 2 })", step1);
+
+ function step1(error, result, wasThrown)
+ {
+
+ function sum()
+ {
+ return this.a + this.b;
+ }
+
+ obj1 = result;
+ RuntimeAgent.callFunctionOn(obj1.objectId, sum.toString(), step2);
+ }
+
+ function step2(error, result, wasThrown)
+ {
+ InspectorTest.addResult(result.description);
+ next();
+ }
+ },
+
+ function testArguments(next)
+ {
+ RuntimeAgent.evaluate("({ c : 1, d : 2 })", step1);
+
+ function step1(error, result, wasThrown)
+ {
+ function format(aobj1, aobj2)
+ {
+ return JSON.stringify(this) + "\n" + JSON.stringify(aobj1) + "\n" + JSON.stringify(aobj2);
+ }
+
+ obj2 = result;
+ RuntimeAgent.callFunctionOn(obj1.objectId, format.toString(), [obj1.objectId, obj2.objectId], step2);
+ }
+
+ function step2(error, result, wasThrown)
+ {
+ InspectorTest.addResult(result.description);
+ next();
+ }
+ }
+ ]);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests RuntimeAgent.callFunctionOn usages.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/runtime/runtime-callFunctionOn.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (91471 => 91472)
--- trunk/Source/WebCore/ChangeLog 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/ChangeLog 2011-07-21 15:49:30 UTC (rev 91472)
@@ -1,3 +1,34 @@
+2011-07-21 Pavel Feldman <[email protected]>
+
+ Web Inspector: RuntimeAgent.evaluateOn should not require "return X;" syntax.
+ https://bugs.webkit.org/show_bug.cgi?id=64691
+
+ Reviewed by Yury Semikhatsky.
+
+ I'm introducing callFunctionOn that receives function declaration in order
+ to make call site syntax clear.
+
+ Test: inspector/runtime/runtime-callFunctionOn.html
+
+ * inspector/InjectedScript.cpp:
+ (WebCore::InjectedScript::callFunctionOn):
+ * inspector/InjectedScript.h:
+ * inspector/InjectedScriptSource.js:
+ (.):
+ * inspector/Inspector.json:
+ * inspector/InspectorRuntimeAgent.cpp:
+ (WebCore::InspectorRuntimeAgent::callFunctionOn):
+ * inspector/InspectorRuntimeAgent.h:
+ * inspector/front-end/ElementsTreeOutline.js:
+ (WebInspector.ElementsTreeElement.prototype._createTooltipForNode.resolvedNode.dimensions):
+ (WebInspector.ElementsTreeElement.prototype._createTooltipForNode.resolvedNode):
+ (WebInspector.ElementsTreeElement.prototype._createTooltipForNode):
+ * inspector/front-end/PropertiesSidebarPane.js:
+ (WebInspector.PropertiesSidebarPane.prototype.update.nodeResolved.protoList):
+ (WebInspector.PropertiesSidebarPane.prototype.update.nodeResolved):
+ * inspector/front-end/RemoteObject.js:
+ (WebInspector.RemoteObject.prototype.callFunction):
+
2011-07-21 Andrew Wason <[email protected]>
[Qt] Adopt existing GraphicsContext3D members (part 1)
Modified: trunk/Source/WebCore/inspector/InjectedScript.cpp (91471 => 91472)
--- trunk/Source/WebCore/inspector/InjectedScript.cpp 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/InjectedScript.cpp 2011-07-21 15:49:30 UTC (rev 91472)
@@ -63,11 +63,19 @@
makeEvalCall(errorString, function, result, wasThrown);
}
-void InjectedScript::evaluateOn(ErrorString* errorString, const String& objectId, const String& _expression_, RefPtr<InspectorObject>* result, bool* wasThrown)
+void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& _expression_, PassRefPtr<InspectorArray> arguments, RefPtr<InspectorObject>* result, bool* wasThrown)
{
- ScriptFunctionCall function(m_injectedScriptObject, "evaluateOn");
+ ScriptFunctionCall function(m_injectedScriptObject, "callFunctionOn");
function.appendArgument(objectId);
function.appendArgument(_expression_);
+ for (unsigned i = 0; i < arguments->length(); ++i) {
+ String argumentId;
+ if (!arguments->get(i)->asString(&argumentId)) {
+ *errorString = "Call argument should be an object id";
+ return;
+ }
+ function.appendArgument(argumentId);
+ }
makeEvalCall(errorString, function, result, wasThrown);
}
Modified: trunk/Source/WebCore/inspector/InjectedScript.h (91471 => 91472)
--- trunk/Source/WebCore/inspector/InjectedScript.h 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/InjectedScript.h 2011-07-21 15:49:30 UTC (rev 91472)
@@ -56,7 +56,7 @@
bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
void evaluate(ErrorString*, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
- void evaluateOn(ErrorString*, const String& objectId, const String& _expression_, RefPtr<InspectorObject>* result, bool* wasThrown);
+ void callFunctionOn(ErrorString*, const String& objectId, const String& _expression_, PassRefPtr<InspectorArray> arguments, RefPtr<InspectorObject>* result, bool* wasThrown);
void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& _expression_, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
Node* nodeForObjectId(const String& objectId);
Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (91471 => 91472)
--- trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-07-21 15:49:30 UTC (rev 91472)
@@ -252,18 +252,37 @@
return this._evaluateAndWrap(InjectedScriptHost.evaluate, InjectedScriptHost, _expression_, objectGroup, false, injectCommandLineAPI);
},
- evaluateOn: function(objectId, _expression_)
+ callFunctionOn: function(objectId, _expression_)
{
var parsedObjectId = this._parseObjectId(objectId);
var object = this._objectForId(parsedObjectId);
if (!object)
return "Could not find object with given id";
+
+ var resolvedArgs = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ var parsedArgId = this._parseObjectId(arguments[i]);
+ if (!parsedArgId || parsedArgId.injectedScriptId !== injectedScriptId)
+ return "Arguments should belong to the same _javascript_ world as the target object.";
+
+ var resolvedArg = this._objectForId(parsedArgId);
+ if (!resolvedArg)
+ return "Could not find object with given id";
+
+ resolvedArgs.push(resolvedArg);
+ }
+
try {
- inspectedWindow.console._objectToEvaluateOn = object;
- var objectGroupName = this._idToObjectGroupName[parsedObjectId.id];
- return this._evaluateAndWrap(inspectedWindow.eval, inspectedWindow, "(function() {" + _expression_ + "}).call(window.console._objectToEvaluateOn)", objectGroupName, false, false);
- } finally {
- delete inspectedWindow.console._objectToEvaluateOn;
+ var objectGroup = this._idToObjectGroupName[parsedObjectId.id];
+ var func = InjectedScriptHost.evaluate("(" + _expression_ + ")");
+ if (typeof func !== "function")
+ return "Given _expression_ does not evaluate to a function";
+
+ return { wasThrown: false,
+ result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup) };
+ } catch (e) {
+ return { wasThrown: true,
+ result: this._wrapObject(e, objectGroup) };
}
},
Modified: trunk/Source/WebCore/inspector/Inspector.json (91471 => 91472)
--- trunk/Source/WebCore/inspector/Inspector.json 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/Inspector.json 2011-07-21 15:49:30 UTC (rev 91472)
@@ -257,16 +257,17 @@
"description": "Evaluate _expression_ on global object."
},
{
- "name": "evaluateOn",
+ "name": "callFunctionOn",
"parameters": [
- { "name": "objectId", "type": "string", "description": "Identifier of the object to evaluate _expression_ on." },
- { "name": "_expression_", "type": "string", "description": "_expression_ to evaluate." }
+ { "name": "objectId", "type": "string", "description": "Identifier of the object to call function on." },
+ { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." },
+ { "name": "arguments", "type": "array", "items": { "type": "objectId", "description": "Identifier of the argument." }, "optional": true, "description": "Call arguments. All call arguments must belong to the same _javascript_ world as the target object." }
],
"returns": [
- { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." },
+ { "name": "result", "$ref": "RemoteObject", "description": "Call result." },
{ "name": "wasThrown", "type": "boolean", "optional": true, "description": "True iff the result was thrown during the evaluation." }
],
- "description": "Evaluate _expression_ on given object using it as <code>this</code>."
+ "description": "Call function with given declaration on the given object."
},
{
"name": "getProperties",
@@ -515,7 +516,7 @@
{ "name": "cacheDisabled", "type": "boolean", "description": "Cache disabled state." }
],
"description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used."
- },
+ }
],
"events": [
{
@@ -1016,7 +1017,7 @@
"name": "resolveNode",
"parameters": [
{ "name": "nodeId", "type": "integer", "description": "Id of the node to resolve." },
- { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." },
+ { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." }
],
"returns": [
{ "name": "object", "$ref": "Runtime.RemoteObject", "description": "_javascript_ object wrapper for given node." }
Modified: trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp (91471 => 91472)
--- trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp 2011-07-21 15:49:30 UTC (rev 91472)
@@ -82,14 +82,19 @@
#endif
}
-void InspectorRuntimeAgent::evaluateOn(ErrorString* errorString, const String& objectId, const String& _expression_, RefPtr<InspectorObject>* result, bool* wasThrown)
+void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& _expression_, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
if (injectedScript.hasNoValue()) {
*errorString = "Inspected frame has gone";
return;
}
- injectedScript.evaluateOn(errorString, objectId, _expression_, result, wasThrown);
+ RefPtr<InspectorArray> arguments = InspectorArray::create();
+ if (optionalArguments) {
+ for (unsigned i = 0; i < (*optionalArguments)->length(); ++i)
+ arguments->pushValue((*optionalArguments)->get(i));
+ }
+ injectedScript.callFunctionOn(errorString, objectId, _expression_, arguments, result, wasThrown);
}
void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result)
Modified: trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h (91471 => 91472)
--- trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h 2011-07-21 15:49:30 UTC (rev 91472)
@@ -54,7 +54,7 @@
// Part of the protocol.
void evaluate(ErrorString*, const String& _expression_, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, RefPtr<InspectorObject>* result, bool* wasThrown);
- void evaluateOn(ErrorString*, const String& objectId, const String& _expression_, RefPtr<InspectorObject>* result, bool* wasThrown);
+ void callFunctionOn(ErrorString*, const String& objectId, const String& _expression_, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown);
void releaseObject(ErrorString*, const String& objectId);
void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& _expression_);
Modified: trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js (91471 => 91472)
--- trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js 2011-07-21 15:49:30 UTC (rev 91472)
@@ -604,7 +604,12 @@
if (!object)
return;
- object.evaluate("return '[' + this.offsetWidth + ',' + this.offsetHeight + ',' + this.naturalWidth + ',' + this.naturalHeight + ']'", setTooltip.bind(this));
+ function dimensions()
+ {
+ return "[" + this.offsetWidth + "," + this.offsetHeight + "," + this.naturalWidth + "," + this.naturalHeight + "]";
+ }
+
+ object.callFunction(dimensions, setTooltip.bind(this));
object.release();
}
WebInspector.RemoteObject.resolveNode(node, "", resolvedNode.bind(this));
Modified: trunk/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js (91471 => 91472)
--- trunk/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js 2011-07-21 15:49:30 UTC (rev 91472)
@@ -50,7 +50,18 @@
{
if (!object)
return;
- object.evaluate("var proto = this; result = {}; var counter = 1; while (proto) { result[counter++] = proto; proto = proto.__proto__ }; return result;", nodePrototypesReady.bind(this));
+ function protoList()
+ {
+ var proto = this;
+ var result = {};
+ var counter = 1;
+ while (proto) {
+ result[counter++] = proto;
+ proto = proto.__proto__;
+ }
+ return result;
+ }
+ object.callFunction(protoList, nodePrototypesReady.bind(this));
object.release();
}
Modified: trunk/Source/WebCore/inspector/front-end/RemoteObject.js (91471 => 91472)
--- trunk/Source/WebCore/inspector/front-end/RemoteObject.js 2011-07-21 15:39:39 UTC (rev 91471)
+++ trunk/Source/WebCore/inspector/front-end/RemoteObject.js 2011-07-21 15:49:30 UTC (rev 91472)
@@ -148,9 +148,9 @@
callback(0);
},
- evaluate: function(_expression_, callback)
+ callFunction: function(functionDeclaration, callback)
{
- RuntimeAgent.evaluateOn(this._objectId, _expression_, callback);
+ RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), undefined, callback);
},
release: function()