Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/Source/WebCore/inspector/InjectedScript.cpp b/Source/WebCore/inspector/InjectedScript.cpp
- index 40b615c..b93fd6e 100644
- --- a/Source/WebCore/inspector/InjectedScript.cpp
- +++ b/Source/WebCore/inspector/InjectedScript.cpp
- @@ -120,17 +120,6 @@ Node* InjectedScript::nodeForObjectId(const String& objectId)
- 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");
- diff --git a/Source/WebCore/inspector/InjectedScript.h b/Source/WebCore/inspector/InjectedScript.h
- index 9c1d45f..f59650d 100644
- --- a/Source/WebCore/inspector/InjectedScript.h
- +++ b/Source/WebCore/inspector/InjectedScript.h
- @@ -60,7 +60,6 @@ public:
- 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)
- diff --git a/Source/WebCore/inspector/InjectedScriptSource.js b/Source/WebCore/inspector/InjectedScriptSource.js
- index 50b32cd..f22cf11 100644
- --- a/Source/WebCore/inspector/InjectedScriptSource.js
- +++ b/Source/WebCore/inspector/InjectedScriptSource.js
- @@ -50,6 +50,8 @@ var InjectedScript = function()
- this._objectGroups = {};
- }
- +InjectedScript.primitiveTypes = { "number": 1, "string": 1, "boolean": 1 };
- +
- InjectedScript.prototype = {
- wrapObject: function(object, groupName, canAccessInspectedWindow)
- {
- @@ -158,61 +160,33 @@ InjectedScript.prototype = {
- for (var i = 0; i < propertyNames.length; ++i) {
- var propertyName = propertyNames[i];
- - var property = {};
- - property.name = propertyName + "";
- - var isGetter = object["__lookupGetter__"] && object.__lookupGetter__(propertyName);
- - if (!isGetter) {
- + var getter = object["__lookupGetter__"] && object.__lookupGetter__(propertyName);
- + var setter = object["__lookupSetter__"] && object.__lookupSetter__(propertyName);
- + if (getter || setter) {
- + if (getter) {
- + var property = {};
- + property.name = "get " + propertyName;
- + property.value = this._wrapObject(getter, objectGroupName);
- + properties.push(property);
- + }
- + if (setter) {
- + var property = {};
- + property.name = "set " + propertyName;
- + property.value = this._wrapObject(setter, objectGroupName);
- + properties.push(property);
- + }
- + } else {
- + var property = {};
- + property.name = propertyName + "";
- try {
- - var value = object[propertyName];
- + property.value = this._wrapObject(object[propertyName], objectGroupName);
- } catch(e) {
- - var value = e;
- + property.value = this._wrapObject(e, objectGroupName);
- property.wasThrown = true;
- }
- - 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.isGetter = true;
- }
- - properties.push(property);
- - }
- - 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();
- - }
- + properties.push(property);
- }
- },
- @@ -261,14 +235,17 @@ InjectedScript.prototype = {
- 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;
- + if (typeof arguments[i] === "object") {
- + 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";
- -
- + resolvedArg = this._objectForId(parsedArgId);
- + if (!resolvedArg)
- + return "Could not find object with given id";
- + } else if (typeof arguments[i] in InjectedScript.primitiveTypes)
- + resolvedArg = arguments[i];
- resolvedArgs.push(resolvedArg);
- }
- diff --git a/Source/WebCore/inspector/Inspector.json b/Source/WebCore/inspector/Inspector.json
- index 8c8a2b4..573c7bd 100644
- --- a/Source/WebCore/inspector/Inspector.json
- +++ b/Source/WebCore/inspector/Inspector.json
- @@ -236,8 +236,7 @@
- "properties": [
- { "name": "name", "type": "string", "description": "Property name." },
- { "name": "value", "$ref": "RemoteObject", "description": "Property value." },
- - { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if exception was thrown on attempt to get the property value, in that case the value propery will contain thrown value." },
- - { "name": "isGetter", "type": "boolean", "optional": true, "description": "True if this property is getter." }
- + { "name": "wasThrown", "type": "boolean", "optional": true, "description": "True if exception was thrown on attempt to get the property value, in that case the value propery will contain thrown value." }
- ]
- }
- ],
- @@ -281,15 +280,6 @@
- "description": "Returns properties of a given object."
- },
- {
- - "name": "setPropertyValue",
- - "parameters": [
- - { "name": "objectId", "type": "string", "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", "type": "string", "description": "Identifier of the object to release." }
- diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
- index 9186310..c5e6fd4 100644
- --- a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
- +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
- @@ -107,15 +107,6 @@ void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String
- 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);
- diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.h b/Source/WebCore/inspector/InspectorRuntimeAgent.h
- index ac01da4..4de5dee 100644
- --- a/Source/WebCore/inspector/InspectorRuntimeAgent.h
- +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.h
- @@ -57,7 +57,6 @@ public:
- 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)
- diff --git a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
- index 9687807..71bee00 100644
- --- a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
- +++ b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
- @@ -198,8 +198,6 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
- } else
- this.valueElement.textContent = description;
- - if (this.property.isGetter)
- - this.valueElement.addStyleClass("dimmed");
- if (this.property.wasThrown)
- this.valueElement.addStyleClass("error");
- if (this.property.value.type)
- diff --git a/Source/WebCore/inspector/front-end/RemoteObject.js b/Source/WebCore/inspector/front-end/RemoteObject.js
- index 3cccff8..9c895a8 100644
- --- a/Source/WebCore/inspector/front-end/RemoteObject.js
- +++ b/Source/WebCore/inspector/front-end/RemoteObject.js
- @@ -137,7 +137,20 @@ WebInspector.RemoteObject.prototype = {
- callback("Can't get a property of non-object.");
- return;
- }
- - RuntimeAgent.setPropertyValue(this._objectId, name, value, callback);
- +
- + function mycallback(error, result, wasThrown)
- + {
- + if (error)
- + callback(error);
- + else
- + callback();
- + }
- +
- + function setPropertyValue(propertyName, expression)
- + {
- + this[propertyName] = InjectedScriptHost.evaluate(expression);
- + }
- + RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [ name, value ], callback);
- },
- pushNodeToFrontend: function(callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement