Bug 1587794 - Do not assume global exists. r=perry

This is effectively a reversion of the change made in
https://hg.mozilla.org/mozilla-central/rev/89c938649297#l1.39 when
DOMMozPromiseRequestHolder was introduced.  I've tried to add some
comments to contextualize what's happening there and why it differs
from other similar callsites.

Longer term we might move to just deleting the underlying actor when
we are disconnected.  Those actors were written assuming an
execution model where letting either end delete the actor would result
in intentional process crashes when a message was received for a
destroyed actor.  That is no longer the case.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andrew Sutherland 2019-10-17 22:52:35 +00:00
Родитель 7f36d96e18
Коммит cb0f2f4a10
1 изменённых файлов: 19 добавлений и 1 удалений

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

@ -240,7 +240,25 @@ already_AddRefed<Promise> ServiceWorkerRegistration::Update(ErrorResult& aRv) {
mInner->Update(
[outer, self](const ServiceWorkerRegistrationDescriptor& aDesc) {
nsIGlobalObject* global = self->GetParentObject();
MOZ_DIAGNOSTIC_ASSERT(global);
// It's possible this binding was detached from the global. In cases
// where we use IPC with Promise callbacks, we use
// DOMMozPromiseRequestHolder in order to auto-disconnect the promise
// that would hold these callbacks. However in bug 1466681 we changed
// this call to use (synchronous) callbacks because the use of
// MozPromise introduced an additional runnable scheduling which made
// it very difficult to maintain ordering required by the standard.
//
// If we were to delete this actor at the time of DETH detaching, we
// would not need to do this check because the IPC callback of the
// RemoteServiceWorkerRegistrationImpl lambdas would never occur.
// However, its actors currently depend on asking the parent to delete
// the actor for us. Given relaxations in the IPC lifecyle, we could
// potentially issue a direct termination, but that requires additional
// evaluation.
if (!global) {
outer->MaybeReject(NS_ERROR_DOM_INVALID_STATE_ERR);
return;
}
RefPtr<ServiceWorkerRegistration> ref =
global->GetOrCreateServiceWorkerRegistration(aDesc);
if (!ref) {