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 print('Test for Debugger.getPossibleBreakpoints'); | 5 print('Test for Debugger.getPossibleBreakpoints'); |
6 | 6 |
7 Protocol.Runtime.enable(); | 7 Protocol.Runtime.enable(); |
8 Protocol.Debugger.enable(); | 8 Protocol.Debugger.enable(); |
9 | 9 |
10 InspectorTest.runTestSuite([ | 10 InspectorTest.runTestSuite([ |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 var promise = Protocol.Debugger.oncePaused() | 167 var promise = Protocol.Debugger.oncePaused() |
168 .then(msg => { (start || {}).scriptId = msg.params.callFrames[0].location.sc
riptId; (end || {}).scriptId = msg.params.callFrames[0].location.scriptId }) | 168 .then(msg => { (start || {}).scriptId = msg.params.callFrames[0].location.sc
riptId; (end || {}).scriptId = msg.params.callFrames[0].location.scriptId }) |
169 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en
d })); | 169 .then(() => Protocol.Debugger.getPossibleBreakpoints({ start: start, end: en
d })); |
170 Protocol.Runtime.evaluate({ expression: source }).then(next); | 170 Protocol.Runtime.evaluate({ expression: source }).then(next); |
171 return promise; | 171 return promise; |
172 } | 172 } |
173 | 173 |
174 function setAllBreakpoints(message) { | 174 function setAllBreakpoints(message) { |
175 var promises = []; | 175 var promises = []; |
176 for (var location of message.result.locations) | 176 for (var location of message.result.locations) |
177 promises.push(Protocol.Debugger.setBreakpoint({ location: location }).then(c
heckBreakpoint)); | 177 promises.push(Protocol.Debugger.setBreakpoint({ location: location.location
}).then(checkBreakpoint)); |
178 return Promise.all(promises); | 178 return Promise.all(promises); |
179 } | 179 } |
180 | 180 |
181 function checkBreakpoint(message) { | 181 function checkBreakpoint(message) { |
182 if (message.error) { | 182 if (message.error) { |
183 InspectorTest.log('FAIL: error in setBreakpoint'); | 183 InspectorTest.log('FAIL: error in setBreakpoint'); |
184 InspectorTest.logMessage(message); | 184 InspectorTest.logMessage(message); |
185 return; | 185 return; |
186 } | 186 } |
187 var id_data = message.result.breakpointId.split(':'); | 187 var id_data = message.result.breakpointId.split(':'); |
188 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse
Int(id_data[2]) !== message.result.actualLocation.columnNumber) { | 188 if (parseInt(id_data[1]) !== message.result.actualLocation.lineNumber || parse
Int(id_data[2]) !== message.result.actualLocation.columnNumber) { |
189 InspectorTest.log('FAIL: possible breakpoint was resolved in another locatio
n'); | 189 InspectorTest.log('FAIL: possible breakpoint was resolved in another locatio
n'); |
190 } | 190 } |
191 } | 191 } |
192 | 192 |
193 function dumpAllLocations(message, source, lineOffset, columnOffset) { | 193 function dumpAllLocations(message, source, lineOffset, columnOffset) { |
194 if (message.error) { | 194 if (message.error) { |
195 InspectorTest.logMessage(message); | 195 InspectorTest.logMessage(message); |
196 return; | 196 return; |
197 } | 197 } |
198 | 198 |
199 lineOffset = lineOffset || 0; | 199 lineOffset = lineOffset || 0; |
200 columnOffset = columnOffset || 0; | 200 columnOffset = columnOffset || 0; |
201 | 201 |
202 var sourceLines = source.split('\n') | 202 var sourceLines = source.split('\n') |
203 var lineOffsets = Array(sourceLines.length).fill(0); | 203 var lineOffsets = Array(sourceLines.length).fill(0); |
204 for (var location of message.result.locations) { | 204 for (var location of message.result.locations) { |
205 var lineNumber = location.lineNumber - lineOffset; | 205 var lineNumber = location.location.lineNumber - lineOffset; |
206 var columnNumber = lineNumber !== 0 ? location.columnNumber : location.colum
nNumber - columnOffset; | 206 var columnNumber = lineNumber !== 0 ? location.location.columnNumber : locat
ion.location.columnNumber - columnOffset; |
207 var line = sourceLines[lineNumber] || ''; | 207 var line = sourceLines[lineNumber] || ''; |
208 var offset = lineOffsets[lineNumber]; | 208 var offset = lineOffsets[lineNumber]; |
209 line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber
+ offset); | 209 line = line.slice(0, columnNumber + offset) + '#' + line.slice(columnNumber
+ offset); |
210 ++lineOffsets[lineNumber]; | 210 ++lineOffsets[lineNumber]; |
211 sourceLines[lineNumber] = line; | 211 sourceLines[lineNumber] = line; |
212 } | 212 } |
213 InspectorTest.log(sourceLines.join('\n')); | 213 InspectorTest.log(sourceLines.join('\n')); |
214 return message; | 214 return message; |
215 } | 215 } |
216 | 216 |
217 function dumpBreakLocationInSourceAndResume(message, source, lineOffset, columnO
ffset) { | 217 function dumpBreakLocationInSourceAndResume(message, source, lineOffset, columnO
ffset) { |
218 lineOffset = lineOffset || 0; | 218 lineOffset = lineOffset || 0; |
219 columnOffset = columnOffset || 0; | 219 columnOffset = columnOffset || 0; |
220 | 220 |
221 InspectorTest.log('paused in ' + message.params.callFrames[0].functionName); | 221 InspectorTest.log('paused in ' + message.params.callFrames[0].functionName); |
222 var location = message.params.callFrames[0].location; | 222 var location = message.params.callFrames[0].location; |
223 var sourceLines = source.split('\n') | 223 var sourceLines = source.split('\n') |
224 | 224 |
225 var lineNumber = location.lineNumber - lineOffset; | 225 var lineNumber = location.lineNumber - lineOffset; |
226 var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnN
umber - columnOffset; | 226 var columnNumber = lineNumber !== 0 ? location.columnNumber : location.columnN
umber - columnOffset; |
227 | 227 |
228 var line = sourceLines[lineNumber]; | 228 var line = sourceLines[lineNumber]; |
229 line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber); | 229 line = line.slice(0, columnNumber) + '^' + line.slice(columnNumber); |
230 sourceLines[lineNumber] = line; | 230 sourceLines[lineNumber] = line; |
231 InspectorTest.log(sourceLines.join('\n')); | 231 InspectorTest.log(sourceLines.join('\n')); |
232 Protocol.Debugger.resume(); | 232 Protocol.Debugger.resume(); |
233 } | 233 } |
OLD | NEW |