Esempio n. 1
0
 public void PeekCompartmentScope_NotContextHaveBeenPushed_ReturnsGlobalContext()
 {
     using (var context = new AutoJSContext())
     {
         var globalObject = SpiderMonkey.DefaultObjectForContextOrNull(context.ContextPointer);
         Assert.AreEqual(context.PeekCompartmentScope(), globalObject);
     }
 }
Esempio 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);
            }
        }
Esempio n. 3
0
        public IEnumerable <KeyValuePair <string, Action <IntPtr> > > EntryPoints()
        {
            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EncodeString", (c) => SpiderMonkey.JS_EncodeString(IntPtr.Zero, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_TypeOfValue", (c) => SpiderMonkey.JS_TypeOfValue(IntPtr.Zero, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ValueToString", (c) => SpiderMonkey.JS_ValueToString(IntPtr.Zero, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ValueToObject", (c) => SpiderMonkey.JS_ValueToObject(IntPtr.Zero, default(JsVal))));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewStringCopyN", (c) => SpiderMonkey.JS_NewStringCopyN(c, "", 0)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetGlobalForObject", (c) => SpiderMonkey.JS_GetGlobalForObject(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("GetGlobalForObjectCrossCompartment", (c) => SpiderMonkey.GetGlobalForObjectCrossCompartment(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SaveFrameChain", (c) => SpiderMonkey.JS_SaveFrameChain(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewObject", (c) => SpiderMonkey.JS_NewObject(c, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetParent", (c) => SpiderMonkey.JS_GetParent(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetScriptedGlobal", (c) => SpiderMonkey.JS_GetScriptedGlobal(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("CurrentGlobalOrNull", (c) => SpiderMonkey.CurrentGlobalOrNull(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_NewContext", (c) => SpiderMonkey.JS_NewContext(IntPtr.Zero, 0)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetRuntime", (c) => SpiderMonkey.JS_GetRuntime(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetContextPrivate", (c) => SpiderMonkey.JS_GetContextPrivate(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetContextPrivate", (c) => SpiderMonkey.JS_SetContextPrivate(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("DefaultObjectForContextOrNull", (c) => SpiderMonkey.DefaultObjectForContextOrNull(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_BeginRequest", (c) => SpiderMonkey.JS_BeginRequest(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EndRequest", (c) => SpiderMonkey.JS_EndRequest(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EvaluateScript", (c) =>
            {
                var jsVal = new JsVal();
                SpiderMonkey.JS_EvaluateScript(c, IntPtr.Zero, "", 0, "", 0, ref jsVal);
            }));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EvaluateScriptForPrincipals", (c) =>
            {
                var jsVal = new JsVal();
                SpiderMonkey.JS_EvaluateScriptForPrincipals(c, IntPtr.Zero, IntPtr.Zero, "", 0, "", 0, ref jsVal);
            }));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetClassObject", (c) => SpiderMonkey.JS_GetClassObject(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetClass", (c) => SpiderMonkey.JS_GetClass(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_ContextIterator", (c) =>
            {
                var pt = IntPtr.Zero;
                SpiderMonkey.JS_ContextIterator(IntPtr.Zero, ref pt);
            }));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetContextCallback", (c) => SpiderMonkey.JS_SetContextCallback(IntPtr.Zero, null)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_EnterCompartment", (c) => SpiderMonkey.JS_EnterCompartment(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_LeaveCompartment", (c) => SpiderMonkey.JS_LeaveCompartment(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_Free", (c) => SpiderMonkey.JS_Free(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_WrapObject", (c) => SpiderMonkey.JS_WrapObject(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("IsObjectInContextCompartment", (c) => SpiderMonkey.IsObjectInContextCompartment(IntPtr.Zero, c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_DestroyRuntime", (c) => SpiderMonkey.JS_DestroyRuntime(IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_HasProperty", (c) => SpiderMonkey.JS_HasProperty(c, IntPtr.Zero, "")));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetProperty", (c) => SpiderMonkey.JS_GetProperty(c, IntPtr.Zero, "")));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetCompartmentPrincipals", (c) => SpiderMonkey.JS_SetCompartmentPrincipals(c, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetCompartmentPrincipals", (c) => SpiderMonkey.JS_GetCompartmentPrincipals(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetTrustedPrincipals", (c) => SpiderMonkey.JS_SetTrustedPrincipals(IntPtr.Zero, IntPtr.Zero)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_GetPendingException", (c) => SpiderMonkey.JS_GetPendingException(c)));

            yield return(new KeyValuePair <string, Action <IntPtr> >("JS_SetErrorReporter", (c) => SpiderMonkey.JS_SetErrorReporter(c, (cx, message, report) => {})));
        }