Example #1
0
        public void DesignerPropertyEqualsSettingsProperty()
        {
            void Action()
            {
                var wv = new Forms.UI.Controls.WebView();

                ((ISupportInitialize)wv).BeginInit();
                wv.IsScriptNotifyAllowed = !wv.IsScriptNotifyAllowed;
                ((ISupportInitialize)wv).EndInit();

                wv.IsScriptNotifyAllowed.ShouldEqual(wv.Settings.IsScriptNotifyAllowed);
            }

#if NETCOREAPP
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                Action();
            }
            else
            {
                _threadManager.Execute(Action);
            }
#else
            Action();
#endif
        }
Example #2
0
 protected override void CreateWebView()
 {
     WebView = new Forms.UI.Controls.WebView()
     {
         IsScriptNotifyAllowed = true
     };
 }
Example #3
0
        public void CanInitializeCtorBeginEndInit()
        {
            var wv = new Forms.UI.Controls.WebView();

            ((ISupportInitialize)wv).BeginInit();
            ((ISupportInitialize)wv).EndInit();
        }
        protected override void CreateWebView()
        {
            WebView = new Forms.UI.Controls.WebView();
            ((ISupportInitialize)WebView).BeginInit();
            ((ISupportInitialize)WebView).EndInit();

            WebView.ShouldNotBeNull();
            WebView.Process.ShouldNotBeNull();
        }
Example #5
0
        public void DesignerPropertyEqualsSettingsProperty()
        {
            var wv = new Forms.UI.Controls.WebView();

            ((ISupportInitialize)wv).BeginInit();
            wv.IsScriptNotifyAllowed = !wv.IsScriptNotifyAllowed;
            ((ISupportInitialize)wv).EndInit();

            wv.IsScriptNotifyAllowed.ShouldEqual(wv.Settings.IsScriptNotifyAllowed);
        }
        protected override void CreateWebView()
        {
            WebView = new Forms.UI.Controls.WebView();
            ((ISupportInitialize)WebView).BeginInit();
            ((ISupportInitialize)WebView).EndInit();

            WebView.ShouldNotBeNull();
            WebView.Process.ShouldNotBeNull();
            WebView.Process.ProcessId.ShouldNotEqual(0U);

            WebView.Process.ProcessExited += (o, e) =>
            {
                _processExitedEventFired = true;
                _mre.Set();
            };
        }
Example #7
0
        protected async Task SetCookieAsync(
            Forms.UI.Controls.WebView webView,
            string cookieName,
            string cookieValue,
            DateTime?expiry = null)
        {
            string formatExpiry(DateTime?e) => e != null
                ? $"; expires={e.Value.ToUniversalTime():R}"
                : string.Empty;

            var cookie = $"{cookieName}={cookieValue}{formatExpiry(expiry)}";

            if (webView != null)
            {
                await webView.InvokeScriptAsync("eval", $"document.cookie = \"{cookie}\"").ConfigureAwait(false);
            }
        }
        protected override void Cleanup()
        {
            PrintStartEnd(
                TestContext.TestName,
                nameof(Cleanup),
                () =>
            {
                UnsubscribeWebViewEvents();
                TryAction(() =>
                {
                    if (WebView != null && !WebView.IsDisposed)
                    {
                        WriteLine("WebView is not null and has not been disposed. Calling Dispose()");
                        WebView.Dispose();
                        WebView = null;
                    }
                });
            });

            base.Cleanup();
        }
Example #9
0
        protected override void CreateWebView()
        {
            // This is what Windows Forms designer emits
            WebView = new Forms.UI.Controls.WebView();
            ((ISupportInitialize)WebView).BeginInit();
            Form.SuspendLayout();
            WebView.Dock = DockStyle.Fill;
            WebView.Size = Form.ClientSize;
            WebView.IsScriptNotifyAllowed = true;
            WebView.IsIndexedDBEnabled    = true;
            WebView.IsJavaScriptEnabled   = true;
            WebView.Visible = true;
            Form.Controls.Add(WebView);
            ((ISupportInitialize)WebView).EndInit();
            Form.ResumeLayout(false);
            Form.PerformLayout();

            WebView.IsScriptNotifyAllowed.ShouldBeTrue();
            WebView.IsIndexedDBEnabled.ShouldBeTrue();
            WebView.IsJavaScriptEnabled.ShouldBeTrue();
        }
Example #10
0
        public void CanInitializeCtorBeginEndInit()
        {
            void Action()
            {
                var wv = new Forms.UI.Controls.WebView();

                ((ISupportInitialize)wv).BeginInit();
                ((ISupportInitialize)wv).EndInit();
            }

#if NETCOREAPP
            if (Thread.CurrentThread.GetApartmentState() == ApartmentState.STA)
            {
                Action();
            }
            else
            {
                _threadManager.Execute(Action);
            }
#else
            Action();
#endif
        }
Example #11
0
        private async Task NewMethod(Forms.UI.Controls.WebView a)
        {
            _actual = await a.InvokeScriptAsync("echoOneArgument", "exampleParameter").ConfigureAwait(false);

            Form.Close();
        }
Example #12
0
 protected override void CreateWebView()
 {
     WebView = new Forms.UI.Controls.WebView();
 }
 protected override void CreateWebView()
 {
     WebView = new Forms.UI.Controls.WebView();
     ((ISupportInitialize)WebView).BeginInit();
     ((ISupportInitialize)WebView).EndInit();
 }
Example #14
0
        public void CanInitializeCtorOnly()
        {
            var wv = new Forms.UI.Controls.WebView();

            wv.Process.ShouldBeNull();
        }
Example #15
0
 protected Task <string> GetCookiesAsync(Forms.UI.Controls.WebView webView)
 {
     return(webView.InvokeScriptAsync("eval", "document.cookie"));
 }
Example #16
0
 protected abstract Task SetCookieAsync(Forms.UI.Controls.WebView webView);