if ( ownRuntime ) JS_DestroyRuntime(rt);
extern "C" void RunInstallOnThread(void *data){    nsInstallInfo *installInfo = (nsInstallInfo*)data;        char        *scriptBuffer = nsnull;    PRUint32    scriptLength;    JSRuntime   *rt;	JSContext   *cx;    JSObject    *glob;    // we will plan on sending a failure status back from here unless we    // find positive acknowledgement that the script sent the status    PRInt32     finalStatus;    PRBool      sendStatus = PR_TRUE;    nsIXPINotifier *notifier;    nsresult    rv;    // lets set up an eventQ so that our xpcom/proxies will not have to:    nsCOMPtr<nsIEventQueue> eventQ;    NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);    if (NS_SUCCEEDED(rv))     {           eventQService->CreateThreadEventQueue();        eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, getter_AddRefs(eventQ));    }    NS_WITH_SERVICE(nsISoftwareUpdate, softwareUpdate, kSoftwareUpdateCID, &rv );    if (!NS_SUCCEEDED(rv))    {        NS_WARNING("shouldn't have RunInstall() if we can't get SoftwareUpdate");        return;    }    softwareUpdate->SetActiveNotifier( installInfo->GetNotifier() );    softwareUpdate->GetMasterNotifier(&notifier);        nsString url;    installInfo->GetURL(url);    if(notifier)        notifier->BeforeJavascriptEvaluation( url.GetUnicode() );        nsString args;    installInfo->GetArguments(args);    nsFileSpec jarpath;    rv = installInfo->GetLocalFile(jarpath);    if (NS_SUCCEEDED(rv))	{        finalStatus = GetInstallScriptFromJarfile( jarpath,                                                    &scriptBuffer,                                                    &scriptLength);        if ( finalStatus == NS_OK && scriptBuffer )        {            rv = SetupInstallContext( jarpath,                                       url.GetUnicode(),                                      args.GetUnicode(),                                       &rt, &cx, &glob);            if (NS_SUCCEEDED(rv))            {                // Go ahead and run!!                jsval rval;                jsval installedFiles;                PRBool ok = JS_EvaluateScript(  cx,                                                 glob,                                                scriptBuffer,                                                 scriptLength,                                                nsnull,                                                0,                                                &rval);                if(!ok)                {                    // problem compiling or running script                    if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&                       JSVAL_TO_BOOLEAN(installedFiles))                    {                        nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob);                        a->InternalAbort(nsInstall::SCRIPT_ERROR);                    }                    finalStatus = nsInstall::SCRIPT_ERROR;                }                else                {                    // check to make sure the script sent back a status                    jsval sent;                    if(JS_GetProperty(cx, glob, "_installedFiles", &installedFiles) &&                       JSVAL_TO_BOOLEAN(installedFiles))                    {                      nsInstall *a = (nsInstall*)JS_GetPrivate(cx, glob);                      a->InternalAbort(nsInstall::SCRIPT_ERROR);                    }                    if ( JS_GetProperty( cx, glob, "_statusSent", &sent ) &&                         JSVAL_TO_BOOLEAN(sent) )                        sendStatus = PR_FALSE;                    else                        finalStatus = nsInstall::SCRIPT_ERROR;                }                JS_DestroyContext(cx);                JS_DestroyRuntime(rt);            }            else            {                // couldn't initialize install context                finalStatus = nsInstall::UNEXPECTED_ERROR;            }        }    }    else     {        // no path to local jar archive        finalStatus = nsInstall::DOWNLOAD_ERROR;    }    if(notifier)     {        if ( sendStatus )            notifier->FinalStatus( url.GetUnicode(), finalStatus );        notifier->AfterJavascriptEvaluation( url.GetUnicode() );    }    if (scriptBuffer) delete [] scriptBuffer;    if ( !url.Equals("file:/",PR_FALSE,6) )    {        // delete the jarfile only if we've downloaded it        jarpath.Delete(PR_FALSE);    }    softwareUpdate->SetActiveNotifier(0);    softwareUpdate->InstallJarCallBack();}