зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1144750: Don't attempt to report errors that will cause the warnings only reporter to assert. r=bholley
--HG-- extra : rebase_source : 328482c7113e94c9dc698fc65766021a41079c71 extra : source : 7588e6588dd381d20d81ef8f0b4be1bfc0d6eefc
This commit is contained in:
Родитель
f1476bf0bb
Коммит
eb35f7fae8
|
@ -312,7 +312,6 @@ AutoJSAPI::~AutoJSAPI()
|
|||
{
|
||||
if (mOwnErrorReporting) {
|
||||
MOZ_ASSERT(NS_IsMainThread(), "See corresponding assertion in TakeOwnershipOfErrorReporting()");
|
||||
JS::ContextOptionsRef(cx()).setAutoJSAPIOwnsErrorReporting(mOldAutoJSAPIOwnsErrorReporting);
|
||||
|
||||
if (HasException()) {
|
||||
|
||||
|
@ -342,6 +341,13 @@ AutoJSAPI::~AutoJSAPI()
|
|||
NS_WARNING("OOMed while acquiring uncaught exception from JSAPI");
|
||||
}
|
||||
}
|
||||
|
||||
// We need to do this _after_ processing the existing exception, because the
|
||||
// JS engine can throw while doing that, and uses this bit to determine what
|
||||
// to do in that case: squelch the exception if the bit is set, otherwise
|
||||
// call the error reporter. Calling WarningOnlyErrorReporter with a
|
||||
// non-warning will assert, so we need to make sure we do the former.
|
||||
JS::ContextOptionsRef(cx()).setAutoJSAPIOwnsErrorReporting(mOldAutoJSAPIOwnsErrorReporting);
|
||||
}
|
||||
|
||||
if (mOldErrorReporter.isSome()) {
|
||||
|
|
|
@ -229,6 +229,13 @@ ReportError(JSContext *cx, const char *message, JSErrorReport *reportp,
|
|||
if (cx->options().autoJSAPIOwnsErrorReporting() || JS_IsRunning(cx)) {
|
||||
if (ErrorToException(cx, message, reportp, callback, userRef))
|
||||
return;
|
||||
|
||||
/*
|
||||
* The AutoJSAPI error reporter only allows warnings to be reported so
|
||||
* just ignore this error rather than try to report it.
|
||||
*/
|
||||
if (cx->options().autoJSAPIOwnsErrorReporting())
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -608,6 +608,12 @@ js::ErrorToException(JSContext *cx, const char *message, JSErrorReport *reportp,
|
|||
static bool
|
||||
IsDuckTypedErrorObject(JSContext *cx, HandleObject exnObject, const char **filename_strp)
|
||||
{
|
||||
/*
|
||||
* This function is called from ErrorReport::init and so should not generate
|
||||
* any new exceptions.
|
||||
*/
|
||||
AutoClearPendingException acpe(cx);
|
||||
|
||||
bool found;
|
||||
if (!JS_HasProperty(cx, exnObject, js_message_str, &found) || !found)
|
||||
return false;
|
||||
|
|
|
@ -115,6 +115,20 @@ ExnTypeFromProtoKey(JSProtoKey key)
|
|||
return type;
|
||||
}
|
||||
|
||||
class AutoClearPendingException
|
||||
{
|
||||
JSContext *cx;
|
||||
|
||||
public:
|
||||
explicit AutoClearPendingException(JSContext *cxArg)
|
||||
: cx(cxArg)
|
||||
{ }
|
||||
|
||||
~AutoClearPendingException() {
|
||||
cx->clearPendingException();
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace js
|
||||
|
||||
#endif /* jsexn_h */
|
||||
|
|
Загрузка…
Ссылка в новой задаче