mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 10:22:55 +00:00
893d03221f
* fix IsComplexType NullReferenceException Sometimes, the registered Javascript object does not have a namespace, at this time this function will throw a ```NullReferenceException```. * add unit test for IsComplexType * Simplify and remove useless code * Update CefSharp/Internals/JavascriptObjectRepository.cs Co-authored-by: campersau <buchholz.bastian@googlemail.com> Co-authored-by: Alex Maitland <amaitland@users.noreply.github.com> Co-authored-by: campersau <buchholz.bastian@googlemail.com>
39 lines
1.0 KiB
C#
39 lines
1.0 KiB
C#
using CefSharp.Internals;
|
|
using Xunit;
|
|
|
|
internal class NoNamespaceClass
|
|
{
|
|
public SomeElseClass SomeElseClass { get; set; }
|
|
public int Year { get; set; }
|
|
|
|
public string GetExampleString()
|
|
{
|
|
return "ok";
|
|
}
|
|
}
|
|
|
|
internal class SomeElseClass
|
|
{
|
|
|
|
}
|
|
|
|
|
|
namespace CefSharp.Test.JavascriptBinding
|
|
{
|
|
public class JavaScriptObjectRepositoryFacts
|
|
{
|
|
[Fact]
|
|
public void CanRegisterJavascriptObjectBindWhenNamespaceIsNull()
|
|
{
|
|
var javascriptObjectRepository = new JavascriptObjectRepository();
|
|
var name = nameof(NoNamespaceClass);
|
|
javascriptObjectRepository.Register(name, new NoNamespaceClass(), false, new BindingOptions() { });
|
|
Assert.True(javascriptObjectRepository.IsBound(name));
|
|
|
|
var result = ((IJavascriptObjectRepositoryInternal)javascriptObjectRepository).TryCallMethod(1, "getExampleString", new object[0]);
|
|
Assert.True(result.Success);
|
|
Assert.Equal("ok", result.ReturnValue.ToString());
|
|
}
|
|
}
|
|
}
|