Esempio n. 1
0
        private void Dispose(bool disposing)
        {
            if (!m_disposed)
            {
                if (disposing)
                {
                    m_session.Dispose();

                    m_frameStoppedLoading.Dispose();
                    m_childNodeEvent.Dispose();
                    m_nodeDictionary.Clear();
                }

                m_disposed = true;
            }
        }
Esempio n. 2
0
        private bool disposedValue = false; // To detect redundant calls

        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                //if (disposing)
                //{
                //    // dispose managed state (managed objects).
                //}

                if (mmSession != null)
                {
                    mmSession.Dispose();
                    mmSession = null;
                }
                disposedValue = true;
            }
        }
        public async Task AssertWSErrorExceptionCanBeCaught()
        {
            bool exceptionThrown = false;

            //Create a new chrome instance
            var chrome      = Chrome.OpenChrome(9226);
            var sessionInfo = await chrome.CreateNewSession();

            ChromeSession session = null;

            try
            {
                session = new ChromeSession(sessionInfo.WebSocketDebuggerUrl);
                await session.Page.Navigate(new Page.NavigateCommand {
                    Url = "https://www.google.com"
                });

                //Dispose of the chrome process, thus killing it.
                chrome.Dispose();

                //Wait a bit to ensure that the chrome process has been terminated.
                Thread.Sleep(2000);

                //Try another navigation -- this will raise the socket exception
                await session.Page.Navigate(new Page.NavigateCommand
                {
                    Url = "https://www.winamp.com"
                });
            }
            catch (System.Net.Sockets.SocketException)
            {
                exceptionThrown = true;
            }
            finally
            {
                //Ensure the session is disposed
                if (session != null)
                {
                    session.Dispose();
                }
            }

            Assert.IsTrue(exceptionThrown);
        }