DevTools: fix pretty-print of anonymous functions passed as call parameters

BUG=520742
NOTRY=true

Review URL: https://codereview.chromium.org/1312033002

git-svn-id: svn://svn.chromium.org/blink/trunk@201111 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 331ee13c
...@@ -68,3 +68,15 @@ Correct mapping for <person> ...@@ -68,3 +68,15 @@ Correct mapping for <person>
Correct mapping for <name> Correct mapping for <name>
Correct mapping for <}> Correct mapping for <}>
Running: anonimousFunctionAsParameter
====== 8< ------
setTimeout(function() {
alert(1);
}, 2000);
------ >8 ======
Correct mapping for <setTimeout>
Correct mapping for <function>
Correct mapping for <alert>
Correct mapping for <2000>
...@@ -40,6 +40,12 @@ function test() ...@@ -40,6 +40,12 @@ function test()
{ {
var mappingQueries = ["for", "person", "name", "}"]; var mappingQueries = ["for", "person", "name", "}"];
testJSFormatter("for(var i=0;i<names.length;++i){let name=names[i];let person=persons[i];}", mappingQueries, next); testJSFormatter("for(var i=0;i<names.length;++i){let name=names[i];let person=persons[i];}", mappingQueries, next);
},
function anonimousFunctionAsParameter(next)
{
var mappingQueries = ["setTimeout", "function", "alert", "2000"];
testJSFormatter("setTimeout(function(){alert(1);},2000);", mappingQueries, next);
} }
]); ]);
} }
......
...@@ -268,6 +268,8 @@ FormatterWorker.JavaScriptFormatter.prototype = { ...@@ -268,6 +268,8 @@ FormatterWorker.JavaScriptFormatter.prototype = {
return ""; return "";
if (node.parent && node.parent.type === "FunctionExpression" && node.parent.parent && node.parent.parent.type === "Property") if (node.parent && node.parent.type === "FunctionExpression" && node.parent.parent && node.parent.parent.type === "Property")
return ""; return "";
if (node.parent && node.parent.type === "FunctionExpression" && node.parent.parent && node.parent.parent.type === "CallExpression")
return "";
if (node.parent && node.parent.type === "DoWhileStatement") if (node.parent && node.parent.type === "DoWhileStatement")
return ""; return "";
if (node.parent && node.parent.type === "TryStatement" && node.parent.block == node) if (node.parent && node.parent.type === "TryStatement" && node.parent.block == node)
......
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