diff --git a/xpcom/threads/ThreadEventTarget.cpp b/xpcom/threads/ThreadEventTarget.cpp index cb229669777c..695e62a06b75 100644 --- a/xpcom/threads/ThreadEventTarget.cpp +++ b/xpcom/threads/ThreadEventTarget.cpp @@ -23,7 +23,12 @@ using namespace mozilla; ThreadEventTarget::ThreadEventTarget(ThreadTargetSink* aSink, bool aIsMainThread) - : mSink(aSink), mIsMainThread(aIsMainThread) { + : mSink(aSink) +#ifdef DEBUG + , + mIsMainThread(aIsMainThread) +#endif +{ mThread = PR_GetCurrentThread(); } @@ -52,10 +57,9 @@ ThreadEventTarget::Dispatch(already_AddRefed aEvent, return NS_ERROR_INVALID_ARG; } - if (gXPCOMThreadsShutDown && !mIsMainThread) { - NS_ASSERTION(false, "Failed Dispatch after xpcom-shutdown-threads"); - return NS_ERROR_ILLEGAL_DURING_SHUTDOWN; - } + NS_ASSERTION(!gXPCOMThreadsShutDown || mIsMainThread || + PR_GetCurrentThread() == mThread, + "Dispatch to non-main thread after xpcom-shutdown-threads"); LogRunnable::LogDispatch(event.get()); diff --git a/xpcom/threads/ThreadEventTarget.h b/xpcom/threads/ThreadEventTarget.h index 6ced779fb987..5b5b188fdaf3 100644 --- a/xpcom/threads/ThreadEventTarget.h +++ b/xpcom/threads/ThreadEventTarget.h @@ -47,7 +47,9 @@ class ThreadEventTarget final : public nsISerialEventTarget { ~ThreadEventTarget(); RefPtr mSink; +#ifdef DEBUG bool mIsMainThread; +#endif }; } // namespace mozilla