Bug 902718 - Use the SafeJSContext for prototype member compilation. r=bz

This commit is contained in:
Bobby Holley 2013-08-09 09:25:14 -07:00
parent 1ec46ae8f9
commit 601b7c6981

View File

@ -186,18 +186,16 @@ nsXBLProtoImpl::CompilePrototypeMembers(nsXBLPrototypeBinding* aBinding)
nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner( nsCOMPtr<nsIScriptGlobalObjectOwner> globalOwner(
do_QueryObject(aBinding->XBLDocumentInfo())); do_QueryObject(aBinding->XBLDocumentInfo()));
AutoSafeJSContext cx;
nsIScriptGlobalObject* globalObject = globalOwner->GetScriptGlobalObject(); nsIScriptGlobalObject* globalObject = globalOwner->GetScriptGlobalObject();
NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED); NS_ENSURE_TRUE(globalObject, NS_ERROR_UNEXPECTED);
JS::Rooted<JSObject*> compilationGlobal(cx, globalObject->GetGlobalJSObject());
NS_ENSURE_TRUE(compilationGlobal, NS_ERROR_UNEXPECTED);
JSAutoCompartment ac(cx, compilationGlobal);
nsIScriptContext *context = globalObject->GetContext();
NS_ENSURE_TRUE(context, NS_ERROR_OUT_OF_MEMORY);
AutoPushJSContext cx(context->GetNativeContext());
JS::Rooted<JSObject*> global(cx, globalObject->GetGlobalJSObject());
JS::Rooted<JSObject*> classObject(cx); JS::Rooted<JSObject*> classObject(cx);
bool classObjectIsNew = false; bool classObjectIsNew = false;
nsresult rv = aBinding->InitClass(mClassName, cx, global, global, nsresult rv = aBinding->InitClass(mClassName, cx, compilationGlobal, compilationGlobal,
&classObject, &classObjectIsNew); &classObject, &classObjectIsNew);
if (NS_FAILED(rv)) if (NS_FAILED(rv))
return rv; return rv;