Ejemplo n.º 1
0
 public void PeekCompartmentScope_NotContextHaveBeenPushed_ReturnsGlobalContext()
 {
     using (var context = new AutoJSContext())
     {
         var globalObject = SpiderMonkey.DefaultObjectForContextOrNull(context.ContextPointer);
         Assert.AreEqual(context.PeekCompartmentScope(), globalObject);
     }
 }
Ejemplo n.º 2
0
        public void PushCompartmentScope_PushANewScopeObject_PeekNoLongerReturnsGlobalContext()
        {
            _browser.TestLoadHtml("hello world");
            using (var context = new AutoJSContext(_browser.Window.JSContext))
            {
                context.PushCompartmentScope((nsISupports)_browser.Window.DomWindow);

                var globalObject = SpiderMonkey.DefaultObjectForContextOrNull(context.ContextPointer);
                Assert.AreNotEqual(context.PeekCompartmentScope(), globalObject);
            }
        }
Ejemplo n.º 3
0
        private static JsVal CreateJsVal(AutoJSContext cx, string jscript)
        {
            if (cx == null)
            {
                return(CreateJsVal(jscript));
            }

            var    ptr   = new JsVal();
            IntPtr scope = cx.PeekCompartmentScope();
            bool   ret   = SpiderMonkey.JS_EvaluateScript(cx.ContextPointer, scope, jscript, (uint)jscript.Length, "script", 1, ref ptr);

            Assert.IsTrue(ret);
            return(ptr);
        }