OLD | NEW |
1 var initialize_DebuggerTest = function() { | 1 var initialize_DebuggerTest = function() { |
2 | 2 |
3 InspectorTest.startDebuggerTest = function(callback, quiet) | 3 InspectorTest.startDebuggerTest = function(callback, quiet) |
4 { | 4 { |
5 if (quiet !== undefined) | 5 if (quiet !== undefined) |
6 InspectorTest._quiet = quiet; | 6 InspectorTest._quiet = quiet; |
7 WebInspector.inspectorView.showPanel("sources"); | 7 WebInspector.inspectorView.showPanel("sources"); |
8 | 8 |
9 if (WebInspector.debuggerModel.debuggerEnabled()) | 9 if (WebInspector.debuggerModel.debuggerEnabled()) |
10 startTest(); | 10 startTest(); |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 InspectorTest._waitUntilResumedCallback = callback; | 145 InspectorTest._waitUntilResumedCallback = callback; |
146 }; | 146 }; |
147 | 147 |
148 InspectorTest.resumeExecution = function(callback) | 148 InspectorTest.resumeExecution = function(callback) |
149 { | 149 { |
150 if (WebInspector.panels.sources.paused) | 150 if (WebInspector.panels.sources.paused) |
151 WebInspector.panels.sources.togglePause(); | 151 WebInspector.panels.sources.togglePause(); |
152 InspectorTest.waitUntilResumed(callback); | 152 InspectorTest.waitUntilResumed(callback); |
153 }; | 153 }; |
154 | 154 |
| 155 InspectorTest.waitUntilPausedAndDumpStackAndResume = function(callback, options) |
| 156 { |
| 157 InspectorTest.waitUntilPaused(paused); |
| 158 InspectorTest.addSniffer(WebInspector.CallStackSidebarPane.prototype, "setSt
atus", setStatus); |
| 159 |
| 160 var caption; |
| 161 var callFrames; |
| 162 var asyncStackTrace; |
| 163 |
| 164 function setStatus(status) |
| 165 { |
| 166 if (typeof status === "string") |
| 167 caption = status; |
| 168 else |
| 169 caption = status.textContent; |
| 170 if (callFrames) |
| 171 step1(); |
| 172 } |
| 173 |
| 174 function paused(frames, reason, breakpointIds, async) |
| 175 { |
| 176 callFrames = frames; |
| 177 asyncStackTrace = async; |
| 178 if (typeof caption === "string") |
| 179 step1(); |
| 180 } |
| 181 |
| 182 function step1() |
| 183 { |
| 184 InspectorTest.captureStackTrace(callFrames, asyncStackTrace, options); |
| 185 InspectorTest.addResult(caption); |
| 186 InspectorTest.runAfterPendingDispatches(step2); |
| 187 } |
| 188 |
| 189 function step2() |
| 190 { |
| 191 InspectorTest.resumeExecution(InspectorTest.safeWrap(callback)); |
| 192 } |
| 193 }; |
| 194 |
155 InspectorTest.captureStackTrace = function(callFrames, asyncStackTrace, options) | 195 InspectorTest.captureStackTrace = function(callFrames, asyncStackTrace, options) |
156 { | 196 { |
157 InspectorTest.addResult(InspectorTest.captureStackTraceIntoString(callFrames
, asyncStackTrace, options)); | 197 InspectorTest.addResult(InspectorTest.captureStackTraceIntoString(callFrames
, asyncStackTrace, options)); |
158 }; | 198 }; |
159 | 199 |
160 InspectorTest.captureStackTraceIntoString = function(callFrames, asyncStackTrace
, options) | 200 InspectorTest.captureStackTraceIntoString = function(callFrames, asyncStackTrace
, options) |
161 { | 201 { |
162 var results = []; | 202 var results = []; |
163 options = options || {}; | 203 options = options || {}; |
164 | 204 |
165 function printCallFrames(callFrames) | 205 function printCallFrames(callFrames) |
166 { | 206 { |
| 207 var printed = 0; |
167 for (var i = 0; i < callFrames.length; i++) { | 208 for (var i = 0; i < callFrames.length; i++) { |
168 var frame = callFrames[i]; | 209 var frame = callFrames[i]; |
169 var script = WebInspector.debuggerModel.scriptForId(frame.location()
.scriptId); | 210 var script = WebInspector.debuggerModel.scriptForId(frame.location()
.scriptId); |
| 211 var isFramework = script.isFramework(); |
| 212 if (options.dropFrameworkCallFrames && isFramework) |
| 213 continue; |
170 var url; | 214 var url; |
171 var lineNumber; | 215 var lineNumber; |
172 if (script) { | 216 if (script) { |
173 url = WebInspector.displayNameForURL(script.sourceURL); | 217 url = WebInspector.displayNameForURL(script.sourceURL); |
174 lineNumber = frame.location().lineNumber + 1; | 218 lineNumber = frame.location().lineNumber + 1; |
175 } else { | 219 } else { |
176 url = "(internal script)"; | 220 url = "(internal script)"; |
177 lineNumber = "(line number)"; | 221 lineNumber = "(line number)"; |
178 } | 222 } |
179 var s = " " + i + ") " + frame.functionName + " (" + url + (optio
ns.dropLineNumbers ? "" : ":" + lineNumber) + ")"; | 223 var s = (isFramework ? " * " : " ") + (printed++) + ") " + frame
.functionName + " (" + url + (options.dropLineNumbers ? "" : ":" + lineNumber) +
")"; |
180 results.push(s); | 224 results.push(s); |
181 if (options.printReturnValue && frame.returnValue()) | 225 if (options.printReturnValue && frame.returnValue()) |
182 results.push(" <return>: " + frame.returnValue().descripti
on); | 226 results.push(" <return>: " + frame.returnValue().descripti
on); |
183 } | 227 } |
| 228 return printed; |
184 } | 229 } |
185 | 230 |
186 results.push("Call stack:"); | 231 results.push("Call stack:"); |
187 printCallFrames(callFrames); | 232 printCallFrames(callFrames); |
188 | 233 |
189 while (asyncStackTrace) { | 234 while (asyncStackTrace) { |
190 results.push(" [" + (asyncStackTrace.description || "Async Call") + "
]"); | 235 results.push(" [" + (asyncStackTrace.description || "Async Call") + "
]"); |
191 printCallFrames(WebInspector.DebuggerModel.CallFrame.fromPayloadArray(We
bInspector.targetManager.activeTarget(), asyncStackTrace.callFrames)); | 236 var printed = printCallFrames(WebInspector.DebuggerModel.CallFrame.fromP
ayloadArray(WebInspector.targetManager.activeTarget(), asyncStackTrace.callFrame
s)); |
| 237 if (!printed) |
| 238 results.pop(); |
192 if (asyncStackTrace.callFrames.peekLast().functionName === "testFunction
") | 239 if (asyncStackTrace.callFrames.peekLast().functionName === "testFunction
") |
193 break; | 240 break; |
194 asyncStackTrace = asyncStackTrace.asyncStackTrace; | 241 asyncStackTrace = asyncStackTrace.asyncStackTrace; |
195 } | 242 } |
196 return results.join("\n"); | 243 return results.join("\n"); |
197 }; | 244 }; |
198 | 245 |
199 InspectorTest.dumpSourceFrameContents = function(sourceFrame) | 246 InspectorTest.dumpSourceFrameContents = function(sourceFrame) |
200 { | 247 { |
201 InspectorTest.addResult("==Source frame contents start=="); | 248 InspectorTest.addResult("==Source frame contents start=="); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 InspectorTest.scriptFormatter = function() | 441 InspectorTest.scriptFormatter = function() |
395 { | 442 { |
396 var editorActions = WebInspector.moduleManager.instances(WebInspector.Source
sView.EditorAction); | 443 var editorActions = WebInspector.moduleManager.instances(WebInspector.Source
sView.EditorAction); |
397 for (var i = 0; i < editorActions.length; ++i) { | 444 for (var i = 0; i < editorActions.length; ++i) { |
398 if (editorActions[i] instanceof WebInspector.ScriptFormatterEditorAction
) | 445 if (editorActions[i] instanceof WebInspector.ScriptFormatterEditorAction
) |
399 return editorActions[i]; | 446 return editorActions[i]; |
400 } | 447 } |
401 }; | 448 }; |
402 | 449 |
403 }; | 450 }; |
OLD | NEW |