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

Unified Diff: third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js

Issue 2214193002: [DevTools] Introduce unserializableValue in RemoteObject. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: hidden Created 4 years, 4 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: third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
diff --git a/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js b/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
index cf7f738bee69f1a8b7c85d372748ef791c00468c..15a0ec04fe1669d26b04fef20c0ca4e5950a67aa 100644
--- a/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
+++ b/third_party/WebKit/Source/devtools/front_end/sdk/RemoteObject.js
@@ -330,46 +330,37 @@ WebInspector.RemoteObject.arrayLength = function(object)
WebInspector.RemoteObject.toCallArgument = function(object)
{
var type = typeof object;
- var value = object;
- var objectId = undefined;
- var description = String(object);
-
- if (type === "number" && value === 0 && 1 / value < 0)
- description = "-0";
-
- switch (type) {
- case "number":
- case "string":
- case "boolean":
- case "undefined":
- break;
- default:
- if (object) {
- type = object.type;
- value = object.value;
- objectId = object.objectId;
- description = object.description;
- }
- break;
- }
-
- // Handle special numbers: NaN, Infinity, -Infinity, -0.
+ if (type === "undefined")
+ return {};
if (type === "number") {
- switch (description) {
- case "NaN":
- case "Infinity":
- case "-Infinity":
- case "-0":
- value = description;
- break;
- }
+ var description = String(object);
+ if (object === 0 && 1 / object < 0)
+ return { unserializableValue: RuntimeAgent.UnserializableValue.Negative0 };
+ if (description === "NaN")
+ return { unserializableValue: RuntimeAgent.UnserializableValue.NaN };
+ if (description === "Infinity")
+ return { unserializableValue: RuntimeAgent.UnserializableValue.Infinity };
+ if (description === "-Infinity")
+ return { unserializableValue: RuntimeAgent.UnserializableValue.NegativeInfinity };
+ return { value: object };
}
+ if (type === "string" || type === "boolean")
+ return { value: object };
+
+ if (!object)
+ return { value: null };
+
+ if (typeof object.unserializableValue !== "undefined")
kozy 2016/08/05 01:21:02 Why do you need both checks?
dgozman 2016/08/05 02:01:07 Because it takes both WI.RemoteObject and RA.Remot
+ return { unserializableValue: object.unserializableValue };
+ if (typeof object._unserializableValue !== "undefined")
+ return { unserializableValue: object._unserializableValue };
- return {
- value: value,
- objectId: objectId,
- type: /** @type {!RuntimeAgent.CallArgumentType.<string>} */ (type)
- };
+ if (typeof object.objectId !== "undefined")
+ return { objectId: object.objectId };
+ if (typeof object._objectId !== "undefined")
+ return { objectId: object._objectId };
+
+ return { value: object.value };
}
/**
@@ -380,11 +371,12 @@ WebInspector.RemoteObject.toCallArgument = function(object)
* @param {string} type
* @param {string|undefined} subtype
* @param {*} value
+ * @param {!RuntimeAgent.UnserializableValue=} unserializableValue
* @param {string=} description
* @param {!RuntimeAgent.ObjectPreview=} preview
* @param {!RuntimeAgent.CustomPreview=} customPreview
*/
-WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value, description, preview, customPreview)
+WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value, unserializableValue, description, preview, customPreview)
{
WebInspector.RemoteObject.call(this);
@@ -404,11 +396,19 @@ WebInspector.RemoteObjectImpl = function(target, objectId, type, subtype, value,
// Primitive or null object.
this._description = description || (value + "");
this._hasChildren = false;
- // Handle special numbers: NaN, Infinity, -Infinity, -0.
- if (type === "number" && typeof value !== "number")
- this.value = Number(value);
- else
+ if (typeof unserializableValue !== "undefined") {
+ this._unserializableValue = unserializableValue;
+ if (unserializableValue === RuntimeAgent.UnserializableValue.Infinity ||
+ unserializableValue === RuntimeAgent.UnserializableValue.NegativeInfinity ||
+ unserializableValue === RuntimeAgent.UnserializableValue.Negative0 ||
+ unserializableValue === RuntimeAgent.UnserializableValue.NaN) {
+ this.value = Number(unserializableValue);
+ } else {
+ this.value = unserializableValue;
+ }
+ } else {
this.value = value;
+ }
}
this._customPreview = customPreview || null;
}
@@ -915,12 +915,13 @@ WebInspector.RemoteObject.loadFromObjectPerProto = function(object, callback)
* @param {string} type
* @param {string|undefined} subtype
* @param {*} value
+ * @param {!RuntimeAgent.UnserializableValue=} unserializableValue
* @param {string=} description
* @param {!RuntimeAgent.ObjectPreview=} preview
*/
-WebInspector.ScopeRemoteObject = function(target, objectId, scopeRef, type, subtype, value, description, preview)
+WebInspector.ScopeRemoteObject = function(target, objectId, scopeRef, type, subtype, value, unserializableValue, description, preview)
{
- WebInspector.RemoteObjectImpl.call(this, target, objectId, type, subtype, value, description, preview);
+ WebInspector.RemoteObjectImpl.call(this, target, objectId, type, subtype, value, unserializableValue, description, preview);
this._scopeRef = scopeRef;
this._savedScopeProperties = undefined;
};

Powered by Google App Engine
This is Rietveld 408576698