CefSharp.Dom - Don't Dispose DevToolsContext

Disposing of the DevToolsContext is causing problems currently as sending the DevTools protocol messages
to the browser is happening after the CefBrowserHost instance has been Disposed.

A separate method of disposing of the DevToolsContext will need to be added that does a cleanup
without sending the commands.

Issue https://github.com/cefsharp/CefSharp.Dom/issues/41
This commit is contained in:
Alex Maitland
2022-09-12 11:03:09 +10:00
parent 303ad85449
commit b150993d67
2 changed files with 16 additions and 2 deletions
@@ -499,7 +499,7 @@ namespace CefSharp.WinForms
ResourceRequestHandlerFactory = null;
RenderProcessMessageHandler = null;
this.DisposeDevToolsContext();
this.FreeDevToolsContext();
}
/// <summary>
+15 -1
View File
@@ -1796,7 +1796,7 @@ namespace CefSharp
}
/// <summary>
/// Dispose of the DevTools Context (if any). Used in conjunction with CefSharp.Puppeteer
/// Dispose of the DevToolsContext (if any). Used in conjunction with CefSharp.Dom
/// </summary>
/// <param name="webBrowserInternal">ChromiumWebBrowser instance</param>
public static void DisposeDevToolsContext(this IWebBrowserInternal webBrowserInternal)
@@ -1810,6 +1810,20 @@ namespace CefSharp
webBrowserInternal.DevToolsContext = null;
}
/// <summary>
/// Set the <see cref="IWebBrowserInternal.DevToolsContext"/> property to null. Used in conjunction with CefSharp.Dom
/// </summary>
/// <param name="webBrowserInternal">ChromiumWebBrowser instance</param>
public static void FreeDevToolsContext(this IWebBrowserInternal webBrowserInternal)
{
if (webBrowserInternal == null)
{
return;
}
webBrowserInternal.DevToolsContext = null;
}
/// <summary>
/// Function used to encode the params passed to <see cref="ExecuteScriptAsync(IWebBrowser, string, object[])"/>,
/// <see cref="EvaluateScriptAsync(IWebBrowser, string, object[])"/> and