Skip to content

WinForms - DefaultFocusHandler.OnGotFocus NullReferenceException when JS print from popup #2725

@c2msis

Description

@c2msis
  • What version of the product are you using?

    • 73.1.120-pre01
  • What architecture x86 or x64?

    • x86
  • On what operating system?

    • Win10
  • Are you using WinForms, WPF or OffScreen?

    • WinForms
  • What steps will reproduce the problem?

    • Open a website with one button with a javascript function, eg.: javascript:CallPrint('name','email');

      Function Code:

function CallPrint(name,email)
{
var printWin=window.open('','','letf=0,top=0,width=600,height=400,toolbar=0,scrollbars=1,status=0');
printWin.document.writeln("<html><body><head></head>");
printWin.document.write("<table align=center ><tr><td align=center></td></tr><tr><td><h3 class=PagTitle>Print this</h3>");
printWin.document.write("<b>Name:</b> "+niss+"<br>");
printWin.document.write("<b>Email:</b> "+nome+"<br>");
printWin.document.write("</td></tr>");
printWin.document.write("<tr><td><table align=center width=400px><tr><td align=center><br><br><br>");
printWin.document.writeln("</td></tr></table></td></tr></table>");
printWin.document.writeln("</body></html>");
printWin.document.close();
printWin.focus();
loadPrint(printWin);}
  • What is the expected output?
    A new window with the preview and the option to print:
    Result

-What do you see instead?

  • It crashes

System.NullReferenceException
HResult=0x80004003
Message=A referência de objecto não foi definida como uma instância de um objecto. Source=CefSharp.WinForms StackTrace:
at CefSharp.WinForms.Internals.DefaultFocusHandler.OnGotFocus(IWebBrowser chromiumWebBrowser, IBrowser browser) at
CefSharp.Internals.ClientAdapter.OnGotFocus(ClientAdapter* , scoped_refptr* browser)

  • Please provide any additional information below.

    • Does the cef log provide any relevant information? (By default there should be a debug.log file in your bin directory)

[0416/145422.219:INFO:CONSOLE(93)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source: [0416/145428.938:INFO:CONSOLE(403)] "Tue Apr 16 2019 14:54:28 GMT+0100 (Western European Summer Time) Atmosphere: beforeunload event", source: [0416/145430.356:INFO:CONSOLE(403)] "Tue Apr 16 2019 14:54:30 GMT+0100 (Western European Summer Time) Atmosphere: unload event", source: [0416/145430.630:INFO:CONSOLE(93)] "Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user's experience. For more help, check https://xhr.spec.whatwg.org/.", source:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions