From 3572f908c9b298ce13476d96368de7bb239edadb Mon Sep 17 00:00:00 2001 From: Ms2ger Date: Sun, 15 Jan 2012 09:13:09 +0100 Subject: [PATCH] Bug 677079 - Part i: Expose errorReporter in jsapi.h; r=mrbkap --- js/src/jsapi.cpp | 6 ++++++ js/src/jsapi.h | 2 ++ js/xpconnect/src/XPCWrappedJSClass.cpp | 6 +++--- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 96adb27f22bb..4f31bee6efce 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -6281,6 +6281,12 @@ JS_ReportAllocationOverflow(JSContext *cx) js_ReportAllocationOverflow(cx); } +JS_PUBLIC_API(JSErrorReporter) +JS_GetErrorReporter(JSContext *cx) +{ + return cx->errorReporter; +} + JS_PUBLIC_API(JSErrorReporter) JS_SetErrorReporter(JSContext *cx, JSErrorReporter er) { diff --git a/js/src/jsapi.h b/js/src/jsapi.h index 11c104e9b3f0..2df3f2648cb9 100644 --- a/js/src/jsapi.h +++ b/js/src/jsapi.h @@ -5130,6 +5130,8 @@ struct JSErrorReport { #define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0) #define JSREPORT_IS_STRICT_MODE_ERROR(flags) (((flags) & \ JSREPORT_STRICT_MODE_ERROR) != 0) +extern JS_PUBLIC_API(JSErrorReporter) +JS_GetErrorReporter(JSContext *cx); extern JS_PUBLIC_API(JSErrorReporter) JS_SetErrorReporter(JSContext *cx, JSErrorReporter er); diff --git a/js/xpconnect/src/XPCWrappedJSClass.cpp b/js/xpconnect/src/XPCWrappedJSClass.cpp index e3bab51a1fb3..f047b70ae495 100644 --- a/js/xpconnect/src/XPCWrappedJSClass.cpp +++ b/js/xpconnect/src/XPCWrappedJSClass.cpp @@ -49,7 +49,7 @@ #include "AccessCheck.h" #include "nsJSUtils.h" -#include "jscntxt.h" // mJSContext->errorReporter, js::AutoValueVector +#include "jscntxt.h" // js::AutoValueVector NS_IMPL_THREADSAFE_ISUPPORTS1(nsXPCWrappedJSClass, nsIXPCWrappedJSClass) @@ -64,7 +64,7 @@ bool AutoScriptEvaluate::StartEvaluating(JSObject *scope, JSErrorReporter errorR return true; mEvaluated = true; - if (!mJSContext->errorReporter) { + if (!JS_GetErrorReporter(mJSContext)) { JS_SetErrorReporter(mJSContext, errorReporter); mErrorReporterSet = true; } @@ -1057,7 +1057,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx, // Try to use the error reporter set on the context to handle this // error if it came from a JS exception. if (reportable && is_js_exception && - cx->errorReporter != xpcWrappedJSErrorReporter) { + JS_GetErrorReporter(cx) != xpcWrappedJSErrorReporter) { reportable = !JS_ReportPendingException(cx); }