/// <summary> /// Gets the nsIXPCComponents which is the javascript 'Components' objects /// The Components objects is the main object XPConnect object. /// </summary> /// <returns></returns> internal nsIXPCComponents GetComponentsObject() { if (_nsIXPCComponents == null) { var jsValue = new JsVal(); SpiderMonkey.JS_ExecuteScript(ContextPointer, "this.myfunc = function(p1) { return Components; };", out jsValue); jsValue = SpiderMonkey.JS_CallFunctionName(ContextPointer, _globalJSObject, "myfunc", new[] { jsValue }); _nsIXPCComponents = Xpcom.QueryInterface <nsIXPCComponents>(jsValue.ToObject()); if (_nsIXPCComponents == null) { throw new GeckoException(String.Format( "Components object does not implement nsIXPCComponents. {0}", jsValue)); } } return(_nsIXPCComponents); }
/// <summary> /// Gets the nsIXPCComponents which is the javascript 'Components' objects /// The Components objects is the main object XPConnect object. /// </summary> /// <returns></returns> public nsIXPCComponents GetComponentsObject() { if (_nsIXPCComponents == null) { string javaScript = "Components"; var jsValue = new JsVal(); var ret = SpiderMonkey.JS_EvaluateScript(_cx, PeekCompartmentScope(), javaScript, (uint)javaScript.Length, "script", 1, ref jsValue); if (!ret || !jsValue.IsObject) { return(null); } _nsIXPCComponents = jsValue.ToObject() as nsIXPCComponents; } return(_nsIXPCComponents); }