Skip to content

Commit d5c7477

Browse files
committed
Test - Add Test to verify workaround for issue #3470
1 parent e9a367f commit d5c7477

File tree

7 files changed

+63
-3
lines changed

7 files changed

+63
-3
lines changed

CefSharp.Example/CefExample.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static class CefExample
3838
public const string DragDropCursorsTestUrl = BaseUrl + "/DragDropCursorsTest.html";
3939
public const string CssAnimationTestUrl = BaseUrl + "/CssAnimationTest.html";
4040
public const string CdmSupportTestUrl = BaseUrl + "/CdmSupportTest.html";
41+
public const string HelloWorldUrl = BaseUrl + "/HelloWorld.html";
4142
public const string BindingApiCustomObjectNameTestUrl = BaseUrl + "/BindingApiCustomObjectNameTest.html";
4243
public const string TestResourceUrl = "http://test/resource/load";
4344
public const string RenderProcessCrashedUrl = "http://processcrashed";

CefSharp.Example/CefSharp.Example.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,7 @@
163163
<Content Include="Resources\BindingApiCustomObjectNameTest.html" />
164164
<Content Include="Resources\BindingTestSingle.html" />
165165
<Content Include="Resources\DragDropCursorsTest.html" />
166+
<Content Include="Resources\HelloWorld.html" />
166167
<Content Include="Resources\JavascriptCallbackTest.html" />
167168
<Content Include="Resources\LegacyBindingTest.html" />
168169
<Content Include="Resources\CdmSupportTest.html" />

CefSharp.Example/CefSharpSchemeHandlerFactory.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ static CefSharpSchemeHandlerFactory()
5959
{ "/UnocodeExampleEqualTo32kb.html", Resources.UnocodeExampleEqualTo32kb },
6060
{ "/JavascriptCallbackTest.html", Resources.JavascriptCallbackTest },
6161
{ "/BindingTestsAsyncTask.html", Resources.BindingTestsAsyncTask },
62-
{ "/BindingApiCustomObjectNameTest.html", Resources.BindingApiCustomObjectNameTest }
62+
{ "/BindingApiCustomObjectNameTest.html", Resources.BindingApiCustomObjectNameTest },
63+
{ "/HelloWorld.html", Resources.HelloWorld }
6364
};
6465
}
6566

CefSharp.Example/Properties/Resources.Designer.cs

Lines changed: 22 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CefSharp.Example/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,7 @@
232232
<data name="BindingTestNetCore" type="System.Resources.ResXFileRef, System.Windows.Forms">
233233
<value>..\Resources\BindingTestNetCore.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
234234
</data>
235+
<data name="HelloWorld" type="System.Resources.ResXFileRef, System.Windows.Forms">
236+
<value>..\Resources\HelloWorld.html;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252</value>
237+
</data>
235238
</root>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
3+
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
4+
<head>
5+
<meta charset="utf-8" />
6+
<title>Hello World</title>
7+
</head>
8+
<body>
9+
<p>Hello World</p>
10+
</body>
11+
</html>

CefSharp.Test/JavascriptBinding/IntegrationTestFacts.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
using System.Diagnostics;
66
using System.Threading.Tasks;
7+
using CefSharp.Event;
78
using CefSharp.Example;
89
using CefSharp.Example.JavascriptBinding;
10+
using CefSharp.Internals;
911
using CefSharp.OffScreen;
1012
using Xunit;
1113
using Xunit.Abstractions;
@@ -157,5 +159,26 @@ public async Task JsBindingRenderProcessId(string script)
157159
}
158160
}
159161
}
162+
163+
[Fact]
164+
//Issue https://github.com/cefsharp/CefSharp/issues/3470
165+
//Verify workaround passes
166+
public async Task CanCallCefSharpBindObjectAsyncWithoutParams()
167+
{
168+
using (var browser = new ChromiumWebBrowser(CefExample.HelloWorldUrl))
169+
{
170+
await browser.LoadPageAsync();
171+
172+
//TODO: See if we can avoid GetAwaiter().GetResult()
173+
var evt = Assert.Raises<JavascriptBindingEventArgs>(
174+
x => browser.JavascriptObjectRepository.ResolveObject += x,
175+
y => browser.JavascriptObjectRepository.ResolveObject -= y,
176+
() => { browser.EvaluateScriptAsync("CefSharp.BindObjectAsync({ IgnoreCache: true });").GetAwaiter().GetResult(); });
177+
178+
Assert.NotNull(evt);
179+
180+
Assert.Equal(JavascriptObjectRepository.AllObjects, evt.Arguments.ObjectName);
181+
}
182+
}
160183
}
161184
}

0 commit comments

Comments
 (0)