Пример #1
0
        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);
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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;
            }
        }
Пример #5
0
        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);
        }