@@ -24,7 +24,7 @@ import * as testUtils from '../testUtils';
24
24
import * as utils from '../../src/utils' ;
25
25
26
26
/** Not mocked - use for type only */
27
- import { ChromeDebugAdapter as _ChromeDebugAdapter , LoadedSourceEventReason } from '../../src/chrome/chromeDebugAdapter' ;
27
+ import { ChromeDebugAdapter as _ChromeDebugAdapter } from '../../src/chrome/chromeDebugAdapter' ;
28
28
import { InitializedEvent , LoadedSourceEvent , Source , BreakpointEvent } from 'vscode-debugadapter/lib/debugSession' ;
29
29
30
30
const MODULE_UNDER_TEST = '../../src/chrome/chromeDebugAdapter' ;
@@ -559,17 +559,29 @@ suite('ChromeDebugAdapter', () => {
559
559
} ) ;
560
560
} ) ;
561
561
562
- // This is needed for Edge debug adapter, please keep the signature and logic of sendLoadedSourceEvent() method intact.
563
- test ( 'tests that sendLoadedSourceEvent can accept an additional paramter to override the `reason` parameter ' , ( ) => {
564
- const loadedSourceEventReason : LoadedSourceEventReason = 'changed' ;
562
+ // This is needed for Edge debug adapter, please keep the logic of sendLoadedSourceEvent()
563
+ test ( 'tests that sendLoadedSourceEvent will set the `reason` parameter based on our internal view of the events we sent to the client ' , ( ) => {
564
+ let eventIndex = 0 ;
565
565
sendEventHandler = ( event ) => {
566
- assert . equal ( 'loadedSource' , event . event ) ;
567
- assert . notEqual ( null , event . body ) ;
568
- assert . equal ( loadedSourceEventReason , event . body . reason ) ;
566
+ switch ( eventIndex ) {
567
+ case 0 :
568
+ assert . equal ( 'loadedSource' , event . event ) ;
569
+ assert . notEqual ( null , event . body ) ;
570
+ assert . equal ( 'new' , event . body . reason ) ;
571
+ break ;
572
+ case 1 :
573
+ assert . equal ( 'loadedSource' , event . event ) ;
574
+ assert . notEqual ( null , event . body ) ;
575
+ assert . equal ( 'changed' , event . body . reason ) ;
576
+ break ;
577
+ default :
578
+ throw new RangeError ( "Unexpected event index" ) ;
579
+ }
580
+ ++ eventIndex ;
569
581
} ;
570
582
571
- return chromeDebugAdapter . attach ( ATTACH_ARGS ) . then ( ( ) => {
572
- return ( < any > chromeDebugAdapter ) . sendLoadedSourceEvent ( {
583
+ return chromeDebugAdapter . attach ( ATTACH_ARGS ) . then ( async ( ) => {
584
+ await ( < any > chromeDebugAdapter ) . sendLoadedSourceEvent ( {
573
585
scriptId : 1 ,
574
586
url : '' ,
575
587
startLine : 0 ,
@@ -578,7 +590,17 @@ suite('ChromeDebugAdapter', () => {
578
590
endColumn : 0 ,
579
591
executionContextId : 0 ,
580
592
hash : ''
581
- } , loadedSourceEventReason ) ;
593
+ } ) ;
594
+ await ( < any > chromeDebugAdapter ) . sendLoadedSourceEvent ( {
595
+ scriptId : 1 ,
596
+ url : '' ,
597
+ startLine : 0 ,
598
+ startColumn : 0 ,
599
+ endLine : 0 ,
600
+ endColumn : 0 ,
601
+ executionContextId : 0 ,
602
+ hash : ''
603
+ } ) ;
582
604
} ) ;
583
605
} ) ;
584
606
0 commit comments