Chromium Code Reviews| 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.showPanel("sources"); | 7 WebInspector.showPanel("sources"); |
| 8 | 8 |
| 9 if (WebInspector.debuggerModel.debuggerEnabled()) | 9 if (WebInspector.debuggerModel.debuggerEnabled()) |
| 10 startTest(); | 10 startTest(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 InspectorTest.evaluateInConsole("setTimeout(testFunction, 0)"); | 76 InspectorTest.evaluateInConsole("setTimeout(testFunction, 0)"); |
| 77 InspectorTest.addResult("Set timer for test function."); | 77 InspectorTest.addResult("Set timer for test function."); |
| 78 }; | 78 }; |
| 79 | 79 |
| 80 InspectorTest.runTestFunctionAndWaitUntilPaused = function(callback) | 80 InspectorTest.runTestFunctionAndWaitUntilPaused = function(callback) |
| 81 { | 81 { |
| 82 InspectorTest.runTestFunction(); | 82 InspectorTest.runTestFunction(); |
| 83 InspectorTest.waitUntilPaused(callback); | 83 InspectorTest.waitUntilPaused(callback); |
| 84 }; | 84 }; |
| 85 | 85 |
| 86 InspectorTest.runAsyncCallStacksTest = function(totalDebuggerStatements, maxAsyn cCallStackDepth) | |
| 87 { | |
| 88 InspectorTest.setQuiet(true); | |
| 89 InspectorTest.startDebuggerTest(step1); | |
| 90 | |
| 91 function step1() | |
| 92 { | |
| 93 DebuggerAgent.setAsyncCallStackDepth(maxAsyncCallStackDepth, step2); | |
| 94 } | |
| 95 | |
| 96 function step2() | |
| 97 { | |
| 98 InspectorTest.runTestFunctionAndWaitUntilPaused(didPaused); | |
| 99 } | |
| 100 | |
| 101 var step = 0; | |
| 102 var callStacksOutput = []; | |
| 103 function didPaused(callFrames, reason, breakpointIds, asyncStackTrace) | |
| 104 { | |
| 105 ++step; | |
| 106 callStacksOutput.push(InspectorTest.captureStackTraceIntoString(callFram es, asyncStackTrace) + "\n"); | |
| 107 if (step < totalDebuggerStatements) { | |
| 108 InspectorTest.resumeExecution(InspectorTest.waitUntilPaused.bind(Ins pectorTest, didPaused)); | |
| 109 } else { | |
| 110 InspectorTest.addResult("Captured call stacks in no particular order :"); | |
| 111 callStacksOutput.sort(); | |
| 112 InspectorTest.addResults(callStacksOutput); | |
| 113 InspectorTest.completeDebuggerTest(); | |
| 114 } | |
| 115 } | |
| 116 }; | |
| 117 | |
| 86 InspectorTest.waitUntilPausedNextTime = function(callback) | 118 InspectorTest.waitUntilPausedNextTime = function(callback) |
| 87 { | 119 { |
| 88 InspectorTest._waitUntilPausedCallback = InspectorTest.safeWrap(callback); | 120 InspectorTest._waitUntilPausedCallback = InspectorTest.safeWrap(callback); |
| 89 }; | 121 }; |
| 90 | 122 |
| 91 InspectorTest.waitUntilPaused = function(callback) | 123 InspectorTest.waitUntilPaused = function(callback) |
| 92 { | 124 { |
| 93 callback = InspectorTest.safeWrap(callback); | 125 callback = InspectorTest.safeWrap(callback); |
| 94 | 126 |
| 95 if (InspectorTest._pausedScriptArguments) | 127 if (InspectorTest._pausedScriptArguments) |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 115 | 147 |
| 116 InspectorTest.resumeExecution = function(callback) | 148 InspectorTest.resumeExecution = function(callback) |
| 117 { | 149 { |
| 118 if (WebInspector.panels.sources.paused) | 150 if (WebInspector.panels.sources.paused) |
| 119 WebInspector.panels.sources._togglePause(); | 151 WebInspector.panels.sources._togglePause(); |
| 120 InspectorTest.waitUntilResumed(callback); | 152 InspectorTest.waitUntilResumed(callback); |
| 121 }; | 153 }; |
| 122 | 154 |
| 123 InspectorTest.captureStackTrace = function(callFrames, asyncStackTrace, options) | 155 InspectorTest.captureStackTrace = function(callFrames, asyncStackTrace, options) |
| 124 { | 156 { |
| 157 InspectorTest.addResult(InspectorTest.captureStackTraceIntoString(callFrames , asyncStackTrace, options)); | |
| 158 }; | |
| 159 | |
| 160 InspectorTest.captureStackTraceIntoString = function(callFrames, asyncStackTrace , options) | |
|
yurys
2013/12/23 12:40:31
Consider making it private.
aandrey
2013/12/23 13:01:29
I call it directly from the new test.
| |
| 161 { | |
| 162 var results = []; | |
| 125 options = options || {}; | 163 options = options || {}; |
| 126 | 164 |
| 127 function printCallFrames(callFrames) | 165 function printCallFrames(callFrames) |
| 128 { | 166 { |
| 129 for (var i = 0; i < callFrames.length; i++) { | 167 for (var i = 0; i < callFrames.length; i++) { |
| 130 var frame = callFrames[i]; | 168 var frame = callFrames[i]; |
| 131 var script = WebInspector.debuggerModel.scriptForId(frame.location.s criptId); | 169 var script = WebInspector.debuggerModel.scriptForId(frame.location.s criptId); |
| 132 var url; | 170 var url; |
| 133 var lineNumber; | 171 var lineNumber; |
| 134 if (script) { | 172 if (script) { |
| 135 url = WebInspector.displayNameForURL(script.sourceURL); | 173 url = WebInspector.displayNameForURL(script.sourceURL); |
| 136 lineNumber = frame.location.lineNumber + 1; | 174 lineNumber = frame.location.lineNumber + 1; |
| 137 } else { | 175 } else { |
| 138 url = "(internal script)"; | 176 url = "(internal script)"; |
| 139 lineNumber = "(line number)"; | 177 lineNumber = "(line number)"; |
| 140 } | 178 } |
| 141 var s = " " + i + ") " + frame.functionName + " (" + url + (optio ns.dropLineNumbers ? "" : ":" + lineNumber) + ")"; | 179 var s = " " + i + ") " + frame.functionName + " (" + url + (optio ns.dropLineNumbers ? "" : ":" + lineNumber) + ")"; |
| 142 InspectorTest.addResult(s); | 180 results.push(s); |
| 143 if (options.printReturnValue && frame.returnValue) | 181 if (options.printReturnValue && frame.returnValue) |
| 144 InspectorTest.addResult(" <return>: " + frame.returnValue. description); | 182 results.push(" <return>: " + frame.returnValue.description ); |
| 145 } | 183 } |
| 146 } | 184 } |
| 147 | 185 |
| 148 InspectorTest.addResult("Call stack:"); | 186 results.push("Call stack:"); |
| 149 printCallFrames(callFrames); | 187 printCallFrames(callFrames); |
| 150 | 188 |
| 151 while (asyncStackTrace) { | 189 while (asyncStackTrace) { |
| 152 InspectorTest.addResult(" [" + (asyncStackTrace.description || "Async Call") + "]"); | 190 results.push(" [" + (asyncStackTrace.description || "Async Call") + " ]"); |
| 153 printCallFrames(asyncStackTrace.callFrames); | 191 printCallFrames(asyncStackTrace.callFrames); |
| 154 if (asyncStackTrace.callFrames[0].functionName === "testFunction") | 192 if (asyncStackTrace.callFrames.peekLast().functionName === "testFunction ") |
| 155 break; | 193 break; |
| 156 asyncStackTrace = asyncStackTrace.asyncStackTrace; | 194 asyncStackTrace = asyncStackTrace.asyncStackTrace; |
| 157 } | 195 } |
| 196 return results.join("\n"); | |
| 158 }; | 197 }; |
| 159 | 198 |
| 160 InspectorTest.dumpSourceFrameContents = function(sourceFrame) | 199 InspectorTest.dumpSourceFrameContents = function(sourceFrame) |
| 161 { | 200 { |
| 162 InspectorTest.addResult("==Source frame contents start=="); | 201 InspectorTest.addResult("==Source frame contents start=="); |
| 163 var textEditor = sourceFrame._textEditor; | 202 var textEditor = sourceFrame._textEditor; |
| 164 for (var i = 0; i < textEditor.linesCount; ++i) | 203 for (var i = 0; i < textEditor.linesCount; ++i) |
| 165 InspectorTest.addResult(textEditor.line(i)); | 204 InspectorTest.addResult(textEditor.line(i)); |
| 166 InspectorTest.addResult("==Source frame contents end=="); | 205 InspectorTest.addResult("==Source frame contents end=="); |
| 167 }; | 206 }; |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 | 378 |
| 340 InspectorTest.checkUILocation = function(uiSourceCode, lineNumber, columnNumber, location) | 379 InspectorTest.checkUILocation = function(uiSourceCode, lineNumber, columnNumber, location) |
| 341 { | 380 { |
| 342 InspectorTest.assertEquals(uiSourceCode, location.uiSourceCode, "Incorrect u iSourceCode, expected '" + (uiSourceCode ? uiSourceCode.originURL() : null) + "' ," + | 381 InspectorTest.assertEquals(uiSourceCode, location.uiSourceCode, "Incorrect u iSourceCode, expected '" + (uiSourceCode ? uiSourceCode.originURL() : null) + "' ," + |
| 343 " but got '" + (location.uiSourceCode ? location.uiSourceCode.originURL() : null) + "'"); | 382 " but got '" + (location.uiSourceCode ? location.uiSourceCode.originURL() : null) + "'"); |
| 344 InspectorTest.assertEquals(lineNumber, location.lineNumber, "Incorrect lineN umber, expected '" + lineNumber + "', but got '" + location.lineNumber + "'"); | 383 InspectorTest.assertEquals(lineNumber, location.lineNumber, "Incorrect lineN umber, expected '" + lineNumber + "', but got '" + location.lineNumber + "'"); |
| 345 InspectorTest.assertEquals(columnNumber, location.columnNumber, "Incorrect c olumnNumber, expected '" + columnNumber + "', but got '" + location.columnNumber + "'"); | 384 InspectorTest.assertEquals(columnNumber, location.columnNumber, "Incorrect c olumnNumber, expected '" + columnNumber + "', but got '" + location.columnNumber + "'"); |
| 346 }; | 385 }; |
| 347 | 386 |
| 348 }; | 387 }; |
| OLD | NEW |