From b3f9fb204501ec174b354635f09d1cfabdd8cacc Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Mon, 8 Sep 2014 16:30:11 -0700 Subject: [PATCH] Bug 1062077 - Switch SystemErrorReporter to xpc::ErrorReport. r=bz --- js/xpconnect/src/nsXPConnect.cpp | 44 +++++--------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/js/xpconnect/src/nsXPConnect.cpp b/js/xpconnect/src/nsXPConnect.cpp index 52c5bec596b..910642cfba6 100644 --- a/js/xpconnect/src/nsXPConnect.cpp +++ b/js/xpconnect/src/nsXPConnect.cpp @@ -197,44 +197,12 @@ xpc::SystemErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep) // exception is ending here, it's not going to get propagated to a caller, // so it's up to us to make it known. - nsresult rv; - - /* Use the console service to register the error. */ - nsCOMPtr consoleService = - do_GetService(NS_CONSOLESERVICE_CONTRACTID); - - /* - * Make an nsIScriptError, populate it with information from this - * error, then log it with the console service. - */ - nsCOMPtr errorObject = - do_CreateInstance(NS_SCRIPTERROR_CONTRACTID); - - if (consoleService && errorObject) { - uint32_t column = rep->uctokenptr - rep->uclinebuf; - - const char16_t* ucmessage = - static_cast(rep->ucmessage); - const char16_t* uclinebuf = - static_cast(rep->uclinebuf); - - rv = errorObject->Init( - ucmessage ? nsDependentString(ucmessage) : EmptyString(), - NS_ConvertASCIItoUTF16(rep->filename), - uclinebuf ? nsDependentString(uclinebuf) : EmptyString(), - rep->lineno, column, rep->flags, - "system javascript"); - if (NS_SUCCEEDED(rv)) - consoleService->LogMessage(errorObject); - } - - if (nsContentUtils::DOMWindowDumpEnabled()) { - fprintf(stderr, "System JS : %s %s:%d - %s\n", - JSREPORT_IS_WARNING(rep->flags) ? "WARNING" : "ERROR", - rep->filename, rep->lineno, - message ? message : ""); - } - + nsRefPtr report = new ErrorReport(); + // Note that the only effect of the global we pass here is to distinguish + // between "chrome javascript" and "content javascript", so we can just + // hackily pass the privileged junk scope for the time being. + report->Init(rep, message, GetNativeForGlobal(xpc::PrivilegedJunkScope())); + report->LogToConsole(); } void