Bug 698408 - Pass JSObject to nsIScriptContext::SetOuterObject; r=jst

This commit is contained in:
Ms2ger 2011-11-26 11:19:15 +01:00
parent 66c4623fdb
commit 0f27987dfd
3 changed files with 8 additions and 10 deletions

View File

@ -74,8 +74,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal,
NS_ISCRIPTCONTEXTPRINCIPAL_IID)
#define NS_ISCRIPTCONTEXT_IID \
{ 0x495479ff, 0xaf40, 0x4bcd, \
{ 0x93, 0x46, 0x5a, 0x46, 0x84, 0x06, 0xff, 0x7f } }
{ 0x18b25592, 0xb1f3, 0x4e96, \
{ 0xab, 0x50, 0x3d, 0x91, 0xf4, 0xc8, 0x1d, 0xa1 } }
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
know what language we have is a little silly... */
@ -330,7 +330,7 @@ public:
/**
* Given an outer object, updates this context with that outer object.
*/
virtual nsresult SetOuterObject(void *aOuterObject) = 0;
virtual nsresult SetOuterObject(JSObject* aOuterObject) = 0;
/**
* Prepares this context for use with the current inner window for the

View File

@ -2294,15 +2294,13 @@ nsJSContext::CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
}
nsresult
nsJSContext::SetOuterObject(void *aOuterObject)
nsJSContext::SetOuterObject(JSObject* aOuterObject)
{
JSObject *outer = static_cast<JSObject *>(aOuterObject);
// Force our context's global object to be the outer.
JS_SetGlobalObject(mContext, outer);
JS_SetGlobalObject(mContext, aOuterObject);
// NB: JS_SetGlobalObject sets mContext->compartment.
JSObject *inner = JS_GetParent(mContext, outer);
JSObject *inner = JS_GetParent(mContext, aOuterObject);
nsIXPConnect *xpc = nsContentUtils::XPConnect();
nsCOMPtr<nsIXPConnectWrappedNative> wrapper;
@ -2312,7 +2310,7 @@ nsJSContext::SetOuterObject(void *aOuterObject)
NS_ABORT_IF_FALSE(wrapper, "bad wrapper");
wrapper->RefreshPrototype();
JS_SetPrototype(mContext, outer, JS_GetPrototype(mContext, inner));
JS_SetPrototype(mContext, aOuterObject, JS_GetPrototype(mContext, inner));
return NS_OK;
}

View File

@ -141,7 +141,7 @@ public:
virtual nsresult InitContext();
virtual nsresult CreateOuterObject(nsIScriptGlobalObject *aGlobalObject,
nsIScriptGlobalObject *aCurrentInner);
virtual nsresult SetOuterObject(void *aOuterObject);
virtual nsresult SetOuterObject(JSObject* aOuterObject);
virtual nsresult InitOuterWindow();
virtual bool IsContextInitialized();
virtual void FinalizeContext();