From 97b26909c52dca595dc7a388da14641620fe4e72 Mon Sep 17 00:00:00 2001 From: chillitom Date: Tue, 14 Dec 2010 20:16:45 +0800 Subject: [PATCH] added a binding test page to CefSharp.Example --- CefSharp.Example/Browser.Designer.cs | 12 ++++++- CefSharp.Example/Browser.cs | 5 +++ CefSharp.Example/CefSharp.Example.csproj | 1 + .../Properties/Resources.Designer.cs | 28 ++++++++++++++++ CefSharp.Example/Properties/Resources.resx | 3 ++ CefSharp.Example/Resources/BindingTest.html | 32 +++++++++++++++++++ CefSharp.Example/TestSchemeHandler.cs | 9 ++++++ 7 files changed, 89 insertions(+), 1 deletion(-) create mode 100644 CefSharp.Example/Resources/BindingTest.html diff --git a/CefSharp.Example/Browser.Designer.cs b/CefSharp.Example/Browser.Designer.cs index df308a6ef..99c1aa42f 100644 --- a/CefSharp.Example/Browser.Designer.cs +++ b/CefSharp.Example/Browser.Designer.cs @@ -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; } } \ No newline at end of file diff --git a/CefSharp.Example/Browser.cs b/CefSharp.Example/Browser.cs index 0ec8f1bab..666182437 100644 --- a/CefSharp.Example/Browser.cs +++ b/CefSharp.Example/Browser.cs @@ -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"); + } } } diff --git a/CefSharp.Example/CefSharp.Example.csproj b/CefSharp.Example/CefSharp.Example.csproj index 11ccf3047..4a87cc66f 100644 --- a/CefSharp.Example/CefSharp.Example.csproj +++ b/CefSharp.Example/CefSharp.Example.csproj @@ -126,6 +126,7 @@ + diff --git a/CefSharp.Example/Properties/Resources.Designer.cs b/CefSharp.Example/Properties/Resources.Designer.cs index 60c98c8ff..e88a996da 100644 --- a/CefSharp.Example/Properties/Resources.Designer.cs +++ b/CefSharp.Example/Properties/Resources.Designer.cs @@ -60,6 +60,34 @@ namespace CefSharp.Example.Properties { } } + /// + /// Looks up a localized string similar to <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> + ///<html> + /// <head> + /// <title></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!"); + /// } + /// [rest of string was truncated]";. + /// + internal static string BindingTest { + get { + return ResourceManager.GetString("BindingTest", resourceCulture); + } + } + internal static System.Drawing.Bitmap chromium256 { get { object obj = ResourceManager.GetObject("chromium256", resourceCulture); diff --git a/CefSharp.Example/Properties/Resources.resx b/CefSharp.Example/Properties/Resources.resx index 7af94e77a..b912ecb91 100644 --- a/CefSharp.Example/Properties/Resources.resx +++ b/CefSharp.Example/Properties/Resources.resx @@ -136,4 +136,7 @@ ..\Resources\SchemeTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + + ..\Resources\BindingTest.html;System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8 + \ No newline at end of file diff --git a/CefSharp.Example/Resources/BindingTest.html b/CefSharp.Example/Resources/BindingTest.html new file mode 100644 index 000000000..40a058e1c --- /dev/null +++ b/CefSharp.Example/Resources/BindingTest.html @@ -0,0 +1,32 @@ + + + + Binding Test + + +

+ Result of calling bound.Repeat("hi ", 5) = + +

+ + Methods on bound object 'bound':
+
    + +
+ + \ No newline at end of file diff --git a/CefSharp.Example/TestSchemeHandler.cs b/CefSharp.Example/TestSchemeHandler.cs index e7f6540df..34f8344c3 100644 --- a/CefSharp.Example/TestSchemeHandler.cs +++ b/CefSharp.Example/TestSchemeHandler.cs @@ -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; } }