mService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID); if (!mService) return NS_ERROR_FAILURE;   mService->PushThreadEventQueue(getter_AddRefs(mQueue)); if (!mQueue) return NS_ERROR_FAILURE;  #ifdef HAVE_LAME_APPSHELL  mAppShell = do_CreateInstance(kAppShellCID); if (!mAppShell) return NS_ERROR_FAILURE;  mAppShell->Create(0, nsnull); mAppShell->Spinup();   mAppShell->ListenToEventQueue(mQueue, PR_TRUE); #endif  return NS_OK;
mService = do_GetService(sJSStackContractID); if(mService) { rv = mService->GetSafeJSContext(&mContext); if (NS_SUCCEEDED(rv) && mContext) { rv = mService->Push(mContext); if (NS_FAILED(rv)) mContext = 0; } } return mContext ? NS_OK : NS_ERROR_FAILURE;
nsresult EventQueueAutoPopper::Push(){  if (mQueue) // only once    return NS_ERROR_FAILURE;  mService = do_GetService(NS_EVENTQUEUESERVICE_CONTRACTID);  if (!mService)    return NS_ERROR_FAILURE;  // push a new queue onto it  mService->PushThreadEventQueue(getter_AddRefs(mQueue));  if (!mQueue)    return NS_ERROR_FAILURE;#ifdef HAVE_LAME_APPSHELL  // listen to the event queue  mAppShell = do_CreateInstance(kAppShellCID);  if (!mAppShell)    return NS_ERROR_FAILURE;  mAppShell->Create(0, nsnull);  mAppShell->Spinup();  // listen to the new queue  mAppShell->ListenToEventQueue(mQueue, PR_TRUE);#endif  return NS_OK;}