@@ -184,7 +184,7 @@ ngApp
184184 return promise ;
185185 }
186186 tasks ( socket , options ) {
187- return new Promise ( resolve => {
187+ let t1 = new Promise ( resolve => {
188188 let autoResume = options && options . autoResume ? options . autoResume : false ;
189189 if ( autoResume ) {
190190 this . autoResumeInspectBrk ( socket )
@@ -195,6 +195,15 @@ ngApp
195195 resolve ( socket ) ;
196196 }
197197 } ) ;
198+ let t2 = new Promise ( resolve => {
199+ let focusOnBreakpoint = options && options . focusOnBreakpoint ? options . focusOnBreakpoint : false ;
200+ if ( focusOnBreakpoint ) this . focusOnBreakpoint ( socket ) ;
201+ resolve ( socket ) ;
202+ } ) ;
203+ return Promise . all ( [ t1 , t2 ] )
204+ . then ( ( ) => {
205+ return Promise . resolve ( socket ) ;
206+ } ) ;
198207 }
199208 autoResumeInspectBrk ( socket ) {
200209 let parsedData = { } ;
@@ -227,6 +236,25 @@ ngApp
227236 resolve ( socket ) ;
228237 } ) ;
229238 }
239+ focusOnBreakpoint ( socket ) {
240+ socket . ws . onmessage = event => {
241+ let parsed = JSON . parse ( event . data ) ,
242+ ws ,
243+ id ;
244+ switch ( parsed . method ) {
245+ case 'Debugger.paused' :
246+ ws = event . currentTarget . url . split ( 'ws://' ) [ 1 ] ;
247+ id = $scope . devToolsSessions . find ( session => session . url . includes ( ws ) ) . id ;
248+ chrome . tabs . update ( id , { active : true } , tab => {
249+ chrome . windows . update ( tab . windowId , { focused : true } , window => {
250+ if ( $scope . settings . debugVerbosity >= 4 ) console . log ( `focusOnBreakpoint(): window: ${ window . id } tab: ${ tab . id } ` ) ;
251+ } ) ;
252+ } ) ;
253+ break ;
254+ }
255+ if ( $scope . settings . debugVerbosity >= 1 ) console . log ( event ) ;
256+ }
257+ }
230258 }
231259 class PubSub {
232260 constructor ( ) {
@@ -730,7 +758,8 @@ ngApp
730758 enabled : true ,
731759 maxMessages : 10
732760 } ,
733- autoResumeInspectBrk : false
761+ autoResumeInspectBrk : false ,
762+ focusOnBreakpoint : false
734763 } ;
735764 $scope . remoteConnectionSettings = { } ;
736765 $scope . Auth = new Auth ( ) ;
@@ -1565,7 +1594,10 @@ ngApp
15651594 } else {
15661595 inspectorURL = nodeInspectMetadataJSON . webSocketDebuggerUrl ;
15671596 }
1568- let dtpSocketPromise = $scope . devToolsProtocolClient . setSocket ( websocketId , inspectorURL , { autoResume : $scope . settings . autoResumeInspectBrk } ) ;
1597+ let dtpSocketPromise = $scope . devToolsProtocolClient . setSocket ( websocketId , inspectorURL , {
1598+ autoResume : $scope . settings . autoResumeInspectBrk ,
1599+ focusOnBreakpoint : $scope . settings . focusOnBreakpoint
1600+ } ) ;
15691601 if ( $scope . settings . newWindow ) {
15701602 $window . _gaq . push ( [ '_trackEvent' , 'Program Event' , 'createWindow' , 'focused' , + $scope . settings . windowFocused , true ] ) ;
15711603 chrome . windows . create ( {
@@ -1637,13 +1669,17 @@ ngApp
16371669
16381670 if ( existingSession ) {
16391671 existingSession . websocketId = websocketId ;
1640- $scope . devToolsProtocolClient . updateSocket ( websocketId , socketUrl , { autoResume : $scope . settings . autoResumeInspectBrk } )
1672+ $scope . devToolsProtocolClient . updateSocket ( websocketId , socketUrl , { autoResume : $scope . settings . autoResumeInspectBrk ,
1673+ focusOnBreakpoint : $scope . settings . focusOnBreakpoint
1674+ } )
16411675 . then ( dtpSocket => {
16421676 existingSession . dtpSocket = dtpSocket ;
16431677 } ) ;
16441678 } else {
16451679 /** A session will not exist if the tab is reused during a node restart */
1646- $scope . devToolsProtocolClient . setSocket ( websocketId , socketUrl , { autoResume : $scope . settings . autoResumeInspectBrk } )
1680+ $scope . devToolsProtocolClient . setSocket ( websocketId , socketUrl , { autoResume : $scope . settings . autoResumeInspectBrk ,
1681+ focusOnBreakpoint : $scope . settings . focusOnBreakpoint
1682+ } )
16471683 . then ( dtpSocket => {
16481684 $scope . devToolsSessions . push ( {
16491685 url : url ,
0 commit comments