Changeset 91472 in webkit
- Timestamp:
- Jul 21, 2011, 8:49:30 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r91471 r91472 1 2011-07-21 Pavel Feldman <pfeldman@google.com> 2 3 Web Inspector: RuntimeAgent.evaluateOn should not require "return X;" syntax. 4 https://bugs.webkit.org/show_bug.cgi?id=64691 5 6 Reviewed by Yury Semikhatsky. 7 8 * inspector/protocol/runtime-agent-expected.txt: 9 * inspector/protocol/runtime-agent.html: 10 * inspector/runtime/runtime-callFunctionOn-expected.txt: Added. 11 * inspector/runtime/runtime-callFunctionOn.html: Added. 12 1 13 2011-07-21 John Knottenbelt <jknotten@chromium.org> 2 14 -
trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt
r86836 r91472 57 57 58 58 ----------------------------------------------------------- 59 RuntimeAgent. evaluateOn(<string>,"this.assignedByEvaluateOn = \"evaluateOn function works fine\";")60 61 request: 62 { 63 method : "Runtime. evaluateOn"64 params : { 65 objectId : <string> 66 expression : "this.assignedByEvaluateOn = "evaluateOn function works fine";"59 RuntimeAgent.callFunctionOn(<string>,"function() { this.assignedByCallFunctionOn = \"callFunctionOn function works fine\"; return this.assignedByCallFunctionOn; }") 60 61 request: 62 { 63 method : "Runtime.callFunctionOn" 64 params : { 65 objectId : <string> 66 functionDeclaration : "function() { this.assignedByCallFunctionOn = "callFunctionOn function works fine"; return this.assignedByCallFunctionOn; }" 67 67 } 68 68 id : <number> … … 73 73 result : { 74 74 result : { 75 type : " undefined"76 description : " undefined"75 type : "string" 76 description : "callFunctionOn function works fine" 77 77 } 78 78 } … … 140 140 result : [ 141 141 { 142 name : "assignedBy EvaluateOn"142 name : "assignedByCallFunctionOn" 143 143 value : { 144 144 type : "string" 145 description : " evaluateOn function works fine"145 description : "callFunctionOn function works fine" 146 146 } 147 147 } … … 210 210 { 211 211 evaluate : "checked" 212 evaluateOn : "checked"212 callFunctionOn : "checked" 213 213 getProperties : "checked" 214 214 setPropertyValue : "checked" -
trunk/LayoutTests/inspector/protocol/runtime-agent.html
r86836 r91472 21 21 ["RuntimeAgent", "evaluate", 'testObject', 'test', false], 22 22 ["RuntimeAgent", "evaluate", 'testObject', 'test'], 23 ["RuntimeAgent", " evaluateOn", result.objectId, 'this.assignedByEvaluateOn = "evaluateOn function works fine";'],23 ["RuntimeAgent", "callFunctionOn", result.objectId, 'function() { this.assignedByCallFunctionOn = "callFunctionOn function works fine"; return this.assignedByCallFunctionOn; }'], 24 24 ["RuntimeAgent", "setPropertyValue", result.objectId, 'assignedBySetPropertyValue', 'true'], 25 25 ["RuntimeAgent", "setPropertyValue", result.objectId, 'removedBySetPropertyValue', ''], -
trunk/Source/WebCore/ChangeLog
r91469 r91472 1 2011-07-21 Pavel Feldman <pfeldman@google.com> 2 3 Web Inspector: RuntimeAgent.evaluateOn should not require "return X;" syntax. 4 https://bugs.webkit.org/show_bug.cgi?id=64691 5 6 Reviewed by Yury Semikhatsky. 7 8 I'm introducing callFunctionOn that receives function declaration in order 9 to make call site syntax clear. 10 11 Test: inspector/runtime/runtime-callFunctionOn.html 12 13 * inspector/InjectedScript.cpp: 14 (WebCore::InjectedScript::callFunctionOn): 15 * inspector/InjectedScript.h: 16 * inspector/InjectedScriptSource.js: 17 (.): 18 * inspector/Inspector.json: 19 * inspector/InspectorRuntimeAgent.cpp: 20 (WebCore::InspectorRuntimeAgent::callFunctionOn): 21 * inspector/InspectorRuntimeAgent.h: 22 * inspector/front-end/ElementsTreeOutline.js: 23 (WebInspector.ElementsTreeElement.prototype._createTooltipForNode.resolvedNode.dimensions): 24 (WebInspector.ElementsTreeElement.prototype._createTooltipForNode.resolvedNode): 25 (WebInspector.ElementsTreeElement.prototype._createTooltipForNode): 26 * inspector/front-end/PropertiesSidebarPane.js: 27 (WebInspector.PropertiesSidebarPane.prototype.update.nodeResolved.protoList): 28 (WebInspector.PropertiesSidebarPane.prototype.update.nodeResolved): 29 * inspector/front-end/RemoteObject.js: 30 (WebInspector.RemoteObject.prototype.callFunction): 31 1 32 2011-07-21 Andrew Wason <rectalogic@rectalogic.com> 2 33 -
trunk/Source/WebCore/inspector/InjectedScript.cpp
r89429 r91472 64 64 } 65 65 66 void InjectedScript::evaluateOn(ErrorString* errorString, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown) 67 { 68 ScriptFunctionCall function(m_injectedScriptObject, "evaluateOn"); 69 function.appendArgument(objectId); 70 function.appendArgument(expression); 66 void InjectedScript::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, PassRefPtr<InspectorArray> arguments, RefPtr<InspectorObject>* result, bool* wasThrown) 67 { 68 ScriptFunctionCall function(m_injectedScriptObject, "callFunctionOn"); 69 function.appendArgument(objectId); 70 function.appendArgument(expression); 71 for (unsigned i = 0; i < arguments->length(); ++i) { 72 String argumentId; 73 if (!arguments->get(i)->asString(&argumentId)) { 74 *errorString = "Call argument should be an object id"; 75 return; 76 } 77 function.appendArgument(argumentId); 78 } 71 79 makeEvalCall(errorString, function, result, wasThrown); 72 80 } -
trunk/Source/WebCore/inspector/InjectedScript.h
r89429 r91472 57 57 58 58 void evaluate(ErrorString*, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown); 59 void evaluateOn(ErrorString*, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown);59 void callFunctionOn(ErrorString*, const String& objectId, const String& expression, PassRefPtr<InspectorArray> arguments, RefPtr<InspectorObject>* result, bool* wasThrown); 60 60 void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown); 61 61 void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result); -
trunk/Source/WebCore/inspector/InjectedScriptSource.js
r90614 r91472 253 253 }, 254 254 255 evaluateOn: function(objectId, expression)255 callFunctionOn: function(objectId, expression) 256 256 { 257 257 var parsedObjectId = this._parseObjectId(objectId); … … 259 259 if (!object) 260 260 return "Could not find object with given id"; 261 262 var resolvedArgs = []; 263 for (var i = 2; i < arguments.length; ++i) { 264 var parsedArgId = this._parseObjectId(arguments[i]); 265 if (!parsedArgId || parsedArgId.injectedScriptId !== injectedScriptId) 266 return "Arguments should belong to the same JavaScript world as the target object."; 267 268 var resolvedArg = this._objectForId(parsedArgId); 269 if (!resolvedArg) 270 return "Could not find object with given id"; 271 272 resolvedArgs.push(resolvedArg); 273 } 274 261 275 try { 262 inspectedWindow.console._objectToEvaluateOn = object; 263 var objectGroupName = this._idToObjectGroupName[parsedObjectId.id]; 264 return this._evaluateAndWrap(inspectedWindow.eval, inspectedWindow, "(function() {" + expression + "}).call(window.console._objectToEvaluateOn)", objectGroupName, false, false); 265 } finally { 266 delete inspectedWindow.console._objectToEvaluateOn; 276 var objectGroup = this._idToObjectGroupName[parsedObjectId.id]; 277 var func = InjectedScriptHost.evaluate("(" + expression + ")"); 278 if (typeof func !== "function") 279 return "Given expression does not evaluate to a function"; 280 281 return { wasThrown: false, 282 result: this._wrapObject(func.apply(object, resolvedArgs), objectGroup) }; 283 } catch (e) { 284 return { wasThrown: true, 285 result: this._wrapObject(e, objectGroup) }; 267 286 } 268 287 }, -
trunk/Source/WebCore/inspector/Inspector.json
r91461 r91472 258 258 }, 259 259 { 260 "name": "evaluateOn", 261 "parameters": [ 262 { "name": "objectId", "type": "string", "description": "Identifier of the object to evaluate expression on." }, 263 { "name": "expression", "type": "string", "description": "Expression to evaluate." } 264 ], 265 "returns": [ 266 { "name": "result", "$ref": "RemoteObject", "description": "Evaluation result." }, 260 "name": "callFunctionOn", 261 "parameters": [ 262 { "name": "objectId", "type": "string", "description": "Identifier of the object to call function on." }, 263 { "name": "functionDeclaration", "type": "string", "description": "Declaration of the function to call." }, 264 { "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." } 265 ], 266 "returns": [ 267 { "name": "result", "$ref": "RemoteObject", "description": "Call result." }, 267 268 { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True iff the result was thrown during the evaluation." } 268 269 ], 269 "description": " Evaluate expression on given object using it as <code>this</code>."270 "description": "Call function with given declaration on the given object." 270 271 }, 271 272 { … … 516 517 ], 517 518 "description": "Toggles ignoring cache for each request. If <code>true</code>, cache will not be used." 518 } ,519 } 519 520 ], 520 521 "events": [ … … 1017 1018 "parameters": [ 1018 1019 { "name": "nodeId", "type": "integer", "description": "Id of the node to resolve." }, 1019 { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." } ,1020 { "name": "objectGroup", "type": "string", "optional": true, "description": "Symbolic group name that can be used to release multiple objects." } 1020 1021 ], 1021 1022 "returns": [ -
trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
r91176 r91472 83 83 } 84 84 85 void InspectorRuntimeAgent:: evaluateOn(ErrorString* errorString, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown)85 void InspectorRuntimeAgent::callFunctionOn(ErrorString* errorString, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown) 86 86 { 87 87 InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId); … … 90 90 return; 91 91 } 92 injectedScript.evaluateOn(errorString, objectId, expression, result, wasThrown); 92 RefPtr<InspectorArray> arguments = InspectorArray::create(); 93 if (optionalArguments) { 94 for (unsigned i = 0; i < (*optionalArguments)->length(); ++i) 95 arguments->pushValue((*optionalArguments)->get(i)); 96 } 97 injectedScript.callFunctionOn(errorString, objectId, expression, arguments, result, wasThrown); 93 98 } 94 99 -
trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h
r91176 r91472 55 55 // Part of the protocol. 56 56 void evaluate(ErrorString*, const String& expression, const String* const objectGroup, const bool* const includeCommandLineAPI, const bool* const doNotPauseOnExceptions, RefPtr<InspectorObject>* result, bool* wasThrown); 57 void evaluateOn(ErrorString*, const String& objectId, const String& expression, RefPtr<InspectorObject>* result, bool* wasThrown);57 void callFunctionOn(ErrorString*, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown); 58 58 void releaseObject(ErrorString*, const String& objectId); 59 59 void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result); -
trunk/Source/WebCore/inspector/front-end/ElementsTreeOutline.js
r91179 r91472 605 605 return; 606 606 607 object.evaluate("return '[' + this.offsetWidth + ',' + this.offsetHeight + ',' + this.naturalWidth + ',' + this.naturalHeight + ']'", setTooltip.bind(this)); 607 function dimensions() 608 { 609 return "[" + this.offsetWidth + "," + this.offsetHeight + "," + this.naturalWidth + "," + this.naturalHeight + "]"; 610 } 611 612 object.callFunction(dimensions, setTooltip.bind(this)); 608 613 object.release(); 609 614 } -
trunk/Source/WebCore/inspector/front-end/PropertiesSidebarPane.js
r89429 r91472 51 51 if (!object) 52 52 return; 53 object.evaluate("var proto = this; result = {}; var counter = 1; while (proto) { result[counter++] = proto; proto = proto.__proto__ }; return result;", nodePrototypesReady.bind(this)); 53 function protoList() 54 { 55 var proto = this; 56 var result = {}; 57 var counter = 1; 58 while (proto) { 59 result[counter++] = proto; 60 proto = proto.__proto__; 61 } 62 return result; 63 } 64 object.callFunction(protoList, nodePrototypesReady.bind(this)); 54 65 object.release(); 55 66 } -
trunk/Source/WebCore/inspector/front-end/RemoteObject.js
r89429 r91472 149 149 }, 150 150 151 evaluate: function(expression, callback)152 { 153 RuntimeAgent. evaluateOn(this._objectId, expression, callback);151 callFunction: function(functionDeclaration, callback) 152 { 153 RuntimeAgent.callFunctionOn(this._objectId, functionDeclaration.toString(), undefined, callback); 154 154 }, 155 155
Note:
See TracChangeset
for help on using the changeset viewer.