Bug 889911 - Replace mozJSLoaderErrorReporter with SystemErrorReporter and remove the former. r=mrbkap

This commit is contained in:
Bobby Holley 2013-07-15 11:44:50 -07:00
Родитель 9d6c49843f
Коммит fb145e40d2
4 изменённых файлов: 5 добавлений и 69 удалений

Просмотреть файл

@ -45,7 +45,7 @@ interface nsIScriptError : nsIConsoleMessage
* Categories I know about -
* XUL javascript
* content javascript (both of these from nsDocShell, currently)
* component javascript (errors in JS components)
* system javascript (errors in JS components and other system JS)
*/
readonly attribute string category;

Просмотреть файл

@ -123,61 +123,6 @@ static PRLogModuleInfo *gJSCLLog;
#define ERROR_GETTING_SYMBOL "%s - Could not get symbol '%s'."
#define ERROR_SETTING_SYMBOL "%s - Could not set symbol '%s' on target object."
void
mozJSLoaderErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep)
{
nsresult rv;
/* Use the console service to register the error. */
nsCOMPtr<nsIConsoleService> consoleService =
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
/*
* Make an nsIScriptError, populate it with information from this
* error, then log it with the console service. The UI can then
* poll the service to update the Error console.
*/
nsCOMPtr<nsIScriptError> errorObject =
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
if (consoleService && errorObject) {
uint32_t column = rep->uctokenptr - rep->uclinebuf;
const PRUnichar* ucmessage =
static_cast<const PRUnichar*>(rep->ucmessage);
const PRUnichar* uclinebuf =
static_cast<const PRUnichar*>(rep->uclinebuf);
rv = errorObject->Init(
ucmessage ? nsDependentString(ucmessage) : EmptyString(),
NS_ConvertASCIItoUTF16(rep->filename),
uclinebuf ? nsDependentString(uclinebuf) : EmptyString(),
rep->lineno, column, rep->flags,
"component javascript");
if (NS_SUCCEEDED(rv)) {
rv = consoleService->LogMessage(errorObject);
if (NS_SUCCEEDED(rv)) {
// We're done! Skip return to fall thru to stderr
// printout, for the benefit of those invoking the
// browser with -console
// return;
}
}
}
/*
* If any of the above fails for some reason, fall back to
* printing to stderr.
*/
#ifdef DEBUG
fprintf(stderr, "JS Component Loader: %s %s:%d\n"
" %s\n",
JSREPORT_IS_WARNING(rep->flags) ? "WARNING" : "ERROR",
rep->filename, rep->lineno,
message ? message : "<no message>");
#endif
}
static JSBool
Dump(JSContext *cx, unsigned argc, jsval *vp)
{
@ -570,7 +515,7 @@ mozJSComponentLoader::LoadModule(FileLocation &aFile)
return NULL;
}
JSCLAutoErrorReporterSetter aers(cx, mozJSLoaderErrorReporter);
JSCLAutoErrorReporterSetter aers(cx, xpc::SystemErrorReporter);
RootedValue NSGetFactory_val(cx);
if (!JS_GetProperty(cx, entry->obj, "NSGetFactory", NSGetFactory_val.address()) ||
@ -821,7 +766,7 @@ mozJSComponentLoader::ObjectForLocation(nsIFile *aComponentFile,
JS_AbortIfWrongThread(JS_GetRuntime(cx));
JSCLAutoErrorReporterSetter aers(cx, mozJSLoaderErrorReporter);
JSCLAutoErrorReporterSetter aers(cx, xpc::SystemErrorReporter);
bool realFile = false;
RootedObject obj(cx, PrepareObjectForLocation(cx, aComponentFile, aURI,

Просмотреть файл

@ -50,10 +50,6 @@ using namespace JS;
#define LOAD_ERROR_NOSPEC "Failed to get URI spec. This is bad."
#define LOAD_ERROR_CONTENTTOOBIG "ContentLength is too large"
// We just use the same reporter as the component loader
extern void
mozJSLoaderErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep);
mozJSSubScriptLoader::mozJSSubScriptLoader() : mSystemPrincipal(nullptr)
{
// Force construction of the JS component loader. We may need it later.
@ -123,7 +119,7 @@ mozJSSubScriptLoader::ReadScript(nsIURI *uri, JSContext *cx, JSObject *targetObj
/* set our own error reporter so we can report any bad things as catchable
* exceptions, including the source/line number */
er = JS_SetErrorReporter(cx, mozJSLoaderErrorReporter);
er = JS_SetErrorReporter(cx, xpc::SystemErrorReporter);
JS::CompileOptions options(cx);
options.setPrincipals(nsJSPrincipals::get(principal))

Просмотреть файл

@ -129,11 +129,6 @@ static JSClass global_class = {
NULL, NULL, NULL, NULL, TraceXPCGlobal
};
// We just use the same reporter as the component loader
// XXX #include angels cry.
extern void
mozJSLoaderErrorReporter(JSContext *cx, const char *message, JSErrorReport *rep);
JSContext*
XPCJSContextStack::GetSafeJSContext()
{
@ -158,7 +153,7 @@ XPCJSContextStack::GetSafeJSContext()
JSAutoRequest req(mSafeJSContext);
JS::RootedObject glob(mSafeJSContext);
JS_SetErrorReporter(mSafeJSContext, mozJSLoaderErrorReporter);
JS_SetErrorReporter(mSafeJSContext, xpc::SystemErrorReporter);
JS::CompartmentOptions options;
options.setZone(JS::SystemZone);