Skip to content

Commit 0fff657

Browse files
committed
Tests - WebBrowserTestExtensions.LoadRequestAsync
- Add timeout
1 parent dcb9d61 commit 0fff657

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

CefSharp.Test/WebBrowserTestExtensions.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
using System;
66
using System.Reflection;
77
using System.Threading.Tasks;
8+
using CefSharp.Internals;
89
using CefSharp.OffScreen;
9-
using Xunit;
1010

1111
namespace CefSharp.Test
1212
{
@@ -61,8 +61,6 @@ public static Task<LoadUrlAsyncResponse> LoadRequestAsync(this IWebBrowser brows
6161
throw new ArgumentNullException("request");
6262
}
6363

64-
//If using .Net 4.6 then use TaskCreationOptions.RunContinuationsAsynchronously
65-
//and switch to tcs.TrySetResult below - no need for the custom extension method
6664
var tcs = new TaskCompletionSource<LoadUrlAsyncResponse>(TaskCreationOptions.RunContinuationsAsynchronously);
6765

6866
EventHandler<LoadErrorEventArgs> loadErrorHandler = null;
@@ -115,10 +113,9 @@ public static Task<LoadUrlAsyncResponse> LoadRequestAsync(this IWebBrowser brows
115113
};
116114

117115
browser.LoadingStateChanged += loadingStateChangeHandler;
118-
119116
browser.GetMainFrame().LoadRequest(request);
120117

121-
return tcs.Task;
118+
return TaskTimeoutExtensions.WaitAsync(tcs.Task, TimeSpan.FromSeconds(30));
122119
}
123120

124121
public static Task<QUnitTestResult> CreateBrowserAndWaitForQUnitTestExeuctionToComplete(this ChromiumWebBrowser browser)

0 commit comments

Comments
 (0)