Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1850)

Unified Diff: Source/devtools/front_end/RemoteObject.js

Issue 201613004: DevTools: Add context menu option for objects to save to temp variable. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/devtools/front_end/RemoteObject.js
diff --git a/Source/devtools/front_end/RemoteObject.js b/Source/devtools/front_end/RemoteObject.js
index 916d4d9fd6ff82edd880cc70f5a420db3000fa61..556fd8803c7a785db5db35f1add250abe2d29e97 100644
--- a/Source/devtools/front_end/RemoteObject.js
+++ b/Source/devtools/front_end/RemoteObject.js
@@ -179,6 +179,34 @@ WebInspector.RemoteObject.type = function(remoteObject)
}
/**
+ * @param {!RuntimeAgent.RemoteObject|!WebInspector.RemoteObject} remoteObject
+ * @return {!RuntimeAgent.CallArgument}
+ */
+WebInspector.RemoteObject.toCallArgument = function(remoteObject)
+{
+ var type = /** @type {!RuntimeAgent.CallArgumentType.<string>} */ (remoteObject.type);
+ var value = remoteObject.value;
+
+ // Handle special numbers: NaN, Infinity, -Infinity, -0.
+ if (type === "number") {
+ switch (remoteObject.description) {
+ case "NaN":
+ case "Infinity":
+ case "-Infinity":
+ case "-0":
+ value = remoteObject.description;
+ break;
+ }
+ }
+
+ return {
+ value: value,
+ objectId: remoteObject.objectId,
+ type: type
+ };
+}
+
+/**
* @constructor
* @extends {WebInspector.RemoteObject}
* @param {!WebInspector.Target|undefined} target
@@ -389,7 +417,7 @@ WebInspector.RemoteObjectImpl.prototype = {
// where property was defined; so do we.
var setPropertyValueFunction = "function(a, b) { this[a] = b; }";
- var argv = [{ value: name }, this._toCallArgument(result)]
+ var argv = [{ value: name }, WebInspector.RemoteObject.toCallArgument(result)]
this._runtimeAgent.callFunctionOn(this._objectId, setPropertyValueFunction, argv, true, undefined, undefined, propertySetCallback);
/**
@@ -408,15 +436,6 @@ WebInspector.RemoteObjectImpl.prototype = {
},
/**
- * @param {!RuntimeAgent.RemoteObject} object
- * @return {!RuntimeAgent.CallArgument}
- */
- _toCallArgument: function(object)
- {
- return { value: object.value, objectId: object.objectId, type: /** @type {!RuntimeAgent.CallArgumentType.<string>} */ (object.type) };
- },
-
- /**
* @param {function(?DOMAgent.NodeId)} callback
*/
pushNodeToFrontend: function(callback)
@@ -654,7 +673,7 @@ WebInspector.ScopeRemoteObject.prototype = {
*/
doSetObjectPropertyValue: function(result, name, callback)
{
- this._debuggerAgent.setVariableValue(this._scopeRef.number, name, this._toCallArgument(result), this._scopeRef.callFrameId, this._scopeRef.functionId, setVariableValueCallback.bind(this));
+ this._debuggerAgent.setVariableValue(this._scopeRef.number, name, WebInspector.RemoteObject.toCallArgument(result), this._scopeRef.callFrameId, this._scopeRef.functionId, setVariableValueCallback.bind(this));
/**
* @param {?Protocol.Error} error

Powered by Google App Engine
This is Rietveld 408576698