mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1219749. Add a way to faithfully propagate the "exception is already on JSContext" state through an ErrorResult. r=peterv
This commit is contained in:
parent
415f6a45c6
commit
08e423a53f
@ -135,6 +135,12 @@ ThrowMethodFailed(JSContext* cx, ErrorResult& rv)
|
||||
// uncatchable exception.
|
||||
return false;
|
||||
}
|
||||
if (rv.IsJSContextException()) {
|
||||
// Whatever we need to throw is on the JSContext already. We
|
||||
// can't assert that there is a pending exception on it, though,
|
||||
// because in the uncatchable exception case there won't be one.
|
||||
return false;
|
||||
}
|
||||
if (rv.IsErrorWithMessage()) {
|
||||
rv.ReportErrorWithMessage(cx);
|
||||
return false;
|
||||
|
@ -167,6 +167,17 @@ public:
|
||||
void ReportDOMException(JSContext* cx);
|
||||
bool IsDOMException() const { return ErrorCode() == NS_ERROR_DOM_DOMEXCEPTION; }
|
||||
|
||||
// Flag on the ErrorResult that whatever needs throwing has been
|
||||
// thrown on the JSContext already and we should not mess with it.
|
||||
void NoteJSContextException() {
|
||||
mResult = NS_ERROR_DOM_EXCEPTION_ON_JSCONTEXT;
|
||||
}
|
||||
// Check whether the ErrorResult says to just throw whatever is on
|
||||
// the JSContext already.
|
||||
bool IsJSContextException() {
|
||||
return ErrorCode() == NS_ERROR_DOM_EXCEPTION_ON_JSCONTEXT;
|
||||
}
|
||||
|
||||
// Report a generic error. This should only be used if we're not
|
||||
// some more specific exception type.
|
||||
void ReportGenericError(JSContext* cx);
|
||||
@ -274,6 +285,8 @@ private:
|
||||
MOZ_ASSERT(aRv != NS_ERROR_DOM_DOMEXCEPTION, "Use ThrowDOMException()");
|
||||
MOZ_ASSERT(!IsDOMException(), "Don't overwrite DOM exceptions");
|
||||
MOZ_ASSERT(aRv != NS_ERROR_XPC_NOT_ENOUGH_ARGS, "May need to bring back ThrowNotEnoughArgsError");
|
||||
MOZ_ASSERT(aRv != NS_ERROR_DOM_EXCEPTION_ON_JSCONTEXT,
|
||||
"Use NoteJSContextException");
|
||||
mResult = aRv;
|
||||
}
|
||||
|
||||
|
@ -530,6 +530,12 @@
|
||||
a DOMException */
|
||||
ERROR(NS_ERROR_DOM_DOMEXCEPTION, FAILURE(1017)),
|
||||
|
||||
/* An nsresult value to use in ErrorResult to indicate that we
|
||||
* should just rethrow whatever is on the JSContext (which might be
|
||||
* nothing if an uncatchable exception was thrown).
|
||||
*/
|
||||
ERROR(NS_ERROR_DOM_EXCEPTION_ON_JSCONTEXT, FAILURE(1018)),
|
||||
|
||||
/* May be used to indicate when e.g. setting a property value didn't
|
||||
* actually change the value, like for obj.foo = "bar"; obj.foo = "bar";
|
||||
* the second assignment throws NS_SUCCESS_DOM_NO_OPERATION.
|
||||
|
Loading…
Reference in New Issue
Block a user