Bug 1482988 - Handle null arguments in nsContentUtils::StorageDisabledByAntiTracking correctly; r=smaug

This commit is contained in:
Ehsan Akhgari 2018-08-13 15:54:55 -04:00
parent d1e5833a37
commit e01dca1048
2 changed files with 18 additions and 9 deletions

View File

@ -8902,16 +8902,24 @@ nsContentUtils::StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
return false;
}
// FIXME: this is wrong. This method is called also with aWindow and a null
// aChannel.
nsCOMPtr<mozIDOMWindowProxy> win;
nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
getter_AddRefs(win));
NS_ENSURE_SUCCESS(rv, false);
auto* pwin = nsPIDOMWindowOuter::From(win);
nsCOMPtr<nsPIDOMWindowOuter> pwin;
if (aWindow) {
auto* outer = nsGlobalWindowOuter::Cast(aWindow->GetOuterWindow());
if (outer) {
pwin = outer->GetTopOuter();
}
} else if (aChannel) {
nsCOMPtr<mozIDOMWindowProxy> win;
nsresult rv = thirdPartyUtil->GetTopWindowForChannel(aChannel,
getter_AddRefs(win));
NS_ENSURE_SUCCESS(rv, false);
pwin = nsPIDOMWindowOuter::From(win);
}
pwin->NotifyContentBlockingState(
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, aChannel);
if (pwin) {
pwin->NotifyContentBlockingState(
nsIWebProgressListener::STATE_BLOCKED_TRACKING_COOKIES, aChannel);
}
}
return disabled;
}

View File

@ -2953,6 +2953,7 @@ public:
/*
* Returns true if this window/channel/aPrincipal should disable storages
* because of the anti-tracking feature.
* Note that either aWindow or aChannel may be null when calling this function.
*/
static bool StorageDisabledByAntiTracking(nsPIDOMWindowInner* aWindow,
nsIChannel* aChannel,