Commit a44f5f8f authored by eric@webkit.org's avatar eric@webkit.org

2009-09-18 Yury Semikhatsky <yurys@chromium.org>

        Reviewed by Timothy Hatcher.

        Fix parameter substitutions in console.log().

        https://bugs.webkit.org/show_bug.cgi?id=29366

        * inspector/front-end/ConsoleView.js:
        (WebInspector.ConsoleMessage.prototype._format):
        * inspector/front-end/InjectedScript.js:
        (InjectedScript.getPrototypes):
        (InjectedScript.CallFrameProxy.prototype._wrapScopeChain):
        * inspector/front-end/utilities.js:
        ():

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@48536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 9764d3a4
2009-09-18 Yury Semikhatsky <yurys@chromium.org>
Reviewed by Timothy Hatcher.
Fix parameter substitutions in console.log().
https://bugs.webkit.org/show_bug.cgi?id=29366
* inspector/front-end/ConsoleView.js:
(WebInspector.ConsoleMessage.prototype._format):
* inspector/front-end/InjectedScript.js:
(InjectedScript.getPrototypes):
(InjectedScript.CallFrameProxy.prototype._wrapScopeChain):
* inspector/front-end/utilities.js:
():
2009-09-18 Sam Weinig <sam@webkit.org>
Reviewed by Geoffrey Garen and Brady Eidson.
......@@ -639,7 +639,7 @@ WebInspector.ConsoleMessage.prototype = {
return WebInspector.console._format(obj, true);
}
if (typeof parameters[0] === "string") {
if (Object.proxyType(parameters[0]) === "string") {
var formatters = {}
for (var i in String.standardFormatters)
formatters[i] = String.standardFormatters[i];
......@@ -660,7 +660,7 @@ WebInspector.ConsoleMessage.prototype = {
return a;
}
var result = String.format(parameters[0], parameters.slice(1), formatters, formattedResult, append);
var result = String.format(parameters[0].description, parameters.slice(1), formatters, formattedResult, append);
formattedResult = result.formattedResult;
parameters = result.unusedSubstitutions;
if (parameters.length)
......
......@@ -421,7 +421,7 @@ InjectedScript.getPrototypes = function(nodeId)
var result = [];
for (var prototype = node; prototype; prototype = prototype.__proto__) {
var title = Object.describe(prototype);
var title = Object.describe(prototype, true);
if (title.match(/Prototype$/)) {
title = title.replace(/Prototype$/, "");
}
......@@ -999,11 +999,11 @@ InjectedScript.CallFrameProxy.prototype = {
var scopeChainProxy = [];
for (var i = 0; i < scopeChain.length; ++i) {
var scopeObject = scopeChain[i];
var scopeObjectProxy = InjectedScript.createProxyObject(scopeObject, { callFrame: this.id, chainIndex: i });
var scopeObjectProxy = InjectedScript.createProxyObject(scopeObject, { callFrame: this.id, chainIndex: i }, true);
if (Object.prototype.toString.call(scopeObject) === "[object JSActivation]") {
if (!foundLocalScope)
scopeObjectProxy.thisObject = InjectedScript.createProxyObject(callFrame.thisObject, { callFrame: this.id, thisObject: true });
scopeObjectProxy.thisObject = InjectedScript.createProxyObject(callFrame.thisObject, { callFrame: this.id, thisObject: true }, true);
else
scopeObjectProxy.isClosure = true;
foundLocalScope = true;
......@@ -1077,6 +1077,8 @@ Object.describe = function(obj, abbreviated)
case "array":
return "[" + obj.toString() + "]";
case "string":
if (!abbreviated)
return obj;
if (obj.length > 100)
return "\"" + obj.substring(0, 100) + "\u2026\"";
return "\"" + obj + "\"";
......@@ -1089,6 +1091,10 @@ Object.describe = function(obj, abbreviated)
return objectText;
case "regexp":
return String(obj).replace(/([\\\/])/g, "\\$1").replace(/\\(\/[gim]*)$/, "$1").substring(1);
case "boolean":
case "number":
case "null":
return obj;
default:
return String(obj);
}
......
......@@ -814,12 +814,16 @@ String.tokenizeFormatString = function(format)
String.standardFormatters = {
d: function(substitution)
{
if (typeof substitution == "object" && Object.proxyType(substitution) === "number")
substitution = substitution.description;
substitution = parseInt(substitution);
return !isNaN(substitution) ? substitution : 0;
},
f: function(substitution, token)
{
if (typeof substitution == "object" && Object.proxyType(substitution) === "number")
substitution = substitution.description;
substitution = parseFloat(substitution);
if (substitution && token.precision > -1)
substitution = substitution.toFixed(token.precision);
......@@ -828,6 +832,8 @@ String.standardFormatters = {
s: function(substitution)
{
if (typeof substitution == "object" && Object.proxyType(substitution) !== "null")
substitution = substitution.description;
return substitution;
},
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment