зеркало из https://github.com/mozilla/gecko-dev.git
Bug 543558 - Make sure we're in a request when calling JS_SaveFrameChain/JS_RestoreFrameChain. r=mrbkap
This commit is contained in:
Родитель
fff703635d
Коммит
fd2c2e3ae7
|
@ -5186,6 +5186,7 @@ JS_IsConstructing(JSContext *cx)
|
|||
JS_PUBLIC_API(JSStackFrame *)
|
||||
JS_SaveFrameChain(JSContext *cx)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
JSStackFrame *fp = js_GetTopStackFrame(cx);
|
||||
if (!fp)
|
||||
return NULL;
|
||||
|
@ -5196,6 +5197,7 @@ JS_SaveFrameChain(JSContext *cx)
|
|||
JS_PUBLIC_API(void)
|
||||
JS_RestoreFrameChain(JSContext *cx, JSStackFrame *fp)
|
||||
{
|
||||
CHECK_REQUEST(cx);
|
||||
JS_ASSERT_NOT_ON_TRACE(cx);
|
||||
JS_ASSERT(!cx->fp);
|
||||
if (!fp)
|
||||
|
|
|
@ -1095,10 +1095,11 @@ nsXPConnect::InitClasses(JSContext * aJSContext, JSObject * aGlobalJSObj)
|
|||
NS_ASSERTION(aJSContext, "bad param");
|
||||
NS_ASSERTION(aGlobalJSObj, "bad param");
|
||||
|
||||
SaveFrame sf(aJSContext);
|
||||
// Nest frame chain save/restore in request created by XPCCallContext.
|
||||
XPCCallContext ccx(NATIVE_CALLER, aJSContext);
|
||||
if(!ccx.IsValid())
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
SaveFrame sf(aJSContext);
|
||||
|
||||
if(!xpc_InitJSxIDClassObjects())
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
|
@ -1135,10 +1136,11 @@ nsXPConnect::InitClasses(JSContext * aJSContext, JSObject * aGlobalJSObj)
|
|||
/* void initClassesForOuterObject (in JSContextPtr aJSContext, in JSObjectPtr aGlobalJSObj); */
|
||||
NS_IMETHODIMP nsXPConnect::InitClassesForOuterObject(JSContext * aJSContext, JSObject * aGlobalJSObj)
|
||||
{
|
||||
SaveFrame sf(aJSContext);
|
||||
// Nest frame chain save/restore in request created by XPCCallContext.
|
||||
XPCCallContext ccx(NATIVE_CALLER, aJSContext);
|
||||
if(!ccx.IsValid())
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
SaveFrame sf(aJSContext);
|
||||
|
||||
XPCWrappedNativeScope* scope =
|
||||
XPCWrappedNativeScope::GetNewOrUsed(ccx, aGlobalJSObj);
|
||||
|
@ -1254,6 +1256,7 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
|
|||
}
|
||||
|
||||
if(!(aFlags & nsIXPConnect::OMIT_COMPONENTS_OBJECT)) {
|
||||
// XPCCallContext gives us an active request needed to save/restore.
|
||||
SaveFrame sf(ccx);
|
||||
if(!nsXPCComponents::AttachNewComponentsObject(ccx, scope, globalJSObj))
|
||||
return UnexpectedFailure(NS_ERROR_FAILURE);
|
||||
|
|
|
@ -100,18 +100,21 @@ XPCJSContextStack::Pop(JSContext * *_retval)
|
|||
if(idx > 0)
|
||||
{
|
||||
--idx; // Advance to new top of the stack
|
||||
|
||||
XPCJSContextInfo & e = mStack[idx];
|
||||
NS_ASSERTION(!e.frame || e.cx, "Shouldn't have frame without a cx!");
|
||||
if(e.cx && e.frame)
|
||||
{
|
||||
JS_RestoreFrameChain(e.cx, e.frame);
|
||||
e.frame = nsnull;
|
||||
}
|
||||
|
||||
if(e.requestDepth)
|
||||
JS_ResumeRequest(e.cx, e.requestDepth);
|
||||
|
||||
e.requestDepth = 0;
|
||||
|
||||
if(e.cx && e.frame)
|
||||
{
|
||||
// Pop() can be called outside any request for e.cx.
|
||||
JSAutoRequest ar(e.cx);
|
||||
JS_RestoreFrameChain(e.cx, e.frame);
|
||||
e.frame = nsnull;
|
||||
}
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -161,7 +164,11 @@ XPCJSContextStack::Push(JSContext * cx)
|
|||
}
|
||||
}
|
||||
|
||||
e.frame = JS_SaveFrameChain(e.cx);
|
||||
{
|
||||
// Push() can be called outside any request for e.cx.
|
||||
JSAutoRequest ar(e.cx);
|
||||
e.frame = JS_SaveFrameChain(e.cx);
|
||||
}
|
||||
|
||||
if(e.cx != cx && JS_GetContextThread(e.cx))
|
||||
e.requestDepth = JS_SuspendRequest(e.cx);
|
||||
|
|
Загрузка…
Ссылка в новой задаче