Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.89 KB | None | 0 0
  1. diff --git a/Source/WebCore/inspector/InjectedScript.cpp b/Source/WebCore/inspector/InjectedScript.cpp
  2. index 40b615c..b93fd6e 100644
  3. --- a/Source/WebCore/inspector/InjectedScript.cpp
  4. +++ b/Source/WebCore/inspector/InjectedScript.cpp
  5. @@ -120,17 +120,6 @@ Node* InjectedScript::nodeForObjectId(const String& objectId)
  6. return InjectedScriptHost::scriptValueAsNode(resultValue);
  7. }
  8.  
  9. -void InjectedScript::setPropertyValue(ErrorString* errorString, const String& objectId, const String& propertyName, const String& expression)
  10. -{
  11. - ScriptFunctionCall function(m_injectedScriptObject, "setPropertyValue");
  12. - function.appendArgument(objectId);
  13. - function.appendArgument(propertyName);
  14. - function.appendArgument(expression);
  15. - RefPtr<InspectorValue> result;
  16. - makeCall(function, &result);
  17. - result->asString(errorString);
  18. -}
  19. -
  20. void InjectedScript::releaseObject(const String& objectId)
  21. {
  22. ScriptFunctionCall function(m_injectedScriptObject, "releaseObject");
  23. diff --git a/Source/WebCore/inspector/InjectedScript.h b/Source/WebCore/inspector/InjectedScript.h
  24. index 9c1d45f..f59650d 100644
  25. --- a/Source/WebCore/inspector/InjectedScript.h
  26. +++ b/Source/WebCore/inspector/InjectedScript.h
  27. @@ -60,7 +60,6 @@ public:
  28. void evaluateOnCallFrame(ErrorString*, const ScriptValue& callFrames, const String& callFrameId, const String& expression, const String& objectGroup, bool includeCommandLineAPI, RefPtr<InspectorObject>* result, bool* wasThrown);
  29. void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
  30. Node* nodeForObjectId(const String& objectId);
  31. - void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& expression);
  32. void releaseObject(const String& objectId);
  33.  
  34. #if ENABLE(JAVASCRIPT_DEBUGGER)
  35. diff --git a/Source/WebCore/inspector/InjectedScriptSource.js b/Source/WebCore/inspector/InjectedScriptSource.js
  36. index 50b32cd..f22cf11 100644
  37. --- a/Source/WebCore/inspector/InjectedScriptSource.js
  38. +++ b/Source/WebCore/inspector/InjectedScriptSource.js
  39. @@ -50,6 +50,8 @@ var InjectedScript = function()
  40. this._objectGroups = {};
  41. }
  42.  
  43. +InjectedScript.primitiveTypes = { "number": 1, "string": 1, "boolean": 1 };
  44. +
  45. InjectedScript.prototype = {
  46. wrapObject: function(object, groupName, canAccessInspectedWindow)
  47. {
  48. @@ -158,61 +160,33 @@ InjectedScript.prototype = {
  49. for (var i = 0; i < propertyNames.length; ++i) {
  50. var propertyName = propertyNames[i];
  51.  
  52. - var property = {};
  53. - property.name = propertyName + "";
  54. - var isGetter = object["__lookupGetter__"] && object.__lookupGetter__(propertyName);
  55. - if (!isGetter) {
  56. + var getter = object["__lookupGetter__"] && object.__lookupGetter__(propertyName);
  57. + var setter = object["__lookupSetter__"] && object.__lookupSetter__(propertyName);
  58. + if (getter || setter) {
  59. + if (getter) {
  60. + var property = {};
  61. + property.name = "get " + propertyName;
  62. + property.value = this._wrapObject(getter, objectGroupName);
  63. + properties.push(property);
  64. + }
  65. + if (setter) {
  66. + var property = {};
  67. + property.name = "set " + propertyName;
  68. + property.value = this._wrapObject(setter, objectGroupName);
  69. + properties.push(property);
  70. + }
  71. + } else {
  72. + var property = {};
  73. + property.name = propertyName + "";
  74. try {
  75. - var value = object[propertyName];
  76. + property.value = this._wrapObject(object[propertyName], objectGroupName);
  77. } catch(e) {
  78. - var value = e;
  79. + property.value = this._wrapObject(e, objectGroupName);
  80. property.wasThrown = true;
  81. }
  82. - property.value = this._wrapObject(value, objectGroupName);
  83. - } else {
  84. - // FIXME: this should show something like "getter" (bug 16734).
  85. - property.value = InjectedScript.RemoteObject.fromObject("\u2014"); // em dash
  86. - property.isGetter = true;
  87. }
  88. - properties.push(property);
  89. - }
  90. - return properties;
  91. - },
  92. -
  93. - setPropertyValue: function(objectId, propertyName, expression)
  94. - {
  95. - var parsedObjectId = this._parseObjectId(objectId);
  96. - var object = this._objectForId(parsedObjectId);
  97. - if (!this._isDefined(object))
  98. - return "Object with given id not found";
  99. -
  100. - var expressionLength = expression.length;
  101. - if (!expressionLength) {
  102. - delete object[propertyName];
  103. - // Avoid explicit assignment to undefined as its value can be overriden (see crbug.com/88414).
  104. - var result;
  105. - if (propertyName in object)
  106. - result = "Cound not delete property.";
  107. - return result;
  108. - }
  109.  
  110. - try {
  111. - // Surround the expression in parenthesis so the result of the eval is the result
  112. - // of the whole expression not the last potential sub-expression.
  113. -
  114. - // There is a regression introduced here: eval is now happening against global object,
  115. - // not call frame while on a breakpoint.
  116. - // TODO: bring evaluation against call frame back.
  117. - var result = InjectedScriptHost.evaluate("(" + expression + ")");
  118. - // Store the result in the property.
  119. - object[propertyName] = result;
  120. - } catch(e) {
  121. - try {
  122. - var result = InjectedScriptHost.evaluate("\"" + expression.replace(/"/g, "\\\"") + "\"");
  123. - object[propertyName] = result;
  124. - } catch(e) {
  125. - return e.toString();
  126. - }
  127. + properties.push(property);
  128. }
  129. },
  130.  
  131. @@ -261,14 +235,17 @@ InjectedScript.prototype = {
  132.  
  133. var resolvedArgs = [];
  134. for (var i = 2; i < arguments.length; ++i) {
  135. - var parsedArgId = this._parseObjectId(arguments[i]);
  136. - if (!parsedArgId || parsedArgId.injectedScriptId !== injectedScriptId)
  137. - return "Arguments should belong to the same JavaScript world as the target object.";
  138. + var resolvedArg;
  139. + if (typeof arguments[i] === "object") {
  140. + var parsedArgId = this._parseObjectId(arguments[i]);
  141. + if (!parsedArgId || parsedArgId.injectedScriptId !== injectedScriptId)
  142. + return "Arguments should belong to the same JavaScript world as the target object.";
  143.  
  144. - var resolvedArg = this._objectForId(parsedArgId);
  145. - if (!resolvedArg)
  146. - return "Could not find object with given id";
  147. -
  148. + resolvedArg = this._objectForId(parsedArgId);
  149. + if (!resolvedArg)
  150. + return "Could not find object with given id";
  151. + } else if (typeof arguments[i] in InjectedScript.primitiveTypes)
  152. + resolvedArg = arguments[i];
  153. resolvedArgs.push(resolvedArg);
  154. }
  155.  
  156. diff --git a/Source/WebCore/inspector/Inspector.json b/Source/WebCore/inspector/Inspector.json
  157. index 8c8a2b4..573c7bd 100644
  158. --- a/Source/WebCore/inspector/Inspector.json
  159. +++ b/Source/WebCore/inspector/Inspector.json
  160. @@ -236,8 +236,7 @@
  161. "properties": [
  162. { "name": "name", "type": "string", "description": "Property name." },
  163. { "name": "value", "$ref": "RemoteObject", "description": "Property value." },
  164. - { "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." },
  165. - { "name": "isGetter", "type": "boolean", "optional": true, "description": "True if this property is getter." }
  166. + { "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." }
  167. ]
  168. }
  169. ],
  170. @@ -281,15 +280,6 @@
  171. "description": "Returns properties of a given object."
  172. },
  173. {
  174. - "name": "setPropertyValue",
  175. - "parameters": [
  176. - { "name": "objectId", "type": "string", "description": "Identifier of the object to set property on." },
  177. - { "name": "propertyName", "type": "string", "description": "Property name to set value for." },
  178. - { "name": "expression", "type": "string", "description": "Expression to evaluate." }
  179. - ],
  180. - "description": "Makes property with given name equal to the expression evaluation result."
  181. - },
  182. - {
  183. "name": "releaseObject",
  184. "parameters": [
  185. { "name": "objectId", "type": "string", "description": "Identifier of the object to release." }
  186. diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
  187. index 9186310..c5e6fd4 100644
  188. --- a/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
  189. +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.cpp
  190. @@ -107,15 +107,6 @@ void InspectorRuntimeAgent::getProperties(ErrorString* errorString, const String
  191. injectedScript.getProperties(errorString, objectId, ignoreHasOwnProperty, result);
  192. }
  193.  
  194. -void InspectorRuntimeAgent::setPropertyValue(ErrorString* errorString, const String& objectId, const String& propertyName, const String& expression)
  195. -{
  196. - InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
  197. - if (!injectedScript.hasNoValue())
  198. - injectedScript.setPropertyValue(errorString, objectId, propertyName, expression);
  199. - else
  200. - *errorString = "No injected script found";
  201. -}
  202. -
  203. void InspectorRuntimeAgent::releaseObject(ErrorString*, const String& objectId)
  204. {
  205. InjectedScript injectedScript = m_injectedScriptManager->injectedScriptForObjectId(objectId);
  206. diff --git a/Source/WebCore/inspector/InspectorRuntimeAgent.h b/Source/WebCore/inspector/InspectorRuntimeAgent.h
  207. index ac01da4..4de5dee 100644
  208. --- a/Source/WebCore/inspector/InspectorRuntimeAgent.h
  209. +++ b/Source/WebCore/inspector/InspectorRuntimeAgent.h
  210. @@ -57,7 +57,6 @@ public:
  211. void callFunctionOn(ErrorString*, const String& objectId, const String& expression, const RefPtr<InspectorArray>* const optionalArguments, RefPtr<InspectorObject>* result, bool* wasThrown);
  212. void releaseObject(ErrorString*, const String& objectId);
  213. void getProperties(ErrorString*, const String& objectId, bool ignoreHasOwnProperty, RefPtr<InspectorArray>* result);
  214. - void setPropertyValue(ErrorString*, const String& objectId, const String& propertyName, const String& expression);
  215. void releaseObjectGroup(ErrorString*, const String& objectGroup);
  216.  
  217. #if ENABLE(JAVASCRIPT_DEBUGGER)
  218. diff --git a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
  219. index 9687807..71bee00 100644
  220. --- a/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
  221. +++ b/Source/WebCore/inspector/front-end/ObjectPropertiesSection.js
  222. @@ -198,8 +198,6 @@ WebInspector.ObjectPropertyTreeElement.prototype = {
  223. } else
  224. this.valueElement.textContent = description;
  225.  
  226. - if (this.property.isGetter)
  227. - this.valueElement.addStyleClass("dimmed");
  228. if (this.property.wasThrown)
  229. this.valueElement.addStyleClass("error");
  230. if (this.property.value.type)
  231. diff --git a/Source/WebCore/inspector/front-end/RemoteObject.js b/Source/WebCore/inspector/front-end/RemoteObject.js
  232. index 3cccff8..9c895a8 100644
  233. --- a/Source/WebCore/inspector/front-end/RemoteObject.js
  234. +++ b/Source/WebCore/inspector/front-end/RemoteObject.js
  235. @@ -137,7 +137,20 @@ WebInspector.RemoteObject.prototype = {
  236. callback("Can't get a property of non-object.");
  237. return;
  238. }
  239. - RuntimeAgent.setPropertyValue(this._objectId, name, value, callback);
  240. +
  241. + function mycallback(error, result, wasThrown)
  242. + {
  243. + if (error)
  244. + callback(error);
  245. + else
  246. + callback();
  247. + }
  248. +
  249. + function setPropertyValue(propertyName, expression)
  250. + {
  251. + this[propertyName] = InjectedScriptHost.evaluate(expression);
  252. + }
  253. + RuntimeAgent.callFunctionOn(this._objectId, setPropertyValue.toString(), [ name, value ], callback);
  254. },
  255.  
  256. pushNodeToFrontend: function(callback)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement