added a binding test page to CefSharp.Example

This commit is contained in:
chillitom
2010-12-14 20:16:45 +08:00
committed by Dmitry Azaraev
parent 24983d67ab
commit 97b26909c5
7 changed files with 89 additions and 1 deletions
+11 -1
View File
@@ -45,6 +45,7 @@
this.testRunArbitraryJavaScriptToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.testSchemeHandlerToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.testConsoleMessagesToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.testBingCLRObjectToJSToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripContainer.TopToolStripPanel.SuspendLayout();
this.toolStripContainer.SuspendLayout();
this.toolStrip1.SuspendLayout();
@@ -165,7 +166,8 @@
this.testRunJsSynchronouslyToolStripMenuItem,
this.testRunArbitraryJavaScriptToolStripMenuItem,
this.testSchemeHandlerToolStripMenuItem,
this.testConsoleMessagesToolStripMenuItem});
this.testConsoleMessagesToolStripMenuItem,
this.testBingCLRObjectToJSToolStripMenuItem});
this.testsToolStripMenuItem.Name = "testsToolStripMenuItem";
this.testsToolStripMenuItem.Size = new System.Drawing.Size(46, 20);
this.testsToolStripMenuItem.Text = "Tests";
@@ -205,6 +207,13 @@
this.testConsoleMessagesToolStripMenuItem.Text = "Test Console Messages";
this.testConsoleMessagesToolStripMenuItem.Click += new System.EventHandler(this.TestConsoleMessagesToolStripMenuItemClick);
//
// testBingCLRObjectToJSToolStripMenuItem
//
this.testBingCLRObjectToJSToolStripMenuItem.Name = "testBingCLRObjectToJSToolStripMenuItem";
this.testBingCLRObjectToJSToolStripMenuItem.Size = new System.Drawing.Size(224, 22);
this.testBingCLRObjectToJSToolStripMenuItem.Text = "Test Bing CLR object to JS";
this.testBingCLRObjectToJSToolStripMenuItem.Click += new System.EventHandler(this.TestBingClrObjectToJsToolStripMenuItemClick);
//
// Browser
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -247,6 +256,7 @@
private System.Windows.Forms.ToolStripMenuItem testRunArbitraryJavaScriptToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem testSchemeHandlerToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem testConsoleMessagesToolStripMenuItem;
private System.Windows.Forms.ToolStripMenuItem testBingCLRObjectToJSToolStripMenuItem;
}
}
+5
View File
@@ -178,5 +178,10 @@ namespace CefSharp.Example
{
MessageBox.Show(e.Source + ":" + e.Line + " " + e.Message, "JavaScript console message");
}
private void TestBingClrObjectToJsToolStripMenuItemClick(object sender, EventArgs e)
{
_browserControl.Load("test://test/BindingTest.html");
}
}
}
+1
View File
@@ -126,6 +126,7 @@
<None Include="Resources\chromium-256.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Resources\BindingTest.html" />
<Content Include="Resources\SchemeTest.html" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+28
View File
@@ -60,6 +60,34 @@ namespace CefSharp.Example.Properties {
}
}
/// <summary>
/// Looks up a localized string similar to &lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;
///&lt;html&gt;
/// &lt;head&gt;
/// &lt;title&gt;&lt;/title&gt;
/// &lt;/head&gt;
/// &lt;body&gt;
/// &lt;p&gt;
/// Result of calling bound.Repeat(&quot;hi &quot;, 5) =
/// &lt;script type=&quot;text/javascript&quot;&gt;
/// var result = bound.Repeat(&quot;hi &quot;, 5);
/// document.write(&apos;&quot;&apos; + result + &apos;&quot;&apos;);
/// if(result == &quot;hi hi hi hi hi &quot;)
/// {
/// document.write(&quot; SUCCESS&quot;);
/// }
/// else
/// {
/// document.write(&quot; FAIL!&quot;);
/// }
/// [rest of string was truncated]&quot;;.
/// </summary>
internal static string BindingTest {
get {
return ResourceManager.GetString("BindingTest", resourceCulture);
}
}
internal static System.Drawing.Bitmap chromium256 {
get {
object obj = ResourceManager.GetObject("chromium256", resourceCulture);
@@ -136,4 +136,7 @@
<data name="SchemeTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\SchemeTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
<data name="BindingTest" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\BindingTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
</data>
</root>
@@ -0,0 +1,32 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Binding Test</title>
</head>
<body>
<p>
Result of calling bound.Repeat("hi ", 5) =
<script type="text/javascript">
var result = bound.Repeat("hi ", 5);
document.write('"' + result + '"');
if(result == "hi hi hi hi hi ")
{
document.write(" SUCCESS");
}
else
{
document.write(" FAIL!");
}
</script>
</p>
Methods on bound object 'bound':<br />
<ul>
<script type="text/javascript">
for(var name in bound) {
document.write("<li>" + name + "</li>");
}
</script>
</ul>
</body>
</html>
+9
View File
@@ -17,6 +17,15 @@ namespace CefSharp.Example
mimeType = "text/html";
return true;
}
if (request.Url.EndsWith("BindingTest.html", StringComparison.OrdinalIgnoreCase))
{
byte[] bytes = Encoding.UTF8.GetBytes(Resources.BindingTest);
stream = new MemoryStream(bytes);
mimeType = "text/html";
return true;
}
return false;
}
}