| OLD | NEW |
| 1 // Copyright 2017 the V8 project authors. All rights reserved. | 1 // Copyright 2017 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('Checks Debugger.getPossibleBreakpoints'); | 5 print('Checks Debugger.getPossibleBreakpoints'); |
| 6 | 6 |
| 7 var source = read('test/inspector/debugger/resources/break-locations.js'); | 7 var source = read('test/inspector/debugger/resources/break-locations.js'); |
| 8 InspectorTest.addScript(source); | 8 InspectorTest.addScript(source); |
| 9 | 9 |
| 10 Protocol.Debugger.onceScriptParsed() | 10 Protocol.Debugger.onceScriptParsed() |
| 11 .then(message => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumbe
r: 0, columnNumber : 0, scriptId: message.params.scriptId }})) | 11 .then(message => Protocol.Debugger.getPossibleBreakpoints({ start: { lineNumbe
r: 0, columnNumber : 0, scriptId: message.params.scriptId }})) |
| 12 .then(dumpAllLocations) | 12 .then(dumpAllLocations) |
| 13 .then(InspectorTest.completeTest); | 13 .then(InspectorTest.completeTest); |
| 14 Protocol.Debugger.enable(); | 14 Protocol.Debugger.enable(); |
| 15 | 15 |
| 16 function dumpAllLocations(message) { | 16 function dumpAllLocations(message) { |
| 17 if (message.error) { | 17 if (message.error) { |
| 18 InspectorTest.logMessage(message); | 18 InspectorTest.logMessage(message); |
| 19 return; | 19 return; |
| 20 } | 20 } |
| 21 var lines = source.split('\n'); | 21 var lines = source.split('\n'); |
| 22 var locations = message.result.locations.sort((loc1, loc2) => { | 22 var locations = message.result.locations.sort((loc1, loc2) => { |
| 23 if (loc2.lineNumber !== loc1.lineNumber) return loc2.lineNumber - loc1.lineN
umber; | 23 if (loc2.location.lineNumber !== loc1.location.lineNumber) return loc2.locat
ion.lineNumber - loc1.location.lineNumber; |
| 24 return loc2.columnNumber - loc1.columnNumber; | 24 return loc2.location.columnNumber - loc1.location.columnNumber; |
| 25 }); | 25 }); |
| 26 for (var location of locations) { | 26 for (var location of locations) { |
| 27 var line = lines[location.lineNumber]; | 27 var line = lines[location.location.lineNumber]; |
| 28 line = line.slice(0, location.columnNumber) + '#' + line.slice(location.colu
mnNumber); | 28 line = line.slice(0, location.location.columnNumber) + locationMark(location
.type) + line.slice(location.location.columnNumber); |
| 29 lines[location.lineNumber] = line; | 29 lines[location.location.lineNumber] = line; |
| 30 } | 30 } |
| 31 lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1); | 31 lines = lines.filter(line => line.indexOf('//# sourceURL=') === -1); |
| 32 InspectorTest.log(lines.join('\n')); | 32 InspectorTest.log(lines.join('\n')); |
| 33 return message; | 33 return message; |
| 34 } | 34 } |
| 35 |
| 36 function locationMark(type) { |
| 37 if (type === 'return') return '|R|'; |
| 38 if (type === 'call') return '|C|'; |
| 39 if (type === 'debuggerStatement') return '|D|'; |
| 40 return '|_|'; |
| 41 } |
| OLD | NEW |