[Mono-bugs] [Bug 509337] New: System.Windows.Forms.HtmlDocument.InvokeScript bugs

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Tue Jun 2 21:11:13 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=509337


           Summary: System.Windows.Forms.HtmlDocument.InvokeScript bugs
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.4.x
          Platform: i586
        OS/Version: openSUSE 11.1
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: ctype at mail.ru
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; uk; rv:1.9.0.10)
Gecko/2009042700 SUSE/3.0.10-1.1.1 Firefox/3.0.10 (.NET CLR 3.5.30729)

Here few bugs related to 2.4.x and snapshot (Mono JIT compiler version 135169
(tarball Tue Jun  2 00:21:41 UTC 2009):
- InvokeScript return only first character of result, i.e. instead of "string"
returned "s", instead of true returned "t", instead of 100 returned '1'
- InvokeScript always return results as System.String 
- InvokeScript don't work with string arguments which contains inside singe or
double quotes
- InvokeScript don't work with boolean arguments as javascript don't understand
True\False but only true\false 

Reproducible: Always

Steps to Reproduce:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;





namespace RefreshAndWebBrowser
{
    public class TestForm : Form
    {

        private System.Windows.Forms.WebBrowser browser;

        void MainFormLoad(object sender, EventArgs e)
        {
            browser.Navigate(new Uri("http://www.google.com"));
            while(browser.ReadyState != WebBrowserReadyState.Complete)
                Application.DoEvents();

            Console.WriteLine("Check returning of different types by
InvokeScript");
            TestReturningValues("\"return SimpleText\"");
            TestReturningValues("true");
            TestReturningValues(100);

            Console.WriteLine();
            Console.WriteLine("Check InvokeScript with arguments with different
types");
            TestInvokeWithString("SimpleText");
            TestInvokeWithString("Text with single quote : ' ");
            TestInvokeWithString("Text with single quote fixed: \\\\\\\' ");
            TestInvokeWithString("Text with double quote : \" ");
            TestInvokeWithString("Text with double quote fixed : \\\\\\\" ");
            TestInvokeWithString(true);
            TestInvokeWithString("true");

            Application.Exit();
            Close();
        }

        void TestReturningValues(object argument)
        {
            Console.Write("Check returning of : " + argument.ToString());
            string res = (string)browser.Document.InvokeScript("true ? " +
argument + " : alert");
            if(res != null && res.Length > 0 && res == argument.ToString())
                Console.WriteLine(" - Result : " + res);
            else
                Console.WriteLine(" - Failed : " + res);
        }

        void TestInvokeWithString(object argument)
        {
            Console.Write("Check : " + argument.ToString());
            string res = (string)browser.Document.InvokeScript("encodeURI", new
object[]{argument});
            if(res != null && res.Length > 0)
                Console.WriteLine(" - Ok. Result : " + res);
            else
                Console.WriteLine(" - Failed");
        }


        [STAThread]
        private static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new TestForm());
        }

        public TestForm()
        {
            this.browser = new System.Windows.Forms.WebBrowser();
            this.SuspendLayout();
            this.browser.Dock = System.Windows.Forms.DockStyle.Fill;
            this.browser.Name = "browser";
            this.ClientSize = new System.Drawing.Size(292, 266);
            this.Controls.Add(this.browser);
            this.Name = "MainForm";
            this.Text = "SuspendLayoutAndWebBrowser";
            this.Load += MainFormLoad;            
            this.ResumeLayout(false);
        }



    }

}

Actual Results:  
Check returning of different types by InvokeScript
Check returning of : "return SimpleText" - Failed : r
Check returning of : true - Failed : t
Check returning of : 100 - Failed : 1

Check InvokeScript with arguments with different types
Check : SimpleText - Ok. Result : S
Check : Text with single quote : '  - Failed
Check : Text with single quote fixed: \\\'  - Ok. Result : T
Check : Text with double quote : "  - Failed
Check : Text with double quote fixed : \\\"  - Ok. Result : T
Check : True - Failed
Check : true - Ok. Result : t

Expected Results:  
Should pass all checks

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list