# HG changeset patch # User Ben Kelly # Date 1516721933 18000 # Node ID c384b60e2a0da234680aa9995892ab3ec4287d68 # Parent c58b6ae1f78fcefe1ebc44aaa300b85ddb07c6a6 Bug 1231211 P8 Make nsDocShell::ShouldPrepareForIntercept() only depend on channel data. r=asuth diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -14224,37 +14224,34 @@ nsDocShell::MaybeNotifyKeywordSearchLoad } NS_IMETHODIMP nsDocShell::ShouldPrepareForIntercept(nsIURI* aURI, nsIChannel* aChannel, bool* aShouldIntercept) { *aShouldIntercept = false; + nsCOMPtr loadInfo = aChannel->GetLoadInfo(); + if (!loadInfo) { + return NS_OK; + } + // For subresource requests we base our decision solely on the client's // controller value. Any settings that would have blocked service worker // access should have been set before the initial navigation created the // window. if (!nsContentUtils::IsNonSubresourceRequest(aChannel)) { - nsCOMPtr doc = GetDocument(); - if (!doc) { - return NS_ERROR_NOT_AVAILABLE; - } - - ErrorResult rv; - *aShouldIntercept = doc->GetController().isSome(); - if (NS_WARN_IF(rv.Failed())) { - return rv.StealNSResult(); - } - + const Maybe& controller = loadInfo->GetController(); + *aShouldIntercept = controller.isSome(); return NS_OK; } nsCOMPtr principal = - BasePrincipal::CreateCodebasePrincipal(aURI, mOriginAttributes); + BasePrincipal::CreateCodebasePrincipal(aURI, + loadInfo->GetOriginAttributes()); // For navigations, first check to see if we are allowed to control a // window with the given URL. if (!ServiceWorkerAllowedToControlWindow(principal, aURI)) { return NS_OK; } RefPtr swm = ServiceWorkerManager::GetInstance();