Linux Mac OSX Windows

  
[uuid(b2ddc328-194b-45d6-95c6-52e487438096)]
interface nsIXPConnect : nsISupports

Constants


        
const PRUint32 INIT_JS_STANDARD_CLASSES = 1

        
const PRUint32 FLAG_SYSTEM_GLOBAL_OBJECT = 2

        
const PRUint32 OMIT_COMPONENTS_OBJECT = 4
 Tells updateXOWs to clear the scope of all of the XOWs it finds.
const PRUint32 XPC_XOW_CLEARSCOPE = 1

Attributes


        
readonly attribute nsIStackFrame CurrentJSStack

        
readonly attribute nsAXPCNativeCallContextPtr CurrentNativeCallContext

        
attribute nsIException PendingException

Methods

 Root JS objects held by aHolder.
 @param aHolder The object that hold the JS objects that should be rooted.
 @param aTrace The tracer for aHolder.
[noscript] void addJSHolder(in voidPtr aHolder, in nsScriptObjectTracerPtr aTracer)

        
void clearAllWrappedNativeSecurityPolicies()
 Create a sandbox for evaluating code in isolation using
 evalInSandboxObject().

 @param cx A context to use when creating the sandbox object.
 @param principal The principal (or NULL to use the null principal)
                  to use when evaluating code in this sandbox.
[noscript] nsIXPConnectJSObjectHolder createSandbox(in JSContextPtr cx, in nsIPrincipal principal)

        
nsIStackFrame createStackFrameLocation(in PRUint32 aLanguage, in string aFilename, in string aFunctionName, in PRInt32 aLineNumber, in nsIStackFrame aCaller)

        
void debugDump(in short depth)

        
void debugDumpEvalInJSStackFrame(in PRUint32 aFrameNumber, in string aSourceText)

        
void debugDumpJSStack(in PRBool showArgs, in PRBool showLocals, in PRBool showThisProps)

        
void debugDumpObject(in nsISupports aCOMObj, in short depth)
 Define quick stubs on the given object, @a proto.

 @param cx
     A context.  Requires request.
 @param proto
     The (newly created) prototype object for a DOM class.  The JS half
     of an XPCWrappedNativeProto.
 @param flags
     Property flags for the quick stub properties--should be either
     JSPROP_ENUMERATE or 0.
 @param interfaceCount
     The number of interfaces the class implements.
 @param interfaceArray
     The interfaces the class implements; interfaceArray and
     interfaceCount are like what nsIClassInfo.getInterfaces returns.
[noscript, notxpcom] PRBool defineDOMQuickStubs(in JSContextPtr cx, in JSObjectPtr proto, in PRUint32 flags, in PRUint32 interfaceCount, [array, size_is(interfaceCount)] in nsIIDPtr interfaceArray)
 Evaluate script in a sandbox, completely isolated from all
 other running scripts.

 @param source The source of the script to evaluate.
 @param cx The context to use when setting up the evaluation of
           the script. The actual evaluation will happen on a new
           temporary context.
 @param sandbox The sandbox object to evaluate the script in.
 @param returnStringOnly The only results to come out of the
                         computation (including exceptions) will
                         be coerced into strings created in the
                         sandbox.
 @return The result of the evaluation as a jsval. If the caller
         intends to use the return value from this call the caller
         is responsible for rooting the jsval before making a call
         to this method.
[noscript] JSVal evalInSandboxObject(in AString source, in JSContextPtr cx, in nsIXPConnectJSObjectHolder sandbox, in PRBool returnStringOnly)
 Preconfigure XPCNativeWrapper automation so that when a scripted
 caller whose filename starts with filenamePrefix accesses a wrapped
 native that is not flagged as "system", the wrapped native will be
 automatically wrapped with an XPCNativeWrapper.

 @param aFilenamePrefix the UTF-8 filename prefix to match, which
                        should end with a slash (/) character
 @param aWantNativeWrappers whether XPConnect should produce native
                            wrappers for scripts whose paths begin
                            with this prefix
void flagSystemFilenamePrefix(in string aFilenamePrefix, in PRBool aWantNativeWrappers)

        
void getDefaultSecurityManager(out nsIXPCSecurityManager aManager, out PRUint16 flags)

        
nsIXPCFunctionThisTranslator getFunctionThisTranslator(in nsIIDRef aIID)

        
void getSecurityManagerForJSContext(in JSContextPtr aJSContext, out nsIXPCSecurityManager aManager, out PRUint16 flags)
 This only succeeds if the JSObject is a nsIXPConnectWrappedNative.
 A new wrapper is *never* constructed.
nsIXPConnectWrappedNative getWrappedNativeOfJSObject(in JSContextPtr aJSContext, in JSObjectPtr aJSObj)
 This only succeeds if the native object is already wrapped by xpconnect.
 A new wrapper is *never* constructed.
nsIXPConnectWrappedNative getWrappedNativeOfNativeObject(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsISupports aCOMObj, in nsIIDRef aIID)

        
nsIXPConnectJSObjectHolder getWrappedNativePrototype(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsIClassInfo aClassInfo)
 Returns a XPCNativeWrapper, XPCSafeJSObjectWrapper, or
 XPCCrossOriginWrapper for the given object based on the principal, scope,
 and filename flags that are passed in.

 Note: In C++, the out jsval parameter must already be a strong GC root.

 @param aJSContext
     A JSContext.
 @param aObject
     The object to wrap.
 @param aScope
     The scope to be used in the event that we create a
     XPCCrossOriginWrapper. Can be null.
 @param aPrincipal
     The principal that should be used for the wrapper. If this parameter
     is given then aFilenameFlags will not be calculated and will be
     assumed to be 0 unless another value is given. If this parameter is
     null then aFilenameFlags will be calculated and the value of that
     argument will be ignored.
 @param aFilenameFlags
     The filename flags from the script that will use this wrapper. See
     above (aPrincipal) for details.
[noscript] JSVal getWrapperForObject(in JSContextPtr aJSContext, in JSObjectPtr aObject, in JSObjectPtr aScope, in nsIPrincipal aPrincipal, in unsigned long aFilenameFlags)
 Wrap a jsval in a cross origin wrapper.
 @param aJSContext A context to use to create objects.
 @param aParent The parent to create the wrapper with.
 @param aWrappedObj The object to wrap.
[noscript] JSVal getXOWForObject(in JSContextPtr aJSContext, in JSObjectPtr aParent, in JSObjectPtr aWrappedObj)
 Get the JSClass and JSGetObjectOps pointers to use for
 identifying JSObjects that hold nsIXPConnectWrappedNative
 pointers in their private date. See IS_WRAPPER_CLASS in
 xpcprivate.h for details.
void GetXPCWrappedNativeJSClassInfo(out JSClassConstPtr clazz, out JSGetObjectOps ops1, out JSGetObjectOps ops2)

        
void initClasses(in JSContextPtr aJSContext, in JSObjectPtr aGlobalJSObj)

        
nsIXPConnectJSObjectHolder initClassesWithNewWrappedGlobal(in JSContextPtr aJSContext, in nsISupports aCOMObj, in nsIIDRef aIID, in PRUint32 aFlags)

        
nsIVariant JSToVariant(in JSContextPtr ctx, in JSVal value)
 Note aJSContext as a child to the cycle collector.
 @param aJSContext The JSContext to note.
 @param aCb The cycle collection traversal callback.
[noscript, notxpcom] void noteJSContext(in JSContextPtr aJSContext, in nsCCTraversalCallbackRef aCb)

        
void releaseJSContext(in JSContextPtr aJSContext, in PRBool noGC)
 Stop rooting the JS objects held by aHolder.
 @param aHolder The object that hold the rooted JS objects.
[noscript] void removeJSHolder(in voidPtr aHolder)

        
void reparentScopeAwareWrappers(in JSContextPtr aJSContext, in JSObjectPtr aOldScope, in JSObjectPtr aNewScope)

        
nsIXPConnectJSObjectHolder reparentWrappedNativeIfFound(in JSContextPtr aJSContext, in JSObjectPtr aScope, in JSObjectPtr aNewParent, in nsISupports aCOMObj)
 Restore an old prototype for wrapped natives of type
 aClassInfo. This should be used only when restoring an old
 scope into a state close to where it was prior to
 being reinitialized.
void restoreWrappedNativePrototype(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsIClassInfo aClassInfo, in nsIXPConnectJSObjectHolder aPrototype)
 The security manager to use when the current JSContext has no security
 manager.
void setDefaultSecurityManager(in nsIXPCSecurityManager aManager, in PRUint16 flags)

        
nsIXPCFunctionThisTranslator setFunctionThisTranslator(in nsIIDRef aIID, in nsIXPCFunctionThisTranslator aTranslator)
 Whether or not XPConnect should report all JS exceptions when returning
 from JS into C++. False by default, although any value set in the
 MOZ_REPORT_ALL_JS_EXCEPTIONS environment variable will override the value
 passed here.
void setReportAllJSExceptions(in boolean reportAllJSExceptions)
 Set fallback JSContext to use when xpconnect can't find an appropriate
 context to use to execute JavaScript.

 NOTE: This method is DEPRECATED. 
       Use nsIThreadJSContextStack::safeJSContext instead.
void setSafeJSContextForCurrentThread(in JSContextPtr cx)

        
void setSecurityManagerForJSContext(in JSContextPtr aJSContext, in nsIXPCSecurityManager aManager, in PRUint16 flags)
 Deprecated do-nothing function.
void syncJSContexts()
 Performs an operation over all of |object|'s XOWs such as clearing
 their scopes or updating their concept of the current principal.

 @param aJSContext A context to use to perform JS operations.
 @param aObject Which XPCWrappedNative we should find the XOWs for.
 @param aWay What operation to perform.
[noscript] void updateXOWs(in JSContextPtr aJSContext, in nsIXPConnectWrappedNative aObject, in PRUint32 aWay)

        
JSVal variantToJS(in JSContextPtr ctx, in JSObjectPtr scope, in nsIVariant value)
 wrapJS will yield a new or previously existing xpcom interface pointer
 to represent the JSObject passed in.

 This method now correctly deals with cases where the passed in JSObject
 already has an associated xpcom interface for the cases:
  1) The JSObject has already been wrapped as a nsIXPConnectWrappedJS.
  2) The JSObject is in fact a nsIXPConnectWrappedNative and thus already
     has an underlying xpcom object.
  3) The JSObject is of a jsclass which supports getting the nsISupports
     from the JSObject directly. This is used for idlc style objects
     (e.g. DOM objects).

 It *might* be possible to QueryInterface the resulting interface pointer
 to nsIXPConnectWrappedJS.

 Returns:
   success:
     NS_OK
    failure:
       NS_ERROR_XPC_BAD_CONVERT_JS
       NS_ERROR_FAILURE
void wrapJS(in JSContextPtr aJSContext, in JSObjectPtr aJSObj, in nsIIDRef aIID, [iid_is(aIID), retval] out nsQIResult result)
 wrapJSAggregatedToNative is just like wrapJS except it is used in cases
 where the JSObject is also aggregated to some native xpcom Object.
 At present XBL is the only system that might want to do this.

 XXX write more!

 Returns:
   success:
     NS_OK
    failure:
       NS_ERROR_XPC_BAD_CONVERT_JS
       NS_ERROR_FAILURE
void wrapJSAggregatedToNative(in nsISupports aOuter, in JSContextPtr aJSContext, in JSObjectPtr aJSObj, in nsIIDRef aIID, [iid_is(aIID), retval] out nsQIResult result)
 wrapNative will create a new JSObject or return an existing one.

 The JSObject is returned inside a refcounted nsIXPConnectJSObjectHolder.
 As long as this holder is held the JSObject will be protected from
 collection by JavaScript's garbage collector. It is a good idea to
 transfer the JSObject to some equally protected place before releasing
 the holder (i.e. use JS_SetProperty to make this object a property of
 some other JSObject).

 This method now correctly deals with cases where the passed in xpcom
 object already has an associated JSObject for the cases:
  1) The xpcom object has already been wrapped for use in the same scope
     as an nsIXPConnectWrappedNative.
  2) The xpcom object is in fact a nsIXPConnectWrappedJS and thus already
     has an underlying JSObject.
  3) The xpcom object implements nsIScriptObjectOwner; i.e. is an idlc
     style DOM object for which we can call GetScriptObject to get the
     JSObject it uses to represent itself into JavaScript.

 It *might* be possible to QueryInterface the nsIXPConnectJSObjectHolder
 returned by the method into a nsIXPConnectWrappedNative or a
 nsIXPConnectWrappedJS.

 This method will never wrap the JSObject involved in an
 XPCNativeWrapper before returning.

 Returns:
    success:
       NS_OK
    failure:
       NS_ERROR_XPC_BAD_CONVERT_NATIVE
       NS_ERROR_XPC_CANT_GET_JSOBJECT_OF_DOM_OBJECT
       NS_ERROR_FAILURE
nsIXPConnectJSObjectHolder wrapNative(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsISupports aCOMObj, in nsIIDRef aIID)
 Same as wrapNative, but also returns the JSObject in aVal. C++ callers
 can pass in null for the aHolder argument, but in that case they must
 ensure that aVal is rooted.
 aIID may be null, it means the same as passing in
 &NS_GET_IID(nsISupports) but when passing in null certain shortcuts
 can be taken because we know without comparing IIDs that the caller is
 asking for an nsISupports wrapper.
void wrapNativeToJSVal(in JSContextPtr aJSContext, in JSObjectPtr aScope, in nsISupports aCOMObj, in nsIIDPtr aIID, out JSVal aVal, out nsIXPConnectJSObjectHolder aHolder)