3 <script src=
"../../../http/tests/inspector/inspector-test.js"></script>
4 <script src=
"../../../http/tests/inspector/debugger-test.js"></script>
6 <script> function firstLineFunction()
11 function notFirstLineFunction()
20 function functionWithDisplayName() {}
21 functionWithDisplayName
.displayName
= "user-friendly name";
23 function functionWithDisplayNameGetter() {}
24 functionWithDisplayNameGetter
.__defineGetter__("displayName", function() { return "FAIL_should_not_execute"; });
26 var smallClosure
= (function(p
) { return function() { return p
; }; })("Capybara");
28 var bigClosure
= (function(p
) {
32 get u() { return 3; },
40 return String(p
) + String(ex
) + u
+ e
;
48 function dumpFunctionDetails(details
)
50 InspectorTest
.addResult("Function details: ");
51 InspectorTest
.addResult("lineNumber: " + details
.location
.lineNumber
);
52 InspectorTest
.addResult("columnNumber: " + details
.location
.columnNumber
);
53 InspectorTest
.addResult("scriptId is valid: " + !!details
.location
.scriptId
);
54 InspectorTest
.addResult("functionName: " + details
.functionName
);
55 InspectorTest
.addResult("isGenerator: " + details
.isGenerator
);
58 function dumpFunctionNoScopes()
60 InspectorTest
.addResult("scopeChain: n/a");
63 function dumpFunctionScope(pos
, type
, propertyDescriptors
)
66 if (type
== "global") {
67 variables
= "<global object properties omitted>";
70 for (var i
= 0; i
< propertyDescriptors
.length
; i
++) {
71 var d
= propertyDescriptors
[i
];
75 valueStr
= JSON
.stringify(d
.value
.value
);
77 valueStr
= "<no string representation>";
79 valueStr
= "<no value>";
81 varArray
.push(d
.name
+ ": " + valueStr
);
84 variables
= varArray
.join();
86 InspectorTest
.addResult("scopeChain #" + pos
+ ": " + type
+ "; " + variables
);
89 function loadAndDumpScopeObjects(scopeChain
, end
)
91 function loadScopeObject(pos
, next
)
93 if (pos
>= scopeChain
.length
) {
97 var scopeJson
= scopeChain
[pos
];
98 InspectorTest
.RuntimeAgent
.getProperties(scopeJson
.object
.objectId
, true, didGetProperties
);
100 function didGetProperties(error
, propertyDescriptors
)
102 dumpFunctionScope(pos
, scopeJson
.type
, propertyDescriptors
);
103 loadScopeObject(pos
+ 1, next
);
108 loadScopeObject(0, end
);
110 dumpFunctionNoScopes();
115 function performStandardTestCase(pageExpression
, next
)
117 InspectorTest
.evaluateInPage(pageExpression
, didEvaluate
);
119 function didEvaluate(remote
)
121 InspectorTest
.addResult(pageExpression
+ " type = " + remote
.type
);
122 InspectorTest
.DebuggerAgent
.getFunctionDetails(remote
.objectId
, didGetDetails
);
124 function didGetDetails(error
, response
)
126 dumpFunctionDetails(response
);
127 loadAndDumpScopeObjects(response
.scopeChain
, next
);
131 InspectorTest
.runDebuggerTestSuite([
132 function testGetFirstLineFunctionDetails(next
)
134 performStandardTestCase("firstLineFunction", next
);
136 function testGetNonFirstLineFunctionDetails(next
)
138 performStandardTestCase("notFirstLineFunction", next
);
140 function testGetDetailsOfFunctionWithInferredName(next
)
142 performStandardTestCase("obj.m", next
);
144 function testGetDetailsOfFunctionWithDisplayName(next
)
146 performStandardTestCase("functionWithDisplayName", next
);
148 function testGetDetailsOfFunctionWithDisplayNameGetter(next
)
150 performStandardTestCase("functionWithDisplayNameGetter", next
);
152 function testSmallClosure(next
)
154 performStandardTestCase("smallClosure", next
);
156 function testBigClosure(next
)
158 performStandardTestCase("bigClosure", next
);
166 <body onload=
"runTest()">
167 <p>Tests that Debugger.getFunctionDetails command returns correct location.
168 <a href=
"https://bugs.webkit.org/show_bug.cgi?id=71808">Bug
71808</a>