Bug 1616079 - Checking if RemoteWorkerChild::mState is Pending before dispatching IninializeWorkerRunnable r=dom-workers-and-storage-reviewers,perry

Differential Revision: https://phabricator.services.mozilla.com/D64049

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Eden Chuang 2020-02-26 18:11:36 +00:00
Родитель 3da50ef6ba
Коммит 339fd6a4e3
1 изменённых файлов: 7 добавлений и 1 удалений

Просмотреть файл

@ -452,7 +452,13 @@ nsresult RemoteWorkerChild::ExecWorkerOnMainThread(RemoteWorkerData&& aData) {
nsCOMPtr<nsIRunnable> r = NS_NewRunnableFunction(
__func__, [initializeWorkerRunnable = std::move(runnable),
self = std::move(self)] {
if (NS_WARN_IF(!initializeWorkerRunnable->Dispatch())) {
// Checking RemoteWorkerChild.mState
bool isPending;
{
auto lock = self->mState.Lock();
isPending = lock->is<Pending>();
}
if (NS_WARN_IF(!isPending || !initializeWorkerRunnable->Dispatch())) {
self->TransitionStateToTerminated();
self->CreationFailedOnAnyThread();
}