forked from mirrors/gecko-dev
Bug 1860572 - Return nullptr in SharedWorker::Constructor if actorChild cannot send. r=dom-worker-reviewers,asuth
Differential Revision: https://phabricator.services.mozilla.com/D191681
This commit is contained in:
parent
e030c4c2eb
commit
c41a3ab328
1 changed files with 9 additions and 3 deletions
|
|
@ -106,6 +106,11 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
|
|||
}
|
||||
#endif // MOZ_DIAGNOSTIC_ASSERT_ENABLED
|
||||
|
||||
PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread();
|
||||
if (!actorChild || !actorChild->CanSend()) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nsAutoString name;
|
||||
WorkerType workerType = WorkerType::Classic;
|
||||
RequestCredentials credentials = RequestCredentials::Omit;
|
||||
|
|
@ -209,8 +214,6 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
|
|||
SerializeURI(loadInfo.mBaseURI, baseURL);
|
||||
|
||||
// Register this component to PBackground.
|
||||
PBackgroundChild* actorChild = BackgroundChild::GetOrCreateForCurrentThread();
|
||||
|
||||
bool isSecureContext = JS::GetIsSecureContext(js::GetContextRealm(cx));
|
||||
|
||||
Maybe<IPCClientInfo> ipcClientInfo;
|
||||
|
|
@ -252,9 +255,12 @@ already_AddRefed<SharedWorker> SharedWorker::Constructor(
|
|||
|
||||
PSharedWorkerChild* pActor = actorChild->SendPSharedWorkerConstructor(
|
||||
remoteWorkerData, loadInfo.mWindowID, portIdentifier.release());
|
||||
if (!pActor) {
|
||||
MOZ_ASSERT_UNREACHABLE("We already checked PBackground above.");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<SharedWorkerChild> actor = static_cast<SharedWorkerChild*>(pActor);
|
||||
MOZ_ASSERT(actor);
|
||||
|
||||
RefPtr<SharedWorker> sharedWorker =
|
||||
new SharedWorker(window, actor, channel->Port2());
|
||||
|
|
|
|||
Loading…
Reference in a new issue