11using System ;
22using System . Drawing ;
3- using System . Net ;
43using System . Threading . Tasks ;
54using System . Windows . Forms ;
65using CefSharp . OutOfProcess . Internal ;
@@ -19,6 +18,7 @@ public class ChromiumWebBrowser : Control, IChromiumWebBrowserInternal
1918 private int _id ;
2019 private IDevToolsContext _devToolsContext ;
2120 private OutOfProcessConnectionTransport _devToolsContextConnectionTransport ;
21+ private bool _devToolsReady ;
2222
2323 /// <inheritdoc/>
2424 public event EventHandler DOMContentLoaded ;
@@ -56,6 +56,8 @@ public class ChromiumWebBrowser : Control, IChromiumWebBrowserInternal
5656 public event EventHandler < StatusMessageEventArgs > StatusMessage ;
5757 /// <inheritdoc/>
5858 public event EventHandler < ConsoleEventArgs > ConsoleMessage ;
59+ /// <inheritdoc/>
60+ public event EventHandler < LifecycleEventArgs > LifecycleEvent ;
5961
6062 public ChromiumWebBrowser ( OutOfProcessHost host , string initialAddress )
6163 {
@@ -81,6 +83,22 @@ protected override Size DefaultSize
8183 get { return new Size ( 640 , 480 ) ; }
8284 }
8385
86+ /// <summary>
87+ /// DevToolsContext - provides communication with the underlying browser
88+ /// </summary>
89+ public IDevToolsContext DevToolsContext
90+ {
91+ get
92+ {
93+ if ( _devToolsReady )
94+ {
95+ return _devToolsContext ;
96+ }
97+
98+ return default ;
99+ }
100+ }
101+
84102 /// <inheritdoc/>
85103 public bool IsBrowserInitialized => _browserHwnd != IntPtr . Zero ;
86104
@@ -104,8 +122,8 @@ protected override void OnHandleCreated(EventArgs e)
104122
105123 _devToolsContextConnectionTransport = new OutOfProcessConnectionTransport ( _id , _host ) ;
106124
107- var connection = Connection . Attach ( _devToolsContextConnectionTransport ) ;
108- _devToolsContext = DevToolsContext . CreateForOutOfProcess ( connection ) ;
125+ var connection = DevToolsConnection . Attach ( _devToolsContextConnectionTransport ) ;
126+ _devToolsContext = Puppeteer . DevToolsContext . CreateForOutOfProcess ( connection ) ;
109127 }
110128
111129 /// <inheritdoc/>
@@ -239,6 +257,8 @@ void IChromiumWebBrowserInternal.OnDevToolsMessage(string jsonMsg)
239257 /// <inheritdoc/>
240258 void IChromiumWebBrowserInternal . OnDevToolsReady ( )
241259 {
260+ _devToolsReady = true ;
261+
242262 var ctx = ( DevToolsContext ) _devToolsContext ;
243263
244264 ctx . DOMContentLoaded += DOMContentLoaded ;
0 commit comments