if (aSecuritySupports) mPushResult = CreatePrincipal(aSecuritySupports, secMan, getter_AddRefs(principal)); else mPushResult = secMan->GetPrincipalFromContext(cx, getter_AddRefs(principal));
mPushResult = secMan->GetPrincipalFromContext(cx, getter_AddRefs(principal));
AutoPushJSContext::AutoPushJSContext(nsISupports* aSecuritySupports,                                     JSContext *cx)                                      : mContext(cx), mPushResult(NS_OK){    mContextStack = do_GetService("@mozilla.org/js/xpc/ContextStack;1");    if(mContextStack)    {        JSContext* currentCX;        if(NS_SUCCEEDED(mContextStack->Peek(&currentCX)))        {            // Is the current context already on the stack?            if(cx == currentCX)                mContextStack = nsnull;            else            {                mContextStack->Push(cx);                // Leave the reference to the mContextStack to                // indicate that we need to pop it in our dtor.                                                           }        }    }    nsCOMPtr<nsIScriptSecurityManager> secMan(        do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &mPushResult));    if (NS_FAILED(mPushResult))        return;    nsCOMPtr<nsIPrincipal> principal;    if (aSecuritySupports)        mPushResult = CreatePrincipal(aSecuritySupports, secMan, getter_AddRefs(principal));    else        mPushResult = secMan->GetPrincipalFromContext(cx, getter_AddRefs(principal));    if (NS_FAILED(mPushResult))    {        JS_ReportError(cx, "failed to get a principal");        return;    }    // See if Javascript is enabled for the current window    PRBool jsEnabled = PR_FALSE;    mPushResult = secMan->CanExecuteScripts(cx, principal, &jsEnabled);    if (!jsEnabled)        mPushResult = NS_ERROR_FAILURE;    memset(&mFrame, 0, sizeof(mFrame));    if (NS_SUCCEEDED(mPushResult))    {        // See if there are any scripts on the stack.        // If not, we need to add a dummy frame with a principal.        PRBool hasScript = PR_FALSE;        JSStackFrame* tempFP = cx->fp;        while (tempFP)        {            if (tempFP->script)            {                hasScript = PR_TRUE;                break;            }            tempFP = tempFP->down;        };        if (!hasScript)        {            JSPrincipals* jsprinc;            principal->GetJSPrincipals(cx, &jsprinc);            mFrame.script = JS_CompileScriptForPrincipals(cx, JS_GetGlobalObject(cx),                                                          jsprinc, "", 0, "", 1);            JSPRINCIPALS_DROP(cx, jsprinc);            if (mFrame.script)            {                mFrame.down = cx->fp;                cx->fp = &mFrame;            }            else                mPushResult = NS_ERROR_OUT_OF_MEMORY;        }    }}