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);
57 function dumpFunctionNoScopes()
59 InspectorTest.addResult("scopeChain: n/a");
62 function dumpFunctionScope(pos, type, propertyDescriptors)
65 if (type == "global") {
66 variables = "<global object properties omitted>";
69 for (var i = 0; i < propertyDescriptors.length; i++) {
70 var d = propertyDescriptors[i];
74 valueStr = JSON.stringify(d.value.value);
76 valueStr = "<no string representation>";
78 valueStr = "<no value>";
80 varArray.push(d.name + ": " + valueStr);
83 variables = varArray.join();
85 InspectorTest.addResult("scopeChain #" + pos + ": " + type + "; " + variables);
88 function loadAndDumpScopeObjects(scopeChain, end) {
89 function loadScopeObject(pos, next) {
90 if (pos >= scopeChain.length) {
94 var scopeJson = scopeChain[pos];
95 RuntimeAgent.getProperties(scopeJson.object.objectId, true, didGetProperties);
97 function didGetProperties(error, propertyDescriptors) {
98 dumpFunctionScope(pos, scopeJson.type, propertyDescriptors);
99 loadScopeObject(pos + 1, next);
104 loadScopeObject(0, end);
106 dumpFunctionNoScopes();
111 function performStandardTestCase(pageExpression, next) {
112 InspectorTest.evaluateInPage(pageExpression, didEvaluate);
114 function didEvaluate(remote)
116 InspectorTest.addResult(pageExpression + " type = " + remote.type);
117 DebuggerAgent.getFunctionDetails(remote.objectId, didGetDetails);
119 function didGetDetails(error, response)
121 dumpFunctionDetails(response);
122 loadAndDumpScopeObjects(response.scopeChain, next);
126 InspectorTest.runDebuggerTestSuite([
127 function testGetFirstLineFunctionDetails(next)
129 performStandardTestCase("firstLineFunction", next);
131 function testGetNonFirstLineFunctionDetails(next)
133 performStandardTestCase("notFirstLineFunction", next);
135 function testGetDetailsOfFunctionWithInferredName(next)
137 performStandardTestCase("obj.m", next);
139 function testGetDetailsOfFunctionWithDisplayName(next)
141 performStandardTestCase("functionWithDisplayName", next);
143 function testGetDetailsOfFunctionWithDisplayNameGetter(next)
145 performStandardTestCase("functionWithDisplayNameGetter", next);
147 function testSmallClosure(next)
149 performStandardTestCase("smallClosure", next);
151 function testBigClosure(next)
153 performStandardTestCase("bigClosure", next);
162 <body onload="runTest()">
163 <p>Tests that Debugger.getFunctionDetails command returns correct location.
164 <a href="https://bugs.webkit.org/show_bug.cgi?id=71808">Bug 71808</a>