Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/WebKit/LayoutTests/inspector/sources/debugger-ui/function-details.html

Issue 2122423002: [DevTools] Remove functionDetails from protocol.json (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@remove-generator-details-from-protocol
Patch Set: a Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <html> 1 <html>
2 <head> 2 <head>
3 <script src="../../../http/tests/inspector/inspector-test.js"></script> 3 <script src="../../../http/tests/inspector/inspector-test.js"></script>
4 <script src="../../../http/tests/inspector/debugger-test.js"></script> 4 <script src="../../../http/tests/inspector/debugger-test.js"></script>
5 5
6 <script> function firstLineFunction() 6 <script> function firstLineFunction()
7 7
8 { 8 {
9 } 9 }
10 10
(...skipping 25 matching lines...) Expand all
36 try { 36 try {
37 throw Error("Test"); 37 throw Error("Test");
38 } catch (ex) { 38 } catch (ex) {
39 return function() { 39 return function() {
40 return String(p) + String(ex) + u + e; 40 return String(p) + String(ex) + u + e;
41 }; 41 };
42 } 42 }
43 } 43 }
44 })({}); 44 })({});
45 45
46 function* gen() { yield [1,2,3] }
47
46 function test() 48 function test()
47 { 49 {
48 function dumpFunctionDetails(details) 50 function dumpFunctionDetails(properties)
49 { 51 {
52 var location = properties.get("[[FunctionLocation]]").value.value;
50 InspectorTest.addResult("Function details: "); 53 InspectorTest.addResult("Function details: ");
51 InspectorTest.addResult("lineNumber: " + details.location.lineNumber); 54 InspectorTest.addResult("lineNumber: " + location.lineNumber);
52 InspectorTest.addResult("columnNumber: " + details.location.columnNumber ); 55 InspectorTest.addResult("columnNumber: " + location.columnNumber);
53 InspectorTest.addResult("scriptId is valid: " + !!details.location.scrip tId); 56 InspectorTest.addResult("scriptId is valid: " + !!location.scriptId);
54 InspectorTest.addResult("functionName: " + details.functionName); 57 InspectorTest.addResult("functionName: " + properties.get("name").value. value);
55 InspectorTest.addResult("isGenerator: " + details.isGenerator); 58 if (properties.has("[[IsGenerator]]"))
59 InspectorTest.addResult("isGenerator: " + properties.get("[[IsGenera tor]]").value.value);
56 } 60 }
57 61
58 function dumpFunctionNoScopes() 62 function dumpFunctionNoScopes()
59 { 63 {
60 InspectorTest.addResult("scopeChain: n/a"); 64 InspectorTest.addResult("scopeChain: n/a");
61 } 65 }
62 66
63 function dumpFunctionScope(pos, type, propertyDescriptors) 67 function dumpFunctionScope(pos, type, propertyDescriptors)
64 { 68 {
65 var variables; 69 var variables;
66 if (type == "global") { 70 if (type == "Global") {
67 variables = "<global object properties omitted>"; 71 variables = "<global object properties omitted>";
68 } else { 72 } else {
69 var varArray = []; 73 var varArray = [];
70 for (var i = 0; i < propertyDescriptors.length; i++) { 74 for (var i = 0; i < propertyDescriptors.length; i++) {
71 var d = propertyDescriptors[i]; 75 var d = propertyDescriptors[i];
72 var valueStr; 76 var valueStr;
73 if (d.value) { 77 if (d.value) {
74 if (d.value.value) 78 if (d.value.value)
75 valueStr = JSON.stringify(d.value.value); 79 valueStr = JSON.stringify(d.value.value);
76 else 80 else
77 valueStr = "<no string representation>"; 81 valueStr = "<no string representation>";
78 } else { 82 } else {
79 valueStr = "<no value>"; 83 valueStr = "<no value>";
80 } 84 }
81 varArray.push(d.name + ": " + valueStr); 85 varArray.push(d.name + ": " + valueStr);
82 } 86 }
83 varArray.sort(); 87 varArray.sort();
84 variables = varArray.join(); 88 variables = varArray.join();
85 } 89 }
86 InspectorTest.addResult("scopeChain #" + pos + ": " + type + "; " + vari ables); 90 InspectorTest.addResult("scopeChain #" + pos + ": " + type + "; " + vari ables);
87 } 91 }
88 92
89 function loadAndDumpScopeObjects(scopeChain, end) 93 function loadAndDumpScopeObjects(scopeChain, end)
90 { 94 {
95 var scopes = [];
91 function loadScopeObject(pos, next) 96 function loadScopeObject(pos, next)
92 { 97 {
93 if (pos >= scopeChain.length) { 98 if (pos >= scopes.length) {
94 next(); 99 next();
95 return; 100 return;
96 } 101 }
97 var scopeJson = scopeChain[pos]; 102 InspectorTest.RuntimeAgent.getProperties(scopes[pos].objectId, true, didGetProperties);
98 InspectorTest.RuntimeAgent.getProperties(scopeJson.object.objectId, true, didGetProperties);
99 103
100 function didGetProperties(error, propertyDescriptors) 104 function didGetProperties(error, propertyDescriptors)
101 { 105 {
102 dumpFunctionScope(pos, scopeJson.type, propertyDescriptors); 106 dumpFunctionScope(pos, scopes[pos].description, propertyDescript ors);
103 loadScopeObject(pos + 1, next); 107 loadScopeObject(pos + 1, next);
104 } 108 }
105 } 109 }
106 110
107 if (scopeChain) { 111 if (scopeChain) {
108 loadScopeObject(0, end); 112 InspectorTest.RuntimeAgent.getProperties(scopeChain.value.objectId, true, didGetScopes);
109 } else { 113 } else {
110 dumpFunctionNoScopes(); 114 dumpFunctionNoScopes();
111 end(); 115 end();
112 } 116 }
117
118 function didGetScopes(error, properties)
119 {
120 for (var prop of properties) {
121 if (String(prop.name >>> 0) === prop.name)
122 scopes.push(prop.value);
123 }
124 loadScopeObject(0, end);
125 }
113 } 126 }
114 127
115 function performStandardTestCase(pageExpression, next) 128 function performStandardTestCase(pageExpression, next)
116 { 129 {
117 InspectorTest.evaluateInPage(pageExpression, didEvaluate); 130 InspectorTest.evaluateInPage(pageExpression, didEvaluate);
118 131
119 function didEvaluate(remote) 132 function didEvaluate(remote)
120 { 133 {
121 InspectorTest.addResult(pageExpression + " type = " + remote.type); 134 InspectorTest.addResult(pageExpression + " type = " + remote.type);
122 InspectorTest.DebuggerAgent.getFunctionDetails(remote.objectId, didG etDetails); 135 InspectorTest.RuntimeAgent.getProperties(remote.objectId, /* isOwnPr operty */ false, didGetDetails);
123 } 136 }
124 function didGetDetails(error, response) 137 function didGetDetails(error, properties, internalProperties)
125 { 138 {
126 dumpFunctionDetails(response); 139 var propertiesMap = new Map();
127 loadAndDumpScopeObjects(response.scopeChain, next); 140 for (var prop of internalProperties)
141 propertiesMap.set(prop.name, prop);
142 for (var prop of properties) {
143 if (prop.name === "name" && prop.value && prop.value.type === "s tring")
144 propertiesMap.set("name", prop);
145 if (prop.name === "displayName" && prop.value && prop.value.type === "string") {
146 propertiesMap.set("name", prop);
147 break;
148 }
149 }
150 dumpFunctionDetails(propertiesMap);
151 loadAndDumpScopeObjects(propertiesMap.get("[[Scopes]]"), next);
128 } 152 }
129 } 153 }
130 154
131 InspectorTest.runDebuggerTestSuite([ 155 InspectorTest.runDebuggerTestSuite([
132 function testGetFirstLineFunctionDetails(next) 156 function testGetFirstLineFunctionDetails(next)
133 { 157 {
134 performStandardTestCase("firstLineFunction", next); 158 performStandardTestCase("firstLineFunction", next);
135 }, 159 },
136 function testGetNonFirstLineFunctionDetails(next) 160 function testGetNonFirstLineFunctionDetails(next)
137 { 161 {
(...skipping 11 matching lines...) Expand all
149 { 173 {
150 performStandardTestCase("functionWithDisplayNameGetter", next); 174 performStandardTestCase("functionWithDisplayNameGetter", next);
151 }, 175 },
152 function testSmallClosure(next) 176 function testSmallClosure(next)
153 { 177 {
154 performStandardTestCase("smallClosure", next); 178 performStandardTestCase("smallClosure", next);
155 }, 179 },
156 function testBigClosure(next) 180 function testBigClosure(next)
157 { 181 {
158 performStandardTestCase("bigClosure", next); 182 performStandardTestCase("bigClosure", next);
183 },
184 function testGenFunction(next)
185 {
186 performStandardTestCase("gen", next);
159 } 187 }
160 ]); 188 ]);
161 }; 189 };
162 190
163 </script> 191 </script>
164 </head> 192 </head>
165 193
166 <body onload="runTest()"> 194 <body onload="runTest()">
167 <p>Tests that Debugger.getFunctionDetails command returns correct location. 195 <p>Tests that Debugger.getFunctionDetails command returns correct location.
168 <a href="https://bugs.webkit.org/show_bug.cgi?id=71808">Bug 71808</a> 196 <a href="https://bugs.webkit.org/show_bug.cgi?id=71808">Bug 71808</a>
169 </p> 197 </p>
170 </body> 198 </body>
171 </html> 199 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698