Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / inspector / sources / debugger-ui / function-details.html
blob10d9760378fbf64ee81b8d7d271c05d8c08de3fc
1 <html>
2 <head>
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()
16 var obj = {
17 m: function() {}
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) {
29 var o = {
30 e: 7,
31 f: 5,
32 get u() { return 3; },
33 set v(value) { }
35 with (o) {
36 try {
37 throw Error("Test");
38 } catch (ex) {
39 return function() {
40 return String(p) + String(ex) + u + e;
44 })({});
46 function test()
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)
65 var variables;
66 if (type == "global") {
67 variables = "<global object properties omitted>";
68 } else {
69 var varArray = [];
70 for (var i = 0; i < propertyDescriptors.length; i++) {
71 var d = propertyDescriptors[i];
72 var valueStr;
73 if (d.value) {
74 if (d.value.value)
75 valueStr = JSON.stringify(d.value.value);
76 else
77 valueStr = "<no string representation>";
78 } else {
79 valueStr = "<no value>";
81 varArray.push(d.name + ": " + valueStr);
83 varArray.sort();
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) {
94 next();
95 return;
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);
107 if (scopeChain) {
108 loadScopeObject(0, end);
109 } else {
110 dumpFunctionNoScopes();
111 end();
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);
163 </script>
164 </head>
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>
169 </p>
170 </body>
171 </html>