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

Unified Diff: Source/core/inspector/InjectedScriptSource.js

Issue 82553008: DevTools: Show -0 for negative zero in console. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 7 years, 1 month 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
« no previous file with comments | « LayoutTests/inspector/debugger/debugger-expand-scope-expected.txt ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/inspector/InjectedScriptSource.js
diff --git a/Source/core/inspector/InjectedScriptSource.js b/Source/core/inspector/InjectedScriptSource.js
index 408f5a2066dfa0311240aea9ec4c52ab90d9c72e..a5a3aaec95e1447bfef1883cf649815a14e90100 100644
--- a/Source/core/inspector/InjectedScriptSource.js
+++ b/Source/core/inspector/InjectedScriptSource.js
@@ -64,6 +64,17 @@ function toString(obj)
}
/**
+ * @param {*} obj
+ * @return {string}
+ */
+function toStringDescription(obj)
+{
+ if (typeof obj === "number" && obj === 0 && 1 / obj < 0)
+ return "-0"; // Negative zero.
+ return "" + obj;
+}
+
+/**
* Please use this bind, not the one from Function.prototype
* @param {function(...)} func
* @param {Object} thisObject
@@ -539,10 +550,10 @@ InjectedScript.prototype = {
throw "Could not find object with given id";
return resolvedArg;
- } else if ("value" in callArgumentJson)
+ } else if ("value" in callArgumentJson) {
return callArgumentJson.value;
- else
- return undefined;
+ }
+ return undefined;
},
/**
@@ -574,10 +585,9 @@ InjectedScript.prototype = {
{
var remoteObject = this._wrapObject(value, objectGroup);
try {
- remoteObject.description = toString(value);
+ remoteObject.description = toStringDescription(value);
} catch (e) {}
- return { wasThrown: true,
- result: remoteObject };
+ return { wasThrown: true, result: remoteObject };
},
/**
@@ -931,7 +941,7 @@ InjectedScript.RemoteObject = function(object, objectGroupName, forceValueType,
// Provide user-friendly number values.
if (this.type === "number")
- this.description = toString(object);
+ this.description = toStringDescription(object);
return;
}
@@ -1031,7 +1041,7 @@ InjectedScript.RemoteObject.prototype = {
value = this._abbreviateString(value, maxLength, true);
preview.lossless = false;
}
- this._appendPropertyPreview(preview, { name: name, type: type, value: toString(value) }, propertiesThreshold);
+ this._appendPropertyPreview(preview, { name: name, type: type, value: toStringDescription(value) }, propertiesThreshold);
continue;
}
« no previous file with comments | « LayoutTests/inspector/debugger/debugger-expand-scope-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698