Bug 1283674 P1 Make ServiceWorkerContainer::GetController() work gracefully when its window is disconnected. r=baku

This commit is contained in:
Ben Kelly 2016-07-04 06:50:25 -07:00
parent 4a424977b6
commit d2dad60d4c
2 changed files with 6 additions and 4 deletions

View File

@ -222,7 +222,6 @@ already_AddRefed<workers::ServiceWorker>
ServiceWorkerContainer::GetController()
{
if (!mControllerWorker) {
nsresult rv;
nsCOMPtr<nsIServiceWorkerManager> swm = mozilla::services::GetServiceWorkerManager();
if (!swm) {
return nullptr;
@ -232,8 +231,8 @@ ServiceWorkerContainer::GetController()
// In theory the DOM ServiceWorker object can exist without the worker
// thread running, but it seems our design does not expect that.
nsCOMPtr<nsISupports> serviceWorker;
rv = swm->GetDocumentController(GetOwner(),
getter_AddRefs(serviceWorker));
nsresult rv = swm->GetDocumentController(GetOwner(),
getter_AddRefs(serviceWorker));
if (NS_WARN_IF(NS_FAILED(rv))) {
return nullptr;
}

View File

@ -2328,7 +2328,10 @@ NS_IMETHODIMP
ServiceWorkerManager::GetDocumentController(nsPIDOMWindowInner* aWindow,
nsISupports** aServiceWorker)
{
MOZ_ASSERT(aWindow);
if (NS_WARN_IF(!aWindow)) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
}
nsCOMPtr<nsIDocument> doc = aWindow->GetExtantDoc();
if (!doc) {
return NS_ERROR_DOM_INVALID_STATE_ERR;