protected void LoadAndWaitReady(string html, TimeSpan timeout, string timeoutMsg = null) { var navigated = false; TargetView.Navigated += (string url) => navigated = true; TargetView.LoadHtml(html); WaitFor(() => navigated, timeout, timeoutMsg); }
public void HtmlIsWellEncoded() { const string BodyContent = "some text and a double byte char '●'"; var navigated = false; TargetView.Navigated += (_, __) => navigated = true; TargetView.LoadHtml($"<html><script>;</script><body>{BodyContent}</body></html>"); WaitFor(() => navigated); var body = TargetView.EvaluateScript <string>("document.body.innerText"); Assert.AreEqual(BodyContent, body); }
protected Task Load(string html) { var taskCompletionSource = new TaskCompletionSource <bool>(TaskCreationOptions.RunContinuationsAsynchronously); void OnNavigated(string url, string frameName) { if (url != UrlHelper.AboutBlankUrl) { TargetView.Navigated -= OnNavigated; taskCompletionSource.SetResult(true); } } TargetView.Navigated += OnNavigated; TargetView.LoadHtml(html); return(taskCompletionSource.Task); }
protected void LoadAndWaitReady(string html, TimeSpan timeout, string timeoutMsg = null) { var navigated = false; void OnNavigated(string url, string frameName) { navigated = true; } try { TargetView.Navigated += OnNavigated; TargetView.LoadHtml(html); WaitFor(() => navigated, timeout, timeoutMsg); } finally { TargetView.Navigated -= OnNavigated; } }
protected Task Load(string html) { var taskCompletionSource = new TaskCompletionSource <bool>(); void OnNavigated(string url, string frameName) { if (url != UrlHelper.AboutBlankUrl) { try { taskCompletionSource.SetResult(true); } finally { TargetView.Navigated -= OnNavigated; } } } TargetView.Navigated += OnNavigated; TargetView.LoadHtml(html); return(taskCompletionSource.Task); }