mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1283674 P1 Make ServiceWorkerContainer::GetController() work gracefully when its window is disconnected. r=baku
This commit is contained in:
parent
4a424977b6
commit
d2dad60d4c
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user