Example #1
0
        private void Gecko_DocumentCompleted(object sender, EventArgs e)
        {
            //调JQuery
            var executor = new Gecko.JQuery.JQueryExecutor(gecko.Window); //先获取到jquery对象

            executor.ExecuteJQuery("$('#btn').click()");                  //然后执行jquery的代码

            //调JS
            using (AutoJSContext context = new AutoJSContext(gecko.Window.JSContext))
            {
                //string str = this.label.Text.ToString();
                string title = "(winform向js传值)winform与gecko互动测试TESTTESTTESTTESTTEST!!!!!!";
                JsVal  jv    = context.EvaluateScript(@"print('" + title + "')", (nsIDOMWindow)gecko.Window.DomWindow);
                strTitle        = jv.ToString();
                this.label.Text = strTitle;
                int   a   = 5;
                JsVal jv2 = context.EvaluateScript(@"getTotal(" + a + ")", (nsIDOMWindow)gecko.Window.DomWindow);
                int   tt  = jv2.ToInteger();
                //string result;
                //context.EvaluateScript("3 + 2;", out result);
                //context.EvaluateScript("'hello' + ' ' + 'world';", out result);
                //context.EvaluateScript("document.write('f');", out result);
                //context.EvaluateScript(@"window.alert('alert')", out result);
                //context.EvaluateScript(@"window.alert('alert')", (nsISupports)gecko.Window.DomWindow, out result);
            }
            progressBar1.Value = 0;
        }
Example #2
0
        public void ToString_OnBoolJsVal_ReturnsNumberContentsConvertedToAString()
        {
            JsVal stringJsVal = SpiderMonkeyTests.CreateBoolJsVal(false);

            Assert.AreEqual("false", stringJsVal.ToString());
        }
Example #3
0
        public void ToString_OnNumberJsVal_ReturnsNumberContentsConvertedToAString()
        {
            JsVal stringJsVal = SpiderMonkeyTests.CreateNumberJsVal(23);

            Assert.AreEqual("23", stringJsVal.ToString());
        }
Example #4
0
        public void ToString_OnStringJsVal_ReturnsStringContents()
        {
            JsVal stringJsVal = SpiderMonkeyTests.CreateStringJsVal("hello world");

            Assert.AreEqual("hello world", stringJsVal.ToString());
        }