public bool EvaluateTrustedScript(string jsScript, out string result)
        {
            throw new NotImplementedException();

            var    ptr          = new JsVal();
            IntPtr globalObject = SpiderMonkey.JS_GetGlobalForScopeChain(_cx);
            bool   ret;
            IntPtr systemGlobalObject = SpiderMonkey.JS_GetGlobalForScopeChain(GlobalJSContextHolder.BackstageJSContext);
            // Compartments have to be entered and left in LIFO order.
            bool   inSystemCompartment = false;
            IntPtr oldCompartment      = IntPtr.Zero;

            try
            {
                // Allow access to any object on page.
                oldCompartment = SpiderMonkey.JS_EnterCompartment(_cx, systemGlobalObject);
                // At any time, a JSContext has a current (possibly-NULL) compartment.
                inSystemCompartment = true;
                ret    = SpiderMonkey.JS_EvaluateScript(_cx, globalObject, jsScript, (uint)jsScript.Length, "script", 1, ref ptr);
                result = ConvertValueToString(ptr);
            }
            finally
            {
                if (inSystemCompartment)
                {
                    SpiderMonkey.JS_LeaveCompartment(_cx, oldCompartment);
                }
            }
            return(ret);
        }
Example #2
0
        public JSAutoCompartment(IntPtr context, IntPtr obj)
        {
            if (context == IntPtr.Zero)
            {
                throw new ArgumentNullException("context");
            }
            if (context == IntPtr.Zero)
            {
                throw new ArgumentNullException("obj");
            }

            _obj            = obj;
            _oldCompartment = SpiderMonkey.JS_EnterCompartment(context, _obj);
            _cx             = context;
        }
Example #3
0
        public JSAutoCompartment(AutoJSContext context, nsISupports comObject)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (context.ContextPointer == IntPtr.Zero)
            {
                throw new ArgumentException("context has Null ContextPointer");
            }
            if (context == null)
            {
                throw new ArgumentNullException("comObject");
            }

            _obj            = context.ConvertCOMObjectToJSObject(comObject);
            _cx             = context.ContextPointer;
            _oldCompartment = SpiderMonkey.JS_EnterCompartment(_cx, _obj);
        }
Example #4
0
 private void EnterCompartment()
 {
     _oldCompartment = SpiderMonkey.JS_EnterCompartment(_cx, _obj);
 }