Bug 604026 - Sync event loops in workers should be created only if compatible with the worker shutdown status

This commit is contained in:
janekptacijarabaci 2018-07-05 13:04:44 +02:00 committed by Roy Tam
commit 98546534b0
17 changed files with 102 additions and 56 deletions

View file

@ -568,15 +568,20 @@ WorkerMainThreadRunnable::WorkerMainThreadRunnable(WorkerPrivate* aWorkerPrivate
}
void
WorkerMainThreadRunnable::Dispatch(ErrorResult& aRv)
WorkerMainThreadRunnable::Dispatch(Status aFailStatus, ErrorResult& aRv)
{
mWorkerPrivate->AssertIsOnWorkerThread();
TimeStamp startTime = TimeStamp::NowLoRes();
AutoSyncLoopHolder syncLoop(mWorkerPrivate);
AutoSyncLoopHolder syncLoop(mWorkerPrivate, aFailStatus);
mSyncLoopTarget = syncLoop.EventTarget();
mSyncLoopTarget = syncLoop.GetEventTarget();
if (!mSyncLoopTarget) {
// SyncLoop creation can fail if the worker is shutting down.
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
DebugOnly<nsresult> rv = mWorkerPrivate->DispatchToMainThread(this);
MOZ_ASSERT(NS_SUCCEEDED(rv),
@ -621,7 +626,7 @@ bool
WorkerCheckAPIExposureOnMainThreadRunnable::Dispatch()
{
ErrorResult rv;
WorkerMainThreadRunnable::Dispatch(rv);
WorkerMainThreadRunnable::Dispatch(Terminating, rv);
bool ok = !rv.Failed();
rv.SuppressException();
return ok;