OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 InspectorTest = {}; | 5 InspectorTest = {}; |
6 InspectorTest._dispatchTable = new Map(); | 6 InspectorTest._dispatchTable = new Map(); |
7 InspectorTest._requestId = 0; | 7 InspectorTest._requestId = 0; |
8 InspectorTest._dumpInspectorProtocolMessages = false; | 8 InspectorTest._dumpInspectorProtocolMessages = false; |
9 InspectorTest._eventHandler = {}; | 9 InspectorTest._eventHandler = {}; |
10 | 10 |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 { | 106 { |
107 for (var frame of callFrames) { | 107 for (var frame of callFrames) { |
108 var functionName = frame.functionName || '(anonymous)'; | 108 var functionName = frame.functionName || '(anonymous)'; |
109 var url = frame.url ? frame.url : InspectorTest._scriptMap.get(frame.locatio
n.scriptId).url; | 109 var url = frame.url ? frame.url : InspectorTest._scriptMap.get(frame.locatio
n.scriptId).url; |
110 var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumb
er; | 110 var lineNumber = frame.location ? frame.location.lineNumber : frame.lineNumb
er; |
111 var columnNumber = frame.location ? frame.location.columnNumber : frame.colu
mnNumber; | 111 var columnNumber = frame.location ? frame.location.columnNumber : frame.colu
mnNumber; |
112 InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`); | 112 InspectorTest.log(`${functionName} (${url}:${lineNumber}:${columnNumber})`); |
113 } | 113 } |
114 } | 114 } |
115 | 115 |
| 116 InspectorTest.logCallFrameSourceLocation = function(callFrame) |
| 117 { |
| 118 var scriptId = callFrame.location.scriptId; |
| 119 if (!InspectorTest._scriptMap || !InspectorTest._scriptMap.has(scriptId)) { |
| 120 InspectorTest.log("InspectorTest.setupScriptMap should be called before Prot
ocol.Debugger.enable."); |
| 121 InspectorTest.completeTest(); |
| 122 } |
| 123 var script = InspectorTest._scriptMap.get(scriptId); |
| 124 if (!script.scriptSource) { |
| 125 return Protocol.Debugger.getScriptSource({ scriptId }) |
| 126 .then(message => script.scriptSource = message.result.scriptSource) |
| 127 .then(dumpSourceWithLocation); |
| 128 } |
| 129 return Promise.resolve().then(dumpSourceWithLocation); |
| 130 |
| 131 function dumpSourceWithLocation() { |
| 132 var location = callFrame.location; |
| 133 var lines = script.scriptSource.split('\n'); |
| 134 var line = lines[location.lineNumber]; |
| 135 line = line.slice(0, location.columnNumber) + '#' + (line.slice(location.col
umnNumber) || ''); |
| 136 lines[location.lineNumber] = line; |
| 137 InspectorTest.log(lines.slice(Math.max(location.lineNumber - 1, 0), location
.lineNumber + 2).join('\n')); |
| 138 InspectorTest.log(''); |
| 139 } |
| 140 } |
| 141 |
116 InspectorTest.logAsyncStackTrace = function(asyncStackTrace) | 142 InspectorTest.logAsyncStackTrace = function(asyncStackTrace) |
117 { | 143 { |
118 while (asyncStackTrace) { | 144 while (asyncStackTrace) { |
119 if (asyncStackTrace.promiseCreationFrame) { | 145 if (asyncStackTrace.promiseCreationFrame) { |
120 var frame = asyncStackTrace.promiseCreationFrame; | 146 var frame = asyncStackTrace.promiseCreationFrame; |
121 InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url | 147 InspectorTest.log(`-- ${asyncStackTrace.description} (${frame.url |
122 }:${frame.lineNumber}:${frame.columnNumber})--`); | 148 }:${frame.lineNumber}:${frame.columnNumber})--`); |
123 } else { | 149 } else { |
124 InspectorTest.log(`-- ${asyncStackTrace.description} --`); | 150 InspectorTest.log(`-- ${asyncStackTrace.description} --`); |
125 } | 151 } |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 if (eventName === "Debugger.scriptParsed" && messageObject.params.url ===
"wait-pending-tasks.js") | 262 if (eventName === "Debugger.scriptParsed" && messageObject.params.url ===
"wait-pending-tasks.js") |
237 return; | 263 return; |
238 if (eventHandler) | 264 if (eventHandler) |
239 eventHandler(messageObject); | 265 eventHandler(messageObject); |
240 } | 266 } |
241 } catch (e) { | 267 } catch (e) { |
242 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); | 268 InspectorTest.log("Exception when dispatching message: " + e + "\n" + e.stac
k + "\n message = " + JSON.stringify(messageObject, null, 2)); |
243 InspectorTest.completeTest(); | 269 InspectorTest.completeTest(); |
244 } | 270 } |
245 } | 271 } |
OLD | NEW |