nsCOMPtr<nsIScriptSecurityManager> secman = do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID);  if (!secman) { JS_ReportError(event->cx, "Could not get script security manager service"); return 0; }  nsCOMPtr<nsIPrincipal> principal; secman->GetSubjectPrincipal(getter_AddRefs(principal)); if (!principal) { JS_ReportError(event->cx, "Could not get principal from script security manager"); return 0; }  PRBool equals = PR_FALSE; principal->Equals(event->princ, &equals);  if (!equals) { JS_ReportError(event->cx, "Principal of callback context is different then InstallTriggers"); return 0; }
static void* handleTriggerEvent(XPITriggerEvent* event){    jsval  ret;    void*  mark;    jsval* args;    JS_BeginRequest(event->cx);    args = JS_PushArguments( event->cx, &mark, "Wi",                             event->URL.get(),                             event->status );    if ( args )    {        nsCOMPtr<nsIJSContextStack> stack =            do_GetService("@mozilla.org/js/xpc/ContextStack;1");        if (stack)            stack->Push(event->cx);        JS_CallFunctionValue( event->cx,                              JSVAL_TO_OBJECT(event->global),                              event->cbval,                              2,                              args,                              &ret );        if (stack)            stack->Pop(nsnull);        JS_PopArguments( event->cx, mark );    }    JS_EndRequest(event->cx);    return 0;}