Bug 1425975 P5 Make ServiceWorkerManager::RemoveRegistration assert there is no controlled document. r=asuth

This commit is contained in:
Ben Kelly
2018-01-05 12:10:20 -05:00
parent ce8f2bcb86
commit ad5ea09be8

View File

@@ -2309,17 +2309,18 @@ ServiceWorkerManager::RemoveScopeAndRegistration(ServiceWorkerRegistrationInfo*
entry.Remove(); entry.Remove();
} }
// The registration should generally only be removed if there are no controlled // Verify there are no controlled documents for the purged registration.
// documents, but mControlledDocuments can contain references to potentially #ifdef MOZ_DIAGNOSTIC_ASSERT_ENABLED
// controlled docs. This happens when the service worker is not active yet.
// We must purge these references since we are evicting the registration.
for (auto iter = swm->mControlledDocuments.Iter(); !iter.Done(); iter.Next()) { for (auto iter = swm->mControlledDocuments.Iter(); !iter.Done(); iter.Next()) {
ServiceWorkerRegistrationInfo* reg = iter.UserData(); ServiceWorkerRegistrationInfo* reg = iter.UserData();
MOZ_ASSERT(reg);
if (reg->mScope.Equals(aRegistration->mScope)) { if (reg->mScope.Equals(aRegistration->mScope)) {
MOZ_DIAGNOSTIC_ASSERT(false,
"controlled document when removing registration");
iter.Remove(); iter.Remove();
break;
} }
} }
#endif
RefPtr<ServiceWorkerRegistrationInfo> info; RefPtr<ServiceWorkerRegistrationInfo> info;
data->mInfos.Remove(aRegistration->mScope, getter_AddRefs(info)); data->mInfos.Remove(aRegistration->mScope, getter_AddRefs(info));