@@ -588,8 +588,8 @@ function createCommandContext(inspector) {
588588
589589 setBreakpoint ( script , line , condition , silent ) {
590590 function registerBreakpoint ( { breakpointId, actualLocation } ) {
591- if ( actualLocation ) {
592- handleBreakpointResolved ( { breakpointId , location : actualLocation } ) ;
591+ handleBreakpointResolved ( { breakpointId , location : actualLocation } ) ;
592+ if ( actualLocation && actualLocation . scriptId ) {
593593 if ( ! silent ) return ctx . list ( 5 ) ;
594594 } else {
595595 print ( `Warning: script '${ script } ' was not loaded yet.` ) ;
@@ -666,14 +666,32 @@ function createCommandContext(inspector) {
666666 const urlRegex = `^(.*[\\/\\\\])?${ escapedPath } $` ;
667667
668668 return Debugger . setBreakpointByUrl ( { urlRegex, lineNumber : line - 1 , condition } )
669- . then ( registerBreakpoint ) ;
669+ . then ( bp => {
670+ // TODO: handle bp.locations in case the regex matches existing files
671+ if ( ! bp . location ) { // Fake it for now.
672+ bp . actualLocation = { scriptUrl : `.*/${ script } $` , lineNumber : line - 1 } ;
673+ }
674+ return registerBreakpoint ( bp ) ;
675+ } ) ;
670676 } ,
671677
672678 clearBreakpoint ( ) {
673679 // TODO: Use Debugger.removeBreakpoint({ breakpointId })
674680 throw new Error ( 'Not implemented' ) ;
675681 } ,
676682
683+ get breakpoints ( ) {
684+ function formatLocation ( location ) {
685+ if ( ! location ) return '<unknown location>' ;
686+ const script = scripts [ location . scriptId ] ;
687+ const scriptUrl = script ? script . url : location . scriptUrl ;
688+ return `${ getRelativePath ( scriptUrl ) } :${ location . lineNumber } ` ;
689+ }
690+ knownBreakpoints . forEach ( ( bp , idx ) => {
691+ print ( `#${ idx } ${ formatLocation ( bp . location ) } ` ) ;
692+ } ) ;
693+ } ,
694+
677695 get cont ( ) {
678696 return Debugger . resume ( ) ;
679697 } ,
@@ -723,7 +741,7 @@ function createCommandContext(inspector) {
723741
724742 let isBreakpoint = false ;
725743 knownBreakpoints . forEach ( ( { location } ) => {
726- if ( location . scriptId === scriptId && ( location . lineNumber + 1 ) === i ) {
744+ if ( location && location . scriptId === scriptId && ( location . lineNumber + 1 ) === i ) {
727745 isBreakpoint = true ;
728746 }
729747 } ) ;
0 commit comments