@@ -71,38 +71,50 @@ protected override async Task<WasmDebuggerConnection> SetupConnection(Uri webser
71
71
throw new Exception ( $ "Failed to connect to the proxy at { endpoint } ", se ) ;
72
72
}
73
73
}
74
+ public async Task < bool > ProcessTabInfo ( Result command , CancellationToken token )
75
+ {
76
+ var resultTabs = command . Value ? [ "result" ] ? [ "value" ] ? [ "tabs" ] ;
77
+ if ( resultTabs == null ||
78
+ resultTabs . Value < JArray > ( ) ? . Count == 0 ||
79
+ resultTabs [ 0 ] ? [ "url" ] ? . Value < string > ( ) ? . StartsWith ( "about:" ) == true )
80
+ return false ;
81
+ var toCmd = resultTabs [ 0 ] ? [ "actor" ] ? . Value < string > ( ) ;
82
+ var res = await SendCommand ( "getWatcher" , JObject . FromObject ( new { type = "getWatcher" , isServerTargetSwitchingEnabled = true , to = toCmd } ) , token ) ;
83
+ var watcherId = res . Value ? [ "result" ] ? [ "value" ] ? [ "actor" ] ? . Value < string > ( ) ;
84
+ res = await SendCommand ( "watchResources" , JObject . FromObject ( new { type = "watchResources" , resourceTypes = new JArray ( "console-message" ) , to = watcherId } ) , token ) ;
85
+ res = await SendCommand ( "watchTargets" , JObject . FromObject ( new { type = "watchTargets" , targetType = "frame" , to = watcherId } ) , token ) ;
86
+ UpdateTarget ( res . Value ? [ "result" ] ? [ "value" ] ? [ "target" ] as JObject ) ;
87
+ res = await SendCommand ( "attach" , JObject . FromObject ( new
88
+ {
89
+ type = "attach" ,
90
+ options = JObject . FromObject ( new
91
+ {
92
+ pauseOnExceptions = false ,
93
+ ignoreCaughtExceptions = true ,
94
+ shouldShowOverlay = true ,
95
+ shouldIncludeSavedFrames = true ,
96
+ shouldIncludeAsyncLiveFrames = false ,
97
+ skipBreakpoints = false ,
98
+ logEventBreakpoints = false ,
99
+ observeAsmJS = true ,
100
+ breakpoints = new JArray ( ) ,
101
+ eventBreakpoints = new JArray ( )
102
+ } ) ,
103
+ to = ThreadActorId
104
+ } ) , token ) ;
105
+ res = await SendCommand ( "getBreakpointListActor" , JObject . FromObject ( new { type = "getBreakpointListActor" , to = watcherId } ) , token ) ;
106
+ BreakpointActorId = res . Value ? [ "result" ] ? [ "value" ] ? [ "breakpointList" ] ? [ "actor" ] ? . Value < string > ( ) ;
107
+ return true ;
108
+ }
74
109
75
110
public override async Task ProcessCommand ( Result command , CancellationToken token )
76
111
{
77
- if ( command . Value ? [ "result" ] ? [ "value" ] ? [ "tabs" ] != null )
112
+ if ( await ProcessTabInfo ( command , token ) )
113
+ return ;
114
+ do
78
115
{
79
- var toCmd = command . Value ? [ "result" ] ? [ "value" ] ? [ "tabs" ] ? [ 0 ] ? [ "actor" ] ? . Value < string > ( ) ;
80
- var res = await SendCommand ( "getWatcher" , JObject . FromObject ( new { type = "getWatcher" , isServerTargetSwitchingEnabled = true , to = toCmd } ) , token ) ;
81
- var watcherId = res . Value ? [ "result" ] ? [ "value" ] ? [ "actor" ] ? . Value < string > ( ) ;
82
- res = await SendCommand ( "watchResources" , JObject . FromObject ( new { type = "watchResources" , resourceTypes = new JArray ( "console-message" ) , to = watcherId } ) , token ) ;
83
- res = await SendCommand ( "watchTargets" , JObject . FromObject ( new { type = "watchTargets" , targetType = "frame" , to = watcherId } ) , token ) ;
84
- UpdateTarget ( res . Value ? [ "result" ] ? [ "value" ] ? [ "target" ] as JObject ) ;
85
- await SendCommand ( "attach" , JObject . FromObject ( new
86
- {
87
- type = "attach" ,
88
- options = JObject . FromObject ( new
89
- {
90
- pauseOnExceptions = false ,
91
- ignoreCaughtExceptions = true ,
92
- shouldShowOverlay = true ,
93
- shouldIncludeSavedFrames = true ,
94
- shouldIncludeAsyncLiveFrames = false ,
95
- skipBreakpoints = false ,
96
- logEventBreakpoints = false ,
97
- observeAsmJS = true ,
98
- breakpoints = new JArray ( ) ,
99
- eventBreakpoints = new JArray ( )
100
- } ) ,
101
- to = ThreadActorId
102
- } ) , token ) ;
103
- res = await SendCommand ( "getBreakpointListActor" , JObject . FromObject ( new { type = "getBreakpointListActor" , to = watcherId } ) , token ) ;
104
- BreakpointActorId = res . Value ? [ "result" ] ? [ "value" ] ? [ "breakpointList" ] ? [ "actor" ] ? . Value < string > ( ) ;
105
- }
116
+ command = await SendCommand ( "listTabs" , JObject . FromObject ( new { type = "listTabs" , to = "root" } ) , token ) ;
117
+ } while ( ! await ProcessTabInfo ( command , token ) ) ;
106
118
}
107
119
108
120
protected override Task ? HandleMessage ( string msg , CancellationToken token )
@@ -187,7 +199,6 @@ public override Task<Result> SendCommand(SessionId sessionId, string method, JOb
187
199
{
188
200
if ( args == null )
189
201
args = new JObject ( ) ;
190
-
191
202
var tcs = new TaskCompletionSource < Result > ( ) ;
192
203
MessageId msgId ;
193
204
if ( args [ "to" ] ? . Value < string > ( ) is not string to_str )
0 commit comments