Skip to content

Commit

Permalink
Bug 1510909 - Bypass calling nsContentUtils::IsThirdPartyWindowOrChan…
Browse files Browse the repository at this point in the history
…nel() for BEHAVIOR_REJECT_TRACKER r=baku

Calling this function is just a waste of time since we will check
third-partiness a few statements further down.

Differential Revision: https://phabricator.services.mozilla.com/D13500
  • Loading branch information
ehsan committed Dec 4, 2018
1 parent 7c383cf commit b983c4a
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions toolkit/components/antitracking/AntiTrackingCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -885,10 +885,15 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
return false;
}

// Let's check if this is a 3rd party context.
if (!nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr, aURI)) {
LOG(("Our window isn't a third-party window"));
return true;
// As a performance optimization, we only perform this check for
// BEHAVIOR_REJECT_FOREIGN and BEHAVIOR_LIMIT_FOREIGN. For
// BEHAVIOR_REJECT_TRACKER, third-partiness is implicily checked later below.
if (behavior != nsICookieService::BEHAVIOR_REJECT_TRACKER) {
// Let's check if this is a 3rd party context.
if (!nsContentUtils::IsThirdPartyWindowOrChannel(aWindow, nullptr, aURI)) {
LOG(("Our window isn't a third-party window"));
return true;
}
}

if (behavior == nsICookieService::BEHAVIOR_REJECT_FOREIGN ||
Expand All @@ -909,6 +914,20 @@ bool AntiTrackingCommon::IsFirstPartyStorageAccessGrantedFor(
return true;
}

#ifdef DEBUG
nsCOMPtr<mozIThirdPartyUtil> thirdPartyUtil = services::GetThirdPartyUtil();
if (thirdPartyUtil) {
bool thirdParty = false;
nsresult rv = thirdPartyUtil->IsThirdPartyWindow(aWindow->GetOuterWindow(),
aURI, &thirdParty);
// The result of this assertion depends on whether IsThirdPartyWindow
// succeeds, because otherwise IsThirdPartyWindowOrChannel artificially
// fails.
MOZ_ASSERT(nsContentUtils::IsThirdPartyWindowOrChannel(
aWindow, nullptr, aURI) == NS_SUCCEEDED(rv));
}
#endif

nsCOMPtr<nsIPrincipal> parentPrincipal;
nsCOMPtr<nsIURI> parentPrincipalURI;
nsCOMPtr<nsIURI> trackingURI;
Expand Down

0 comments on commit b983c4a

Please sign in to comment.