Bug 1720568: Be more explicit about the WorkerPrivate self-reference. r=dom-worker-reviewers,asuth a=pascalc

Differential Revision: https://phabricator.services.mozilla.com/D120630
This commit is contained in:
Jens Stutte 2021-07-24 10:04:55 +00:00
parent a2ab5f7884
commit 5fec9b6832

View File

@ -2495,6 +2495,11 @@ already_AddRefed<WorkerPrivate> WorkerPrivate::Constructor(
return nullptr;
}
// From this point on (worker thread has been started) we
// must keep ourself alive. We can now only be cleared by
// ClearSelfAndParentEventTargetRef().
worker->mSelfRef = worker;
worker->EnableDebugger();
MOZ_DIAGNOSTIC_ASSERT(worker->PrincipalIsValid());
@ -2511,8 +2516,6 @@ already_AddRefed<WorkerPrivate> WorkerPrivate::Constructor(
return nullptr;
}
worker->mSelfRef = worker;
return worker.forget();
}