public void Dispose()
        {
            _Disposed     = true;
            Binding       = null;
            UseINavigable = false;

            CleanWebControl(ref _CurrentWebControl);
            CleanWebControl(ref _NextWebControl);
        }
        private void Crashed(object sender, BrowserCrashedArgs e)
        {
            var dest = _CurrentWebControl.HTMLWindow.Url;
            var vm   = Binding.Root;
            var mode = Binding.Mode;

            _webSessionLogger.Error("WebView crashed trying recover");

            CleanWebControl(ref _CurrentWebControl);
            Binding = null;

            Navigate(dest, vm, mode);
        }
Esempio n. 3
0
        private Exception Test_HTMLWindow_WebCoreShutDown_Base_Exception(IWebSessionWatcher iWatcher)
        {
            var       a   = new AA1();
            Exception res = null;

            TestNavigation((wpfbuild, wpfnav, WindowTest)
                           =>
            {
                wpfnav.WebSessionWatcher.Should().NotBeNull();
                if (iWatcher != null)
                {
                    wpfnav.WebSessionWatcher = iWatcher;
                }
                SetUpRoute(wpfbuild);
                wpfnav.UseINavigable = true;
                IHTMLBinding bind    = null;

                var mre = new ManualResetEvent(false);
                WindowTest.RunOnUIThread(() => wpfnav.IsHTMLLoaded.Should().BeFalse());

                WindowTest.RunOnUIThread(
                    () =>
                {
                    wpfnav.NavigateAsync(a).ContinueWith(t => { var tt = t as Task <IHTMLBinding>; bind = tt.Result; mre.Set(); });
                });

                mre.WaitOne();

                WindowTest.RunOnUIThread(() =>
                {
                    wpfnav.IsHTMLLoaded.Should().BeTrue();
                    a.Navigation.Should().NotBeNull();

                    var js = bind.JSRootObject;

                    var command = js.Invoke("Change", bind.Context);
                    command.Invoke("Execute", bind.Context);

                    //JSObject mycommand = (JSObject)js.Invoke("Change");
                    //mycommand.Invoke("Execute");
                });

                Thread.Sleep(1500);

                res = a.Exception;
            });

            return(res);
        }
        private void Switch(Task <IHTMLBinding> binding, HTMLLogicWindow window, TaskCompletionSource <IHTMLBinding> tcs)
        {
            var oldvm         = Binding?.Root;
            var fireFirstLoad = false;

            Binding = binding.Result;

            if (_CurrentWebControl != null)
            {
                _CurrentWebControl.HTMLWindow.ConsoleMessage -= ConsoleMessage;
                _CurrentWebControl.Dispose();
            }
            else
            {
                fireFirstLoad = true;
            }

            _CurrentWebControl = _NextWebControl;
            _NextWebControl    = null;
            _CurrentWebControl.HTMLWindow.Crashed += Crashed;

            _CurrentWebControl.Show();

            _Window = window;

            var inav = _UseINavigable ? Binding.Root as INavigable : null;

            if (inav != null)
            {
                inav.Navigation = this;
            }
            _Window.State = WindowLogicalState.Opened;

            _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root));

            _Navigating = false;

            FireNavigate(Binding.Root, oldvm);

            tcs?.SetResult(Binding);

            if (fireFirstLoad)
            {
                OnFirstLoad?.Invoke(this, EventArgs.Empty);
            }
        }
        private void Switch(Task <IHTMLBinding> iBinding, HTMLLogicWindow iwindow, TaskCompletionSource <IHTMLBinding> tcs)
        {
            object oldvm = (Binding != null) ? Binding.Root : null;

            Binding = iBinding.Result;

            if (_CurrentWebControl != null)
            {
                _CurrentWebControl.HTMLWindow.ConsoleMessage -= ConsoleMessage;
                _CurrentWebControl.Dispose();
            }
            else if (OnFirstLoad != null)
            {
                OnFirstLoad(this, EventArgs.Empty);
            }

            _CurrentWebControl = _NextWebControl;
            _NextWebControl    = null;
            //_CurrentWebControl.Crashed += Crashed;

            _CurrentWebControl.Show();

            _Window = iwindow;

            var inav = _UseINavigable ? Binding.Root as INavigable : null;

            if (inav != null)
            {
                inav.Navigation = this;
            }
            _Window.State = WindowLogicalState.Opened;

            _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root));

            _Navigating = false;


            FireNavigate(Binding.Root, oldvm);

            if (tcs != null)
            {
                tcs.SetResult(Binding);
            }
        }
        private void Switch(Task<IHTMLBinding> iBinding, HTMLLogicWindow iwindow, TaskCompletionSource<IHTMLBinding> tcs)
        {
            var oldvm = Binding?.Root;
            Binding = iBinding.Result;
          
            if (_CurrentWebControl!=null)
            {
                _CurrentWebControl.HTMLWindow.ConsoleMessage -= ConsoleMessage;
                _CurrentWebControl.Dispose();
            }
            else 
            {
                OnFirstLoad?.Invoke(this, EventArgs.Empty);
            }

            _CurrentWebControl = _NextWebControl;     
            _NextWebControl = null;
            _CurrentWebControl.HTMLWindow.Crashed += Crashed;

            _CurrentWebControl.Show();
    
            _Window = iwindow; 

            var inav = _UseINavigable ? Binding.Root as INavigable : null;
            if (inav != null)
                inav.Navigation = this;
            _Window.State = WindowLogicalState.Opened;

            _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root));

            _Navigating = false;
           
            FireNavigate(Binding.Root, oldvm);

            tcs?.SetResult(Binding);
        }    
        private void Switch(Task<IHTMLBinding> iBinding, HTMLLogicWindow iwindow, TaskCompletionSource<IHTMLBinding> tcs)
        {
            object oldvm = (Binding != null) ? Binding.Root : null;
            Binding = iBinding.Result;
          
            if (_CurrentWebControl!=null)
            {
                _CurrentWebControl.ConsoleMessage -= ConsoleMessage;
                _IWebViewLifeCycleManager.Dispose(_CurrentWebControl);
            }
            else if (OnFirstLoad != null)
                OnFirstLoad(this, EventArgs.Empty);

            _CurrentWebControl = _NextWebControl;     
            _NextWebControl = null;
            //_CurrentWebControl.Crashed += Crashed;

            _IWebViewLifeCycleManager.Display(_CurrentWebControl);
    
            _Window = iwindow; 

            _Window.State = WindowLogicalState.Opened;

            _Window.OpenAsync().ContinueWith(t => EndAnimation(Binding.Root));

            _Navigating = false;
            var inav = _UseINavigable ? Binding.Root as INavigable : null;
            if (inav != null)
                inav.Navigation = this;

            FireNavigate(Binding.Root, oldvm);
            
            if (tcs != null) tcs.SetResult(Binding);
        }
        public void Dispose()
        {
            _Disposed = true;
            Binding = null;
            UseINavigable = false;

            CleanWebControl(ref _CurrentWebControl);
            CleanWebControl(ref _NextWebControl);
        }
        private void Crashed(object sender, BrowserCrashedArgs e)
        {
            var dest = _CurrentWebControl.HTMLWindow.Url;
            var vm = Binding.Root;
            var mode = Binding.Mode;

            _webSessionLogger.Error("WebView crashed trying recover");

            CleanWebControl(ref _CurrentWebControl);
            Binding = null;

            Navigate(dest, vm, mode);
        }