Example #1
0
        public void FindInterfaceWithMember_OnAWindowElementLookingForNameMethod_ReturnsInterfaceThatContainsMethodNode()
        {
            _browser.TestLoadHtml("hello world");
            using (var context = new AutoJSContext(_browser.Window))
            {
                var jsValWindow = context.EvaluateScript("this");
                var jsVal       = SpiderMonkeyTests.CreateStringJsVal(context, "name");
                var jsObject    = SpiderMonkey.JS_ValueToObject(context.ContextPointer, jsValWindow);
                var a           = m_instance.GetWrappedNativeOfJSObject(context.ContextPointer, jsObject);

                // Perform the test.
                var i = a.FindInterfaceWithMember(ref jsVal.AsPtr);

                Assert.NotNull(i);
                Assert.IsTrue(i.IsScriptable());
                Assert.AreEqual("nsIDOMWindow", i.GetNameShared());
            }
        }
Example #2
0
        public void FindInterfaceWithName_OnAWindowElementLookingForADOMWindowInterface_ReturnsExpectedInterface()
        {
            _browser.TestLoadHtml("hello world");
            using (var context = new AutoJSContext(_browser.Window.JSContext))
            {
                context.PushCompartmentScope((nsISupports)_browser.Window.DomWindow);
                var jsValWindow = context.EvaluateScript("this");
                var jsVal       = SpiderMonkeyTests.CreateStringJsVal(context, "nsIDOMWindow");
                var jsObject    = SpiderMonkey.JS_ValueToObject(context.ContextPointer, jsValWindow);
                var a           = m_instance.GetWrappedNativeOfJSObject(context.ContextPointer, jsObject);

                // Perform the test
                var i = a.FindInterfaceWithName(ref jsVal.AsPtr);

                Assert.NotNull(i);
                Assert.IsTrue(i.IsScriptable());
                Assert.AreEqual("nsIDOMWindow", i.GetNameShared());
            }
        }
Example #3
0
        public void IsString_OnNumberJsVal_RetrunsFalse()
        {
            JsVal numberJsVal = SpiderMonkeyTests.CreateNumberJsVal(23);

            Assert.IsFalse(numberJsVal.IsString);
        }
Example #4
0
        public void IsString_OnStringJsVal_RetrunsTrue()
        {
            JsVal stringJsVal = SpiderMonkeyTests.CreateStringJsVal("hello world");

            Assert.IsTrue(stringJsVal.IsString);
        }
Example #5
0
        public void Type_OnNumberJsVal_ReturnsNumberType()
        {
            JsVal numberJsVal = SpiderMonkeyTests.CreateNumberJsVal(23);

            Assert.AreEqual(JSType.JSTYPE_NUMBER, numberJsVal.Type);
        }
Example #6
0
        public void Type_OnStringJsVal_RetrunsStringType()
        {
            JsVal stringJsVal = SpiderMonkeyTests.CreateStringJsVal("hello world");

            Assert.AreEqual(JSType.JSTYPE_STRING, stringJsVal.Type);
        }
Example #7
0
        public void ToString_OnBoolJsVal_ReturnsNumberContentsConvertedToAString()
        {
            JsVal stringJsVal = SpiderMonkeyTests.CreateBoolJsVal(false);

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

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

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