Skip to content

Commit 2b2b26e

Browse files
committed
GetSetUserAgent
1 parent 9bb2adc commit 2b2b26e

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

src/ElectronNET.IntegrationTests/Tests/WebContentsTests.cs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,27 @@ public async Task GetSetUserAgent_check()
178178
{
179179
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
180180

181-
await Task.Delay(1000);
181+
BrowserWindow window = null;
182+
183+
try
184+
{
185+
////Skip.If(Environment.GetEnvironmentVariable("GITHUB_RUN_ID") != null && RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "Skipping test on Windows CI.");
186+
187+
window = await Electron.WindowManager.CreateWindowAsync(new BrowserWindowOptions { Show = true }, "about:blank");
182188

183-
fx.MainWindow.WebContents.SetUserAgent("MyUserAgent/1.0");
189+
await Task.Delay(3000);
190+
191+
window.WebContents.SetUserAgent("MyUserAgent/1.0");
184192

185-
await Task.Delay(1000);
193+
await Task.Delay(1000);
186194

187-
var ok = await fx.MainWindow.WebContents.GetUserAgentAsync();
188-
ok.Should().Be("MyUserAgent/1.0");
195+
var ok = await window.WebContents.GetUserAgentAsync();
196+
ok.Should().Be("MyUserAgent/1.0");
197+
}
198+
finally
199+
{
200+
window?.Destroy();
201+
}
189202
}
190203

191204
}

0 commit comments

Comments
 (0)