Diff
Modified: trunk/LayoutTests/ChangeLog (91749 => 91750)
--- trunk/LayoutTests/ChangeLog 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/LayoutTests/ChangeLog 2011-07-26 10:20:53 UTC (rev 91750)
@@ -1,5 +1,15 @@
2011-07-26 Pavel Feldman <[email protected]>
+ Web Inspector: Implement setPropertyValue using evaluate and callFunctionOn
+ https://bugs.webkit.org/show_bug.cgi?id=65112
+
+ Reviewed by Yury Semikhatsky.
+
+ * inspector/runtime/runtime-setPropertyValue-expected.txt: Added.
+ * inspector/runtime/runtime-setPropertyValue.html: Added.
+
+2011-07-26 Pavel Feldman <[email protected]>
+
Re-applying r91665 and r91668 with JSC issues fixed.
Web Inspector: use dedicated type for object id in the protocol.
Modified: trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt (91749 => 91750)
--- trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/LayoutTests/inspector/protocol/runtime-agent-expected.txt 2011-07-26 10:20:53 UTC (rev 91750)
@@ -78,48 +78,6 @@
}
-----------------------------------------------------------
-RuntimeAgent.setPropertyValue(<string>,"assignedBySetPropertyValue","true")
-
-request:
-{
- method : "Runtime.setPropertyValue"
- params : {
- objectId : <string>
- propertyName : "assignedBySetPropertyValue"
- _expression_ : "true"
- }
- id : <number>
-}
-
-response:
-{
- result : {
- }
- id : <number>
-}
-
------------------------------------------------------------
-RuntimeAgent.setPropertyValue(<string>,"removedBySetPropertyValue","")
-
-request:
-{
- method : "Runtime.setPropertyValue"
- params : {
- objectId : <string>
- propertyName : "removedBySetPropertyValue"
- _expression_ : ""
- }
- id : <number>
-}
-
-response:
-{
- result : {
- }
- id : <number>
-}
-
------------------------------------------------------------
RuntimeAgent.getProperties(<string>,false)
request:
@@ -144,13 +102,6 @@
}
}
{
- name : "assignedBySetPropertyValue"
- value : {
- type : "boolean"
- value : true
- }
- }
- {
name : "__proto__"
value : {
type : "object"
@@ -208,7 +159,6 @@
evaluate : "checked"
callFunctionOn : "checked"
getProperties : "checked"
- setPropertyValue : "checked"
releaseObject : "checked"
releaseObjectGroup : "checked"
}
Modified: trunk/LayoutTests/inspector/protocol/runtime-agent.html (91749 => 91750)
--- trunk/LayoutTests/inspector/protocol/runtime-agent.html 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/LayoutTests/inspector/protocol/runtime-agent.html 2011-07-26 10:20:53 UTC (rev 91750)
@@ -6,7 +6,6 @@
function TestObject()
{
- this.removedBySetPropertyValue = "doesn't work";
}
testObject = new TestObject();
@@ -21,8 +20,6 @@
["RuntimeAgent", "evaluate", 'testObject', 'test', false],
["RuntimeAgent", "evaluate", 'testObject', 'test'],
["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],
["RuntimeAgent", "releaseObject", result.objectId],
["RuntimeAgent", "releaseObjectGroup", 'test']];
Added: trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue-expected.txt (0 => 91750)
--- trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue-expected.txt (rev 0)
+++ trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue-expected.txt 2011-07-26 10:20:53 UTC (rev 91750)
@@ -0,0 +1,37 @@
+CONSOLE MESSAGE: line 11: ===== Initial =====
+CONSOLE MESSAGE: line 12: {"foo":1}
+CONSOLE MESSAGE: line 13: {"bar":2}
+CONSOLE MESSAGE: line 14:
+CONSOLE MESSAGE: line 11: ===== Set primitive =====
+CONSOLE MESSAGE: line 12: {"foo":2}
+CONSOLE MESSAGE: line 13: {"bar":2}
+CONSOLE MESSAGE: line 14:
+CONSOLE MESSAGE: line 11: ===== Set handle =====
+CONSOLE MESSAGE: line 12: {"foo":{"bar":2}}
+CONSOLE MESSAGE: line 13: {"bar":2}
+CONSOLE MESSAGE: line 14:
+CONSOLE MESSAGE: line 11: ===== Set undefined =====
+CONSOLE MESSAGE: line 12: {}
+CONSOLE MESSAGE: line 13: {"bar":2}
+CONSOLE MESSAGE: line 14:
+CONSOLE MESSAGE: line 11: ===== Set exception =====
+CONSOLE MESSAGE: line 12: {}
+CONSOLE MESSAGE: line 13: {"bar":2}
+CONSOLE MESSAGE: line 14:
+Tests WebInspector.RemoveObject.setPropertyValue implementation.
+
+
+Running: testSetUp
+
+Running: testSetPrimitive
+
+Running: testSetHandle
+
+Running: testSetUndefined
+
+Running: testSetException
+{
+ type : "string"
+ value : "exception"
+}
+
Property changes on: trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue-expected.txt
___________________________________________________________________
Added: svn:eol-style
Added: trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue.html (0 => 91750)
--- trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue.html (rev 0)
+++ trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue.html 2011-07-26 10:20:53 UTC (rev 91750)
@@ -0,0 +1,96 @@
+<html>
+<head>
+<script src=""
+<script>
+
+var object1 = { foo: 1 };
+var object2 = { bar: 2 };
+
+function dumpObjects(label)
+{
+ console.log("===== " + label + " =====");
+ console.log(JSON.stringify(object1));
+ console.log(JSON.stringify(object2));
+ console.log("");
+}
+
+function test()
+{
+ var obj1, obj2;
+
+ InspectorTest.runTestSuite([
+ function testSetUp(next)
+ {
+ InspectorTest.evaluateInPage("dumpObjects('Initial')", step0);
+
+ function step0()
+ {
+ RuntimeAgent.evaluate("object1", step1);
+ }
+
+ function step1(error, result, wasThrown)
+ {
+ obj1 = WebInspector.RemoteObject.fromPayload(result);
+ RuntimeAgent.evaluate("object1", step2);
+ }
+
+ function step2(error, result, wasThrown)
+ {
+ obj2 = WebInspector.RemoteObject.fromPayload(result);
+ next();
+ }
+ },
+
+ function testSetPrimitive(next)
+ {
+ obj1.setPropertyValue("foo", "2", step1);
+
+ function step1()
+ {
+ InspectorTest.evaluateInPage("dumpObjects('Set primitive')", next);
+ }
+ },
+
+ function testSetHandle(next)
+ {
+ obj1.setPropertyValue("foo", "object2", step1);
+
+ function step1()
+ {
+ InspectorTest.evaluateInPage("dumpObjects('Set handle')", next);
+ }
+ },
+
+ function testSetUndefined(next)
+ {
+ obj1.setPropertyValue("foo", "undefined", step1);
+
+ function step1()
+ {
+ InspectorTest.evaluateInPage("dumpObjects('Set undefined')", next);
+ }
+ },
+
+ function testSetException(next)
+ {
+ obj1.setPropertyValue("foo", "throw 'exception'", step1);
+
+ function step1(error)
+ {
+ InspectorTest.dump(error);
+ InspectorTest.evaluateInPage("dumpObjects('Set exception')", next);
+ }
+ }
+ ]);
+}
+
+</script>
+</head>
+
+<body _onload_="runTest()">
+<p>
+Tests WebInspector.RemoveObject.setPropertyValue implementation.
+</p>
+
+</body>
+</html>
Property changes on: trunk/LayoutTests/inspector/runtime/runtime-setPropertyValue.html
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Source/WebCore/ChangeLog (91749 => 91750)
--- trunk/Source/WebCore/ChangeLog 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/ChangeLog 2011-07-26 10:20:53 UTC (rev 91750)
@@ -1,5 +1,27 @@
2011-07-26 Pavel Feldman <[email protected]>
+ Web Inspector: Implement setPropertyValue using evaluate and callFunctionOn
+ https://bugs.webkit.org/show_bug.cgi?id=65112
+
+ Reviewed by Yury Semikhatsky.
+
+ Test: inspector/runtime/runtime-setPropertyValue.html
+
+ * inspector/InjectedScript.cpp:
+ * inspector/InjectedScript.h:
+ * inspector/InjectedScriptSource.js:
+ (.):
+ * inspector/Inspector.json:
+ * inspector/InspectorRuntimeAgent.cpp:
+ * inspector/InspectorRuntimeAgent.h:
+ * inspector/front-end/RemoteObject.js:
+ (WebInspector.RemoteObject.prototype.setPropertyValue.evaluatedCallback.setPropertyValue):
+ (WebInspector.RemoteObject.prototype.setPropertyValue.evaluatedCallback):
+ (WebInspector.RemoteObject.prototype.setPropertyValue.propertySetCallback):
+ (WebInspector.RemoteObject.prototype.setPropertyValue):
+
+2011-07-26 Pavel Feldman <[email protected]>
+
Re-applying r91665 and r91668 with JSC issues fixed.
Web Inspector: use dedicated type for object id in the protocol.
Modified: trunk/Source/WebCore/inspector/InjectedScript.cpp (91749 => 91750)
--- trunk/Source/WebCore/inspector/InjectedScript.cpp 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/InjectedScript.cpp 2011-07-26 10:20:53 UTC (rev 91750)
@@ -113,17 +113,6 @@
return InjectedScriptHost::scriptValueAsNode(resultValue);
}
-void InjectedScript::setPropertyValue(ErrorString* errorString, const String& objectId, const String& propertyName, const String& _expression_)
-{
- ScriptFunctionCall function(m_injectedScriptObject, "setPropertyValue");
- function.appendArgument(objectId);
- function.appendArgument(propertyName);
- function.appendArgument(_expression_);
- RefPtr<InspectorValue> result;
- makeCall(function, &result);
- result->asString(errorString);
-}
-
void InjectedScript::releaseObject(const String& objectId)
{
ScriptFunctionCall function(m_injectedScriptObject, "releaseObject");
Modified: trunk/Source/WebCore/inspector/InjectedScript.h (91749 => 91750)
--- trunk/Source/WebCore/inspector/InjectedScript.h 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/InjectedScript.h 2011-07-26 10:20:53 UTC (rev 91750)
@@ -60,7 +60,6 @@
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);
- void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& _expression_);
void releaseObject(const String& objectId);
#if ENABLE(_javascript__DEBUGGER)
Modified: trunk/Source/WebCore/inspector/InjectedScriptSource.js (91749 => 91750)
--- trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/InjectedScriptSource.js 2011-07-26 10:20:53 UTC (rev 91750)
@@ -196,7 +196,7 @@
property.value = this._wrapObject(value, objectGroupName);
} else {
// FIXME: this should show something like "getter" (bug 16734).
- property.value = InjectedScript.RemoteObject.fromObject("\u2014"); // em dash
+ property.value = new InjectedScript.RemoteObject("\u2014"); // em dash
property.isGetter = true;
}
properties.push(property);
@@ -204,43 +204,6 @@
return properties;
},
- setPropertyValue: function(objectId, propertyName, _expression_)
- {
- var parsedObjectId = this._parseObjectId(objectId);
- var object = this._objectForId(parsedObjectId);
- if (!this._isDefined(object))
- return "Object with given id not found";
-
- var expressionLength = _expression_.length;
- if (!expressionLength) {
- delete object[propertyName];
- // Avoid explicit assignment to undefined as its value can be overriden (see crbug.com/88414).
- var result;
- if (propertyName in object)
- result = "Cound not delete property.";
- return result;
- }
-
- try {
- // Surround the _expression_ in parenthesis so the result of the eval is the result
- // of the whole _expression_ not the last potential sub-_expression_.
-
- // There is a regression introduced here: eval is now happening against global object,
- // not call frame while on a breakpoint.
- // TODO: bring evaluation against call frame back.
- var result = InjectedScriptHost.evaluate("(" + _expression_ + ")");
- // Store the result in the property.
- object[propertyName] = result;
- } catch(e) {
- try {
- var result = InjectedScriptHost.evaluate("\"" + _expression_.replace(/"/g, "\\\"") + "\"");
- object[propertyName] = result;
- } catch(e) {
- return e.toString();
- }
- }
- },
-
releaseObject: function(objectId)
{
var parsedObjectId = this._parseObjectId(objectId);
Modified: trunk/Source/WebCore/inspector/Inspector.json (91749 => 91750)
--- trunk/Source/WebCore/inspector/Inspector.json 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/Inspector.json 2011-07-26 10:20:53 UTC (rev 91750)
@@ -296,15 +296,6 @@
"description": "Returns properties of a given object."
},
{
- "name": "setPropertyValue",
- "parameters": [
- { "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to set property on." },
- { "name": "propertyName", "type": "string", "description": "Property name to set value for." },
- { "name": "_expression_", "type": "string", "description": "_expression_ to evaluate." }
- ],
- "description": "Makes property with given name equal to the _expression_ evaluation result."
- },
- {
"name": "releaseObject",
"parameters": [
{ "name": "objectId", "$ref": "RemoteObjectId", "description": "Identifier of the object to release." }
Modified: trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp (91749 => 91750)
--- trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/InspectorRuntimeAgent.cpp 2011-07-26 10:20:53 UTC (rev 91750)
@@ -105,15 +105,6 @@
injectedScript.getProperties(errorString, objectId, ignoreHasOwnProperty, result);
}
-void InspectorRuntimeAgent::setPropertyValue(ErrorString* errorString, const String& objectId, const String& propertyName, const String& _expression_)
-{
- InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
- if (!injectedScript.hasNoValue())
- injectedScript.setPropertyValue(errorString, objectId, propertyName, _expression_);
- else
- *errorString = "No injected script found";
-}
-
void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId)
{
InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
Modified: trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h (91749 => 91750)
--- trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/InspectorRuntimeAgent.h 2011-07-26 10:20:53 UTC (rev 91750)
@@ -57,7 +57,6 @@
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_);
void releaseObjectGroup(ErrorString*, const String& objectGroup);
#if ENABLE(_javascript__DEBUGGER)
Modified: trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js (91749 => 91750)
--- trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js 2011-07-26 10:20:53 UTC (rev 91750)
@@ -202,7 +202,9 @@
this.valueElement.addStyleClass("dimmed");
if (this.property.wasThrown)
this.valueElement.addStyleClass("error");
- if (this.property.value.type)
+ if (this.property.value.subtype)
+ this.valueElement.addStyleClass("console-formatted-" + this.property.value.subtype);
+ else if (this.property.value.type)
this.valueElement.addStyleClass("console-formatted-" + this.property.value.type);
if (this.property.value.subtype === "node")
this.valueElement.addEventListener("contextmenu", this._contextMenuEventFired.bind(this), false);
Modified: trunk/Source/WebCore/inspector/front-end/RemoteObject.js (91749 => 91750)
--- trunk/Source/WebCore/inspector/front-end/RemoteObject.js 2011-07-26 10:09:52 UTC (rev 91749)
+++ trunk/Source/WebCore/inspector/front-end/RemoteObject.js 2011-07-26 10:20:53 UTC (rev 91750)
@@ -31,10 +31,10 @@
WebInspector.RemoteObject = function(objectId, type, subtype, value, description)
{
this._type = type;
+ this._subtype = subtype;
if (objectId) {
// handle
this._objectId = objectId;
- this._subtype = subtype;
this._description = description;
this._hasChildren = true;
} else {
@@ -146,10 +146,37 @@
setPropertyValue: function(name, value, callback)
{
if (!this._objectId) {
- callback("Can't get a property of non-object.");
+ callback("Can't set a property of non-object.");
return;
}
- RuntimeAgent.setPropertyValue(this._objectId, name, value, callback);
+
+ RuntimeAgent.evaluate(value, undefined, false, true, evaluatedCallback.bind(this));
+
+ function evaluatedCallback(error, result, wasThrown)
+ {
+ if (error || wasThrown) {
+ callback(error || result);
+ return;
+ }
+
+ function setPropertyValue(propertyName, propertyValue)
+ {
+ this[propertyName] = propertyValue;
+ }
+
+ delete result.description; // Optimize on traffic.
+ RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [{ value:name }, result], propertySetCallback.bind(this));
+ if (result._objectId)
+ RuntimeAgent.releaseObject(result._objectId);
+ }
+
+ function propertySetCallback(error, result, wasThrown) {
+ if (error || wasThrown) {
+ callback(error || result);
+ return;
+ }
+ callback();
+ }
},
pushNodeToFrontend: function(callback)