Bug 1472005 Don't resolve ready promise until the registration has reached the right state version. r=mrbkap

This commit is contained in:
Ben Kelly
2018-07-05 13:13:48 -04:00
parent eaad94a43e
commit 80b1443c29
3 changed files with 49 additions and 1 deletions

View File

@@ -544,7 +544,14 @@ ServiceWorkerContainer::GetReady(ErrorResult& aRv)
RefPtr<ServiceWorkerRegistration> reg =
global->GetOrCreateServiceWorkerRegistration(aDescriptor);
NS_ENSURE_TRUE_VOID(reg);
outer->MaybeResolve(reg);
// Don't resolve the ready promise until the registration has
// reached the right version. This ensures that the active
// worker property is set correctly on the registration.
reg->WhenVersionReached(aDescriptor.Version(),
[outer, reg] (bool aResult) {
outer->MaybeResolve(reg);
});
}, [self, outer] (ErrorResult& aRv) {
outer->MaybeReject(aRv);
});