File tree Expand file tree Collapse file tree 1 file changed +23
-4
lines changed
src/mono/wasm/Wasm.Build.Tests Expand file tree Collapse file tree 1 file changed +23
-4
lines changed Original file line number Diff line number Diff line change @@ -109,11 +109,17 @@ public async Task<IBrowser> SpawnBrowserAsync(
109
109
// codespaces: ignore certificate error -> Microsoft.Playwright.PlaywrightException : net::ERR_CERT_AUTHORITY_INVALID
110
110
string [ ] chromeArgs = new [ ] { $ "--explicitly-allowed-ports={ url . Port } ", "--ignore-certificate-errors" } ;
111
111
_testOutput . WriteLine ( $ "Launching chrome ('{ s_chromePath . Value } ') via playwright with args = { string . Join ( ',' , chromeArgs ) } ") ;
112
- return Browser = await Playwright . Chromium . LaunchAsync ( new BrowserTypeLaunchOptions {
112
+ Browser = await Playwright . Chromium . LaunchAsync ( new BrowserTypeLaunchOptions {
113
113
ExecutablePath = s_chromePath . Value ,
114
114
Headless = headless ,
115
115
Args = chromeArgs
116
116
} ) ;
117
+ Browser . Disconnected += ( sender , e ) =>
118
+ {
119
+ Browser = null ;
120
+ _testOutput . WriteLine ( "Browser has been disconnected" ) ;
121
+ } ;
122
+ return Browser ;
117
123
}
118
124
119
125
// FIXME: options
@@ -196,8 +202,21 @@ public async Task WaitForProcessExitAsync(TimeSpan timeout)
196
202
197
203
public async ValueTask DisposeAsync ( )
198
204
{
199
- if ( Browser is not null )
200
- await Browser . DisposeAsync ( ) ;
201
- Playwright ? . Dispose ( ) ;
205
+ try
206
+ {
207
+ if ( Browser is not null )
208
+ {
209
+ await Browser . DisposeAsync ( ) ;
210
+ Browser = null ;
211
+ }
212
+ }
213
+ catch ( PlaywrightException ex )
214
+ {
215
+ _testOutput . WriteLine ( $ "PlaywrightException occurred during DisposeAsync: { ex . Message } ") ;
216
+ }
217
+ finally
218
+ {
219
+ Playwright ? . Dispose ( ) ;
220
+ }
202
221
}
203
222
}
You can’t perform that action at this time.
0 commit comments