DevTools: support getters and setters in javascript outline

BUG=339798
R=vsevik, apavlov

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

git-svn-id: svn://svn.chromium.org/blink/trunk@180469 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 4804531b
...@@ -38,6 +38,36 @@ Tests the script outline extraction functionality. ...@@ -38,6 +38,36 @@ Tests the script outline extraction functionality.
line : 9 line : 9
name : "innerFunction2" name : "innerFunction2"
} }
{
arguments : "(name)"
column : 13
line : 14
name : "Cat"
}
{
arguments : "()"
column : 9
line : 20
name : "mew"
}
{
arguments : "()"
column : 8
line : 25
name : "get name"
}
{
arguments : "()"
column : 10
line : 30
name : "feed"
}
{
arguments : "(newName)"
column : 8
line : 35
name : "set name"
}
] ]
index : 1 index : 1
total : 1 total : 1
......
...@@ -3,12 +3,59 @@ ...@@ -3,12 +3,59 @@
<script src="../../../http/tests/inspector/inspector-test.js"></script> <script src="../../../http/tests/inspector/inspector-test.js"></script>
<script src="resources/obfuscated.js"></script> <script src="resources/obfuscated.js"></script>
<script id="outline">function first(x,y) { }
var second = function(y
,
z) { }
Object = function(arg) {
}
Object.prototype.functionOnPrototype = function ( a, b ,
c, d ,
e , f ) { function innerFunction1() {
var innerFunction2 = function(arg1,arg2) {} } }
/**
* @constructor
* @param {string} name
*/
window.Cat = function(name)
{
this._name = name;
}
window.Cat.prototype = {
mew: function()
{
console.log("Mew!");
},
get name()
{
return this._name;
},
feed: function()
{
// noop
},
set name(newName)
{
this._name = newName;
}
};
</script>
<script> <script>
var test = function() function getScriptText()
{ {
return document.querySelector("#outline").textContent;
}
function test()
{
var worker = Runtime.startWorker("script_formatter_worker"); var worker = Runtime.startWorker("script_formatter_worker");
var parsedScript = "function first(x,y) { }\n var second = function(y \n , \nz) { }\n Object = function(arg) {\n}\n Object.prototype.functionOnPrototype = function ( a, b , \n c, d , \n e , f ) { function innerFunction1() {\n var innerFunction2 = function(arg1,arg2) {} } }";
worker.onmessage = InspectorTest.safeWrap(function(event) worker.onmessage = InspectorTest.safeWrap(function(event)
{ {
...@@ -22,7 +69,11 @@ var test = function() ...@@ -22,7 +69,11 @@ var test = function()
InspectorTest.completeTest(); InspectorTest.completeTest();
}; };
worker.postMessage({ method: "javaScriptOutline", params: { content: parsedScript } }); InspectorTest.evaluateInPage("getScriptText()", onScriptText);
function onScriptText(result)
{
worker.postMessage({ method: "javaScriptOutline", params: { content: result.value } });
}
} }
</script> </script>
......
...@@ -143,7 +143,11 @@ FormatterWorker.javaScriptOutline = function(params) ...@@ -143,7 +143,11 @@ FormatterWorker.javaScriptOutline = function(params)
*/ */
function processToken(tokenValue, tokenType, column, newColumn) function processToken(tokenValue, tokenType, column, newColumn)
{ {
if (isJavaScriptIdentifier(tokenType)) { if (tokenType === "property" && previousTokenType === "property" && (previousToken === "get" || previousToken === "set")) {
currentFunction = { line: i, column: column, name: previousToken + " " + tokenValue };
addedFunction = true;
previousIdentifier = null;
} else if (isJavaScriptIdentifier(tokenType)) {
previousIdentifier = tokenValue; previousIdentifier = tokenValue;
if (tokenValue && previousToken === "function") { if (tokenValue && previousToken === "function") {
// A named function: "function f...". // A named function: "function f...".
......
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