title: How to handle popup links in CefSharp Offscreen
body: <p>I write a console application that uses CEF offscreen rendering mode and provides its own windows in which the images returned from CEF render engine are presented.
  I managed to get child windows to open (and close), but I have a problem with sites that have a "Connect with AccelAero" feature, like <a href="http://reservations.daallo.com/xbe/public/showLogin.action" rel="nofollow">http://reservations.daallo.com/xbe/public/showLogin.action</a>.
  In such websites, a new window pops up allowing the user to enter his/her FB credentials. Then the popup closes and the website let you enter.
  In my implementation the popup does appear, but once approved it stays open with no content (testing with the Dev-Tools shows it is no longer connected), and nothing happens in the parent window.</p>
  
  <pre><code>public class LifeSpanHandler : ILifeSpanHandler
  {     
      public void OnAfterCreated(IWebBrowser browserControl, IBrowser browser)
      {
  
      }
  
      public bool DoClose(IWebBrowser browserControl, IBrowser browser)
      {
          return false;
      }
  
      public void OnBeforeClose(IWebBrowser browserControl, IBrowser browser)
      {
  
      }
  
      public bool OnBeforePopup(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, string targetFrameName, WindowOpenDisposition targetDisposition, bool userGesture, IPopupFeatures popupFeatures, IWindowInfo windowInfo, IBrowserSettings browserSettings, ref bool noJavascriptAccess, out IWebBrowser newBrowser)
      {
          //var chromiumWebBrowser = (ChromiumWebBrowser)browserControl;
          //var windowX = (windowInfo.X == int.MinValue) ? double.NaN : windowInfo.X;
          //var windowY = (windowInfo.Y == int.MinValue) ? double.NaN : windowInfo.Y;
          //var windowWidth = (windowInfo.Width == int.MinValue) ? double.NaN : windowInfo.Width;
          //var windowHeight = (windowInfo.Height == int.MinValue) ? double.NaN : windowInfo.Height;
  
          ChromiumWebBrowser chromiumBrowser = null;
          /*
             it is a website which have a scripts that start a new popup 
             on its first page and when I want to grab the handler of the 
             popup window in a new page the scripts of the page understand
             this and reopen a new popup window which I want to grab its 
             handler too.
          */
          chromiumBrowser = new ChromiumWebBrowser(targetUrl);
          chromiumBrowser.SetAsPopup();
          chromiumBrowser.LifeSpanHandler = this;
          newBrowser = chromiumBrowser;
          return true; //Infinite loop
      }
  }
  </code></pre>
  
  <p>Calling:</p>
  
  <pre><code>   browser = new ChromiumWebBrowser("http://reservations.daallo.com/xbe/public/showLogin.action");
     browser.LifeSpanHandler = new LifeSpanHandler();
  </code></pre>