2008-01-15 07:50:57 -08:00
|
|
|
/* -*- Mode: IDL; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
2007-03-22 10:30:00 -07:00
|
|
|
*
|
2012-05-21 04:12:37 -07:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/* The core XPConnect public interfaces. */
|
|
|
|
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
#include "nsIClassInfo.idl"
|
|
|
|
#include "xpccomponents.idl"
|
|
|
|
#include "xpcjsid.idl"
|
|
|
|
#include "xpcexception.idl"
|
|
|
|
#include "nsIInterfaceInfo.idl"
|
|
|
|
#include "nsIInterfaceInfoManager.idl"
|
|
|
|
#include "nsIExceptionService.idl"
|
|
|
|
#include "nsIVariant.idl"
|
2012-02-13 05:10:04 -08:00
|
|
|
#include "nsIObjectOutputStream.idl"
|
|
|
|
#include "nsIObjectInputStream.idl"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
%{ C++
|
|
|
|
#include "jspubtd.h"
|
|
|
|
#include "xptinfo.h"
|
2008-01-15 07:50:57 -08:00
|
|
|
#include "nsAXPCNativeCallContext.h"
|
2011-02-16 12:47:08 -08:00
|
|
|
|
|
|
|
class nsWrapperCache;
|
2007-03-22 10:30:00 -07:00
|
|
|
%}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
2010-07-14 23:19:36 -07:00
|
|
|
// NB: jsval and jsid are declared in nsIVariant.idl
|
2009-09-01 09:45:05 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
[ptr] native JSContextPtr(JSContext);
|
2009-12-16 16:51:06 -08:00
|
|
|
[ptr] native JSClassPtr(JSClass);
|
2012-03-19 07:34:55 -07:00
|
|
|
[ptr] native JSFreeOpPtr(JSFreeOp);
|
2007-03-22 10:30:00 -07:00
|
|
|
[ptr] native JSObjectPtr(JSObject);
|
|
|
|
[ptr] native JSValPtr(jsval);
|
2010-07-14 23:19:36 -07:00
|
|
|
[ptr] native JSValConstPtr(const jsval);
|
2010-03-18 18:00:58 -07:00
|
|
|
native JSPropertyOp(JSPropertyOp);
|
2009-05-12 13:20:42 -07:00
|
|
|
native JSEqualityOp(JSEqualityOp);
|
2012-02-13 05:10:04 -08:00
|
|
|
[ptr] native JSScriptPtr(JSScript);
|
2007-03-22 10:30:00 -07:00
|
|
|
[ptr] native voidPtrPtr(void*);
|
2007-10-29 06:45:07 -07:00
|
|
|
[ptr] native nsScriptObjectTracerPtr(nsScriptObjectTracer);
|
2007-11-01 15:51:57 -07:00
|
|
|
[ref] native nsCCTraversalCallbackRef(nsCycleCollectionTraversalCallback);
|
2008-01-15 07:50:57 -08:00
|
|
|
[ptr] native nsAXPCNativeCallContextPtr(nsAXPCNativeCallContext);
|
2010-05-10 11:53:05 -07:00
|
|
|
[ptr] native nsWrapperCachePtr(nsWrapperCache);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
// forward declarations...
|
|
|
|
interface nsIXPCScriptable;
|
|
|
|
interface nsIXPConnect;
|
|
|
|
interface nsIXPConnectWrappedNative;
|
|
|
|
interface nsIInterfaceInfo;
|
|
|
|
interface nsIXPCSecurityManager;
|
|
|
|
interface nsIPrincipal;
|
|
|
|
|
|
|
|
%{C++
|
2007-11-01 15:51:57 -07:00
|
|
|
class nsCycleCollectionTraversalCallback;
|
2007-10-29 06:45:07 -07:00
|
|
|
class nsScriptObjectTracer;
|
2007-03-22 10:30:00 -07:00
|
|
|
%}
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
[uuid(8916a320-d118-11d3-8f3a-0010a4e73d9a)]
|
|
|
|
interface nsIXPConnectJSObjectHolder : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute JSObjectPtr JSObject;
|
|
|
|
};
|
|
|
|
|
2012-11-21 13:20:05 -08:00
|
|
|
[uuid(92e98688-0154-4b65-971b-0d4afe8fd7cb)]
|
2007-03-22 10:30:00 -07:00
|
|
|
interface nsIXPConnectWrappedNative : nsIXPConnectJSObjectHolder
|
|
|
|
{
|
|
|
|
/* attribute 'JSObject' inherited from nsIXPConnectJSObjectHolder */
|
|
|
|
readonly attribute nsISupports Native;
|
|
|
|
readonly attribute JSObjectPtr JSObjectPrototype;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* These are here as an aid to nsIXPCScriptable implementors
|
|
|
|
*/
|
|
|
|
|
|
|
|
readonly attribute nsIXPConnect XPConnect;
|
2010-07-14 23:19:36 -07:00
|
|
|
nsIInterfaceInfo FindInterfaceWithMember(in jsid nameID);
|
|
|
|
nsIInterfaceInfo FindInterfaceWithName(in jsid nameID);
|
2012-11-21 13:20:05 -08:00
|
|
|
[notxpcom] bool HasNativeMember(in jsid name);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void debugDump(in short depth);
|
|
|
|
|
2012-03-05 15:22:45 -08:00
|
|
|
/*
|
|
|
|
* This finishes initializing a wrapped global, doing the parts that we
|
|
|
|
* couldn't do while the global and window were being simultaneously
|
|
|
|
* bootstrapped. This should be called exactly once, and only for wrapped
|
|
|
|
* globals.
|
|
|
|
*/
|
|
|
|
void finishInitForWrappedGlobal();
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/*
|
|
|
|
* This returns a pointer into the instance and care should be taken
|
|
|
|
* to make sure the pointer is not kept past the life time of the
|
|
|
|
* object it points into.
|
|
|
|
*/
|
|
|
|
voidPtrPtr GetSecurityInfoAddress();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* NOTE: Add new IDL methods _before_ the C++ block below if you
|
|
|
|
* add them. Otherwise the vtable won't be what xpidl thinks it
|
|
|
|
* is, since GetObjectPrincipal() is virtual.
|
|
|
|
*/
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
/**
|
|
|
|
* Faster access to the native object from C++. Will never return null.
|
|
|
|
*/
|
|
|
|
nsISupports* Native() const { return mIdentity; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
nsISupports *mIdentity;
|
|
|
|
public:
|
|
|
|
%}
|
|
|
|
};
|
|
|
|
|
|
|
|
%{C++
|
|
|
|
#include "nsCOMPtr.h"
|
|
|
|
|
|
|
|
inline
|
|
|
|
const nsQueryInterface
|
|
|
|
do_QueryWrappedNative(nsIXPConnectWrappedNative *aWrappedNative)
|
|
|
|
{
|
|
|
|
return nsQueryInterface(aWrappedNative->Native());
|
|
|
|
}
|
|
|
|
|
|
|
|
inline
|
|
|
|
const nsQueryInterfaceWithError
|
|
|
|
do_QueryWrappedNative(nsIXPConnectWrappedNative *aWrappedNative,
|
|
|
|
nsresult *aError)
|
|
|
|
|
|
|
|
{
|
|
|
|
return nsQueryInterfaceWithError(aWrappedNative->Native(), aError);
|
|
|
|
}
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
[uuid(BED52030-BCA6-11d2-BA79-00805F8A5DD7)]
|
|
|
|
interface nsIXPConnectWrappedJS : nsIXPConnectJSObjectHolder
|
|
|
|
{
|
|
|
|
/* attribute 'JSObject' inherited from nsIXPConnectJSObjectHolder */
|
|
|
|
readonly attribute nsIInterfaceInfo InterfaceInfo;
|
|
|
|
readonly attribute nsIIDPtr InterfaceIID;
|
|
|
|
|
|
|
|
void debugDump(in short depth);
|
|
|
|
|
|
|
|
void aggregatedQueryInterface(in nsIIDRef uuid,
|
|
|
|
[iid_is(uuid),retval] out nsQIResult result);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This is a sort of a placeholder interface. It is not intended to be
|
|
|
|
* implemented. It exists to give the nsIXPCSecurityManager an iid on
|
|
|
|
* which to gate a specific activity in XPConnect.
|
|
|
|
*
|
|
|
|
* That activity is...
|
|
|
|
*
|
2009-07-27 01:46:54 -07:00
|
|
|
* When JavaScript code uses a component that is itself implemented in
|
2007-03-22 10:30:00 -07:00
|
|
|
* JavaScript then XPConnect will build a wrapper rather than directly
|
|
|
|
* expose the JSObject of the component. This allows components implemented
|
|
|
|
* in JavaScript to 'look' just like any other xpcom component (from the
|
|
|
|
* perspective of the JavaScript caller). This insulates the component from
|
|
|
|
* the caller and hides any properties or methods that are not part of the
|
|
|
|
* interface as declared in xpidl. Usually this is a good thing.
|
|
|
|
*
|
|
|
|
* However, in some cases it is useful to allow the JS caller access to the
|
|
|
|
* JS component's underlying implementation. In order to facilitate this
|
|
|
|
* XPConnect supports the 'wrappedJSObject' property. The caller code can do:
|
|
|
|
*
|
|
|
|
* // 'foo' is some xpcom component (that might be implemented in JS).
|
|
|
|
* try {
|
|
|
|
* var bar = foo.wrappedJSObject;
|
|
|
|
* if(bar) {
|
|
|
|
* // bar is the underlying JSObject. Do stuff with it here.
|
|
|
|
* }
|
|
|
|
* } catch(e) {
|
|
|
|
* // security exception?
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Recall that 'foo' above is an XPConnect wrapper, not the underlying JS
|
|
|
|
* object. The property get "foo.wrappedJSObject" will only succeed if three
|
|
|
|
* conditions are met:
|
|
|
|
*
|
|
|
|
* 1) 'foo' really is an XPConnect wrapper around a JSObject.
|
|
|
|
* 2) The underlying JSObject actually implements a "wrappedJSObject"
|
|
|
|
* property that returns a JSObject. This is called by XPConnect. This
|
|
|
|
* restriction allows wrapped objects to only allow access to the underlying
|
|
|
|
* JSObject if they choose to do so. Ususally this just means that 'foo'
|
|
|
|
* would have a property tht looks like:
|
|
|
|
* this.wrappedJSObject = this.
|
|
|
|
* 3) The implemementation of nsIXPCSecurityManager (if installed) allows
|
|
|
|
* a property get on the interface below. Although the JSObject need not
|
|
|
|
* implement 'nsIXPCWrappedJSObjectGetter', XPConnect will ask the
|
|
|
|
* security manager if it is OK for the caller to access the only method
|
|
|
|
* in nsIXPCWrappedJSObjectGetter before allowing the activity. This fits
|
|
|
|
* in with the security manager paradigm and makes control over accessing
|
|
|
|
* the property on this interface the control factor for getting the
|
|
|
|
* underlying wrapped JSObject of a JS component from JS code.
|
|
|
|
*
|
|
|
|
* Notes:
|
|
|
|
*
|
|
|
|
* a) If 'foo' above were the underlying JSObject and not a wrapper at all,
|
|
|
|
* then this all just works and XPConnect is not part of the picture at all.
|
|
|
|
* b) One might ask why 'foo' should not just implement an interface through
|
|
|
|
* which callers might get at the underlying object. There are three reasons:
|
|
|
|
* i) XPConnect would still have to do magic since JSObject is not a
|
|
|
|
* scriptable type.
|
|
|
|
* ii) JS Components might use aggregation (like C++ objects) and have
|
|
|
|
* different JSObjects for different interfaces 'within' an aggregate
|
|
|
|
* object. But, using an additional interface only allows returning one
|
|
|
|
* underlying JSObject. However, this allows for the possibility that
|
|
|
|
* each of the aggregte JSObjects could return something different.
|
|
|
|
* Note that one might do: this.wrappedJSObject = someOtherObject;
|
|
|
|
* iii) Avoiding the explicit interface makes it easier for both the caller
|
|
|
|
* and the component.
|
|
|
|
*
|
|
|
|
* Anyway, some future implementation of nsIXPCSecurityManager might want
|
|
|
|
* do special processing on 'nsIXPCSecurityManager::CanGetProperty' when
|
|
|
|
* the interface id is that of nsIXPCWrappedJSObjectGetter.
|
|
|
|
*/
|
|
|
|
|
|
|
|
[scriptable, uuid(254bb2e0-6439-11d4-8fe0-0010a4e73d9a)]
|
|
|
|
interface nsIXPCWrappedJSObjectGetter : nsISupports
|
|
|
|
{
|
|
|
|
readonly attribute nsISupports neverCalled;
|
|
|
|
};
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This interface is implemented by outside code and registered with xpconnect
|
|
|
|
* via nsIXPConnect::setFunctionThisTranslator.
|
|
|
|
*
|
|
|
|
* The reason this exists is to support calls to JavaScript event callbacks
|
|
|
|
* needed by the DOM via xpconnect from C++ code.
|
|
|
|
*
|
|
|
|
* We've added support for wrapping JS function objects as xpcom interfaces
|
|
|
|
* by declaring the given interface as a [function] interface. However, to
|
|
|
|
* support the requirements of JS event callbacks we need to call the JS
|
|
|
|
* function with the 'this' set as the JSObject for which the event is being
|
|
|
|
* fired; e.g. a form node.
|
|
|
|
*
|
|
|
|
* We've decided that for all cases we care about the appropriate 'this' object
|
|
|
|
* can be derived from the first param in the call to the callback. In the
|
|
|
|
* event handler case the first param is an event object.
|
|
|
|
*
|
|
|
|
* Though we can't change all the JS code so that it would setup its own 'this',
|
|
|
|
* we can add plugin 'helper' support to xpconnect. And that is what we have
|
|
|
|
* here.
|
|
|
|
*
|
|
|
|
* The idea is that at startup time some code that cares about this issue
|
|
|
|
* (e.g. the DOM helper code) can register a nsIXPCFunctionThisTranslator
|
|
|
|
* object with xpconnect to handle calls to [function] interfaces of a given
|
|
|
|
* iid. When xpconnect goes to invoke a method on a wrapped JSObject for
|
|
|
|
* an interface marked as [function], xpconnect will check if the first param
|
|
|
|
* of the method is an xpcom object pointer and if so it will check to see if a
|
|
|
|
* nsIXPCFunctionThisTranslator has been registered for the given iid of the
|
|
|
|
* interface being called. If so it will call the translator and get an
|
|
|
|
* interface pointer to use as the 'this' for the call. If the translator
|
|
|
|
* returns a non-null interface pointer (which it should then have addref'd
|
|
|
|
* since it is being returned as an out param), xpconnect will attempt to build
|
|
|
|
* a wrapper around the pointer and get a JSObject from that wrapper to use
|
|
|
|
* as the 'this' for the call.
|
|
|
|
*
|
|
|
|
* If a null interface pointer is returned then xpconnect will use the default
|
|
|
|
* 'this' - the same JSObject as the function object it is calling.
|
|
|
|
*/
|
|
|
|
|
2012-10-02 01:22:32 -07:00
|
|
|
[uuid(f5f84b70-92eb-41f1-a1dd-2eaac0ed564c)]
|
2007-03-22 10:30:00 -07:00
|
|
|
interface nsIXPCFunctionThisTranslator : nsISupports
|
|
|
|
{
|
2012-10-02 01:22:32 -07:00
|
|
|
nsISupports TranslateThis(in nsISupports aInitialThis);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
/***************************************************************************/
|
|
|
|
|
|
|
|
%{ C++
|
|
|
|
// For use with the service manager
|
|
|
|
// {CB6593E0-F9B2-11d2-BDD6-000064657374}
|
|
|
|
#define NS_XPCONNECT_CID \
|
|
|
|
{ 0xcb6593e0, 0xf9b2, 0x11d2, \
|
|
|
|
{ 0xbd, 0xd6, 0x0, 0x0, 0x64, 0x65, 0x73, 0x74 } }
|
|
|
|
%}
|
|
|
|
|
2013-02-26 08:15:44 -08:00
|
|
|
[uuid(19e869b4-23cc-417d-b877-f3d46b8bc2d2)]
|
2007-03-22 10:30:00 -07:00
|
|
|
interface nsIXPConnect : nsISupports
|
|
|
|
{
|
|
|
|
%{ C++
|
|
|
|
NS_DEFINE_STATIC_CID_ACCESSOR(NS_XPCONNECT_CID)
|
|
|
|
%}
|
|
|
|
|
2009-08-18 21:02:05 -07:00
|
|
|
/**
|
|
|
|
* Initializes classes on a global object that has already been created.
|
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
void
|
|
|
|
initClasses(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aGlobalJSObj);
|
|
|
|
|
2009-08-18 21:02:05 -07:00
|
|
|
/**
|
|
|
|
* Creates a new global object using the given aCOMObj as the global
|
|
|
|
* object. The object will be set up according to the flags (defined
|
|
|
|
* below). If you do not pass INIT_JS_STANDARD_CLASSES, then aCOMObj
|
|
|
|
* must implement nsIXPCScriptable so it can resolve the standard
|
|
|
|
* classes when asked by the JS engine.
|
2010-07-19 13:36:49 -07:00
|
|
|
*
|
|
|
|
* @param aJSContext the context to use while creating the global object.
|
|
|
|
* @param aCOMObj the native object that represents the global object.
|
|
|
|
* @param aPrincipal the principal of the code that will run in this
|
2010-10-26 23:57:31 -07:00
|
|
|
* compartment. Can be null if not on the main thread.
|
2010-07-19 13:36:49 -07:00
|
|
|
* @param aFlags one of the flags below specifying what options this
|
|
|
|
* global object wants.
|
2009-08-18 21:02:05 -07:00
|
|
|
*/
|
2007-03-22 10:30:00 -07:00
|
|
|
nsIXPConnectJSObjectHolder
|
|
|
|
initClassesWithNewWrappedGlobal(
|
|
|
|
in JSContextPtr aJSContext,
|
|
|
|
in nsISupports aCOMObj,
|
2010-07-19 13:36:49 -07:00
|
|
|
in nsIPrincipal aPrincipal,
|
2012-08-22 08:56:38 -07:00
|
|
|
in uint32_t aFlags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t INIT_JS_STANDARD_CLASSES = 1 << 0;
|
2012-09-05 11:32:07 -07:00
|
|
|
// Free bit here!
|
2012-08-22 08:56:38 -07:00
|
|
|
const uint32_t OMIT_COMPONENTS_OBJECT = 1 << 2;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* 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);
|
|
|
|
|
2008-12-16 07:46:18 -08:00
|
|
|
/**
|
|
|
|
* 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.
|
2008-12-16 07:46:18 -08:00
|
|
|
* 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.
|
2009-05-21 01:17:51 -07:00
|
|
|
* If aAllowWrapper, then the returned value will be wrapped in the proper
|
|
|
|
* type of security wrapper on top of the XPCWrappedNative (if needed).
|
2009-08-14 12:00:24 -07:00
|
|
|
* This method doesn't push aJSContext on the context stack, so the caller
|
|
|
|
* is required to push it if the top of the context stack is not equal to
|
|
|
|
* aJSContext.
|
2008-12-16 07:46:18 -08:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
wrapNativeToJSVal(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aScope,
|
|
|
|
in nsISupports aCOMObj,
|
2010-05-10 11:53:05 -07:00
|
|
|
in nsWrapperCachePtr aCache,
|
2008-12-16 07:46:18 -08:00
|
|
|
in nsIIDPtr aIID,
|
2009-05-21 01:17:51 -07:00
|
|
|
in boolean aAllowWrapper,
|
2010-05-12 06:18:51 -07:00
|
|
|
out jsval aVal,
|
2008-12-16 07:46:18 -08:00
|
|
|
out nsIXPConnectJSObjectHolder aHolder);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2009-09-01 09:45:05 -07:00
|
|
|
/**
|
2010-05-12 06:18:51 -07:00
|
|
|
* Wraps the given jsval in a nsIVariant and returns the new variant.
|
2009-09-01 09:45:05 -07:00
|
|
|
*/
|
|
|
|
nsIVariant
|
|
|
|
jSValToVariant(in JSContextPtr cx, in JSValPtr aJSVal);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
/**
|
|
|
|
* This only succeeds if the JSObject is a nsIXPConnectWrappedNative.
|
|
|
|
* A new wrapper is *never* constructed.
|
|
|
|
*/
|
|
|
|
nsIXPConnectWrappedNative
|
|
|
|
getWrappedNativeOfJSObject(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aJSObj);
|
|
|
|
|
2009-05-12 13:20:42 -07:00
|
|
|
[noscript, notxpcom] nsISupports
|
|
|
|
getNativeOfWrapper(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aJSObj);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
void setSecurityManagerForJSContext(in JSContextPtr aJSContext,
|
|
|
|
in nsIXPCSecurityManager aManager,
|
2012-08-22 08:56:38 -07:00
|
|
|
in uint16_t flags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void getSecurityManagerForJSContext(in JSContextPtr aJSContext,
|
|
|
|
out nsIXPCSecurityManager aManager,
|
2012-08-22 08:56:38 -07:00
|
|
|
out uint16_t flags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The security manager to use when the current JSContext has no security
|
|
|
|
* manager.
|
|
|
|
*/
|
|
|
|
void setDefaultSecurityManager(in nsIXPCSecurityManager aManager,
|
2012-08-22 08:56:38 -07:00
|
|
|
in uint16_t flags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void getDefaultSecurityManager(out nsIXPCSecurityManager aManager,
|
2012-08-22 08:56:38 -07:00
|
|
|
out uint16_t flags);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
nsIStackFrame
|
2012-08-22 08:56:38 -07:00
|
|
|
createStackFrameLocation(in uint32_t aLanguage,
|
2007-03-22 10:30:00 -07:00
|
|
|
in string aFilename,
|
|
|
|
in string aFunctionName,
|
2012-08-22 08:56:38 -07:00
|
|
|
in int32_t aLineNumber,
|
2007-03-22 10:30:00 -07:00
|
|
|
in nsIStackFrame aCaller);
|
|
|
|
|
|
|
|
/**
|
2011-03-27 20:59:44 -07:00
|
|
|
* @deprecated do-nothing function.
|
2007-03-22 10:30:00 -07:00
|
|
|
*/
|
2011-03-27 20:59:44 -07:00
|
|
|
[deprecated] void syncJSContexts();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
readonly attribute nsIStackFrame CurrentJSStack;
|
2008-01-15 07:50:57 -08:00
|
|
|
readonly attribute nsAXPCNativeCallContextPtr CurrentNativeCallContext;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void debugDump(in short depth);
|
|
|
|
void debugDumpObject(in nsISupports aCOMObj, in short depth);
|
2011-08-06 22:03:32 -07:00
|
|
|
void debugDumpJSStack(in boolean showArgs,
|
|
|
|
in boolean showLocals,
|
|
|
|
in boolean showThisProps);
|
2012-08-22 08:56:38 -07:00
|
|
|
void debugDumpEvalInJSStackFrame(in uint32_t aFrameNumber,
|
2007-03-22 10:30:00 -07:00
|
|
|
in string aSourceText);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
// Methods added since mozilla 0.6....
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
2012-10-02 01:24:08 -07:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
setFunctionThisTranslator(in nsIIDRef aIID,
|
|
|
|
in nsIXPCFunctionThisTranslator aTranslator);
|
|
|
|
|
2012-11-21 13:20:05 -08:00
|
|
|
void
|
2007-03-22 10:30:00 -07:00
|
|
|
reparentWrappedNativeIfFound(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aScope,
|
|
|
|
in JSObjectPtr aNewParent,
|
|
|
|
in nsISupports aCOMObj);
|
|
|
|
void
|
2012-10-16 06:07:54 -07:00
|
|
|
rescueOrphansInScope(in JSContextPtr aJSContext, in JSObjectPtr aScope);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
void clearAllWrappedNativeSecurityPolicies();
|
|
|
|
|
|
|
|
nsIXPConnectJSObjectHolder
|
|
|
|
getWrappedNativePrototype(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aScope,
|
|
|
|
in nsIClassInfo aClassInfo);
|
|
|
|
|
2011-08-06 22:03:32 -07:00
|
|
|
void releaseJSContext(in JSContextPtr aJSContext, in boolean noGC);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-05-12 06:18:51 -07:00
|
|
|
jsval variantToJS(in JSContextPtr ctx, in JSObjectPtr scope, in nsIVariant value);
|
|
|
|
nsIVariant JSToVariant(in JSContextPtr ctx, in jsval value);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
2007-07-17 13:12:21 -07:00
|
|
|
* @param returnStringOnly The only results to come out of the
|
|
|
|
* computation (including exceptions) will
|
|
|
|
* be coerced into strings created in the
|
|
|
|
* sandbox.
|
2007-03-22 10:30:00 -07:00
|
|
|
* @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.
|
|
|
|
*/
|
2010-05-12 06:18:51 -07:00
|
|
|
[noscript] jsval evalInSandboxObject(in AString source, in JSContextPtr cx,
|
2007-07-17 13:12:21 -07:00
|
|
|
in nsIXPConnectJSObjectHolder sandbox,
|
2011-08-06 22:03:32 -07:00
|
|
|
in boolean returnStringOnly);
|
2007-07-26 12:18:06 -07:00
|
|
|
|
2007-10-29 06:45:07 -07:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2012-11-12 17:15:00 -08:00
|
|
|
[noscript,notxpcom] void addJSHolder(in voidPtr aHolder,
|
|
|
|
in nsScriptObjectTracerPtr aTracer);
|
2007-10-29 06:45:07 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Stop rooting the JS objects held by aHolder.
|
|
|
|
* @param aHolder The object that hold the rooted JS objects.
|
|
|
|
*/
|
2012-11-12 17:15:00 -08:00
|
|
|
[noscript,notxpcom] void removeJSHolder(in voidPtr aHolder);
|
2007-11-01 15:51:57 -07:00
|
|
|
|
2012-07-06 10:28:51 -07:00
|
|
|
/**
|
|
|
|
* Test to see if a JS holder is in our hashtable.
|
|
|
|
* Only available in debug builds.
|
|
|
|
* @param aHolder The object to test for.
|
|
|
|
*/
|
2012-11-12 17:15:00 -08:00
|
|
|
[noscript,notxpcom] bool testJSHolder(in voidPtr aHolder);
|
2012-07-06 10:28:51 -07:00
|
|
|
|
2007-11-01 15:51:57 -07:00
|
|
|
/**
|
|
|
|
* 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);
|
2007-12-12 15:02:25 -08:00
|
|
|
|
2008-04-10 10:35:56 -07:00
|
|
|
/**
|
|
|
|
* 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);
|
2008-08-19 19:38:24 -07:00
|
|
|
|
2010-07-19 23:31:01 -07:00
|
|
|
/**
|
|
|
|
* Trigger a JS garbage collection.
|
2012-01-25 10:59:55 -08:00
|
|
|
* Use a js::gcreason::Reason from jsfriendapi.h for the kind.
|
2010-07-19 23:31:01 -07:00
|
|
|
*/
|
2012-08-22 08:56:38 -07:00
|
|
|
void GarbageCollect(in uint32_t reason);
|
2010-07-19 23:31:01 -07:00
|
|
|
|
2012-02-17 14:35:20 -08:00
|
|
|
/**
|
|
|
|
* Signals a good place to do an incremental GC slice, because the
|
|
|
|
* browser is drawing a frame.
|
|
|
|
*/
|
|
|
|
void NotifyDidPaint();
|
|
|
|
|
2009-05-12 13:20:42 -07:00
|
|
|
%{C++
|
|
|
|
/**
|
|
|
|
* Get the object principal for this wrapper. Note that this may well end
|
|
|
|
* up being null; in that case one should seek principals elsewhere. Null
|
|
|
|
* here does NOT indicate system principal or no principals at all, just
|
|
|
|
* that this wrapper doesn't have an intrinsic one.
|
|
|
|
*/
|
|
|
|
virtual nsIPrincipal* GetPrincipal(JSObject* obj,
|
2011-09-28 23:19:26 -07:00
|
|
|
bool allowShortCircuit) const = 0;
|
|
|
|
virtual char* DebugPrintJSStack(bool showArgs,
|
|
|
|
bool showLocals,
|
|
|
|
bool showThisProps) = 0;
|
2009-05-12 13:20:42 -07:00
|
|
|
%}
|
2009-12-16 16:51:06 -08:00
|
|
|
|
2010-08-13 17:05:18 -07:00
|
|
|
/**
|
|
|
|
* Creates a JS object holder around aObject that will hold the object
|
|
|
|
* alive for as long as the holder stays alive.
|
|
|
|
*/
|
|
|
|
nsIXPConnectJSObjectHolder holdObject(in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aObject);
|
2010-08-19 18:12:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the caller object of the current call from JS.
|
|
|
|
*/
|
|
|
|
[noscript,notxpcom] void getCaller(out JSContextPtr aJSContext,
|
|
|
|
out JSObjectPtr aObject);
|
2010-10-30 09:13:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* When we place the browser in JS debug mode, there can't be any
|
|
|
|
* JS on the stack. This is because we currently activate debugMode
|
|
|
|
* on all scripts in the JSRuntime when the debugger is activated.
|
|
|
|
* This method will turn debug mode on or off when the context
|
|
|
|
* stack reaches zero length.
|
|
|
|
*/
|
2011-11-09 13:11:39 -08:00
|
|
|
[noscript] void setDebugModeWhenPossible(in boolean mode,
|
|
|
|
in boolean allowSyncDisable);
|
2012-02-13 05:10:04 -08:00
|
|
|
|
|
|
|
[noscript] void writeScript(in nsIObjectOutputStream aStream,
|
|
|
|
in JSContextPtr aJSContext,
|
|
|
|
in JSScriptPtr aJSScript);
|
|
|
|
|
|
|
|
[noscript] JSScriptPtr readScript(in nsIObjectInputStream aStream,
|
|
|
|
in JSContextPtr aJSContext);
|
|
|
|
|
|
|
|
[noscript] void writeFunction(in nsIObjectOutputStream aStream,
|
|
|
|
in JSContextPtr aJSContext,
|
|
|
|
in JSObjectPtr aJSObject);
|
|
|
|
|
|
|
|
[noscript] JSObjectPtr readFunction(in nsIObjectInputStream aStream,
|
|
|
|
in JSContextPtr aJSContext);
|
2007-03-22 10:30:00 -07:00
|
|
|
};
|