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

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

View File

@ -2508,6 +2508,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());
@ -2524,8 +2529,6 @@ already_AddRefed<WorkerPrivate> WorkerPrivate::Constructor(
return nullptr;
}
worker->mSelfRef = worker;
return worker.forget();
}