Bug 1738636 - Return true if the browsing context is not available for a document in AntiTrackingUtils::IsThirdPartyWindow(). r=pbz

The browsing context of a document might be a nullptr in some rare
cases. This patch makes sure we won't pass a null browsingContext to
IsThirdPartyContext() in AntiTrackingUtils::IsThirdPartyWindow().

We don't have a good way to test this. We can only first land the patch
and see if the crash report stops.

Differential Revision: https://phabricator.services.mozilla.com/D130357
This commit is contained in:
Tim Huang 2021-11-04 20:25:25 +00:00
Родитель bfcef5343a
Коммит 0b04ea1041
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -664,8 +664,10 @@ bool AntiTrackingUtils::IsThirdPartyWindow(nsPIDOMWindowInner* aWindow,
if (!doc->GetChannel()) {
// If we can't get the channel from the document, i.e. initial about:blank
// page, we use the browsingContext of the document to check if it's in the
// third-party context.
return IsThirdPartyContext(doc->GetBrowsingContext());
// third-party context. If the browsing context is still not available, we
// will treat the window as third-party.
RefPtr<BrowsingContext> bc = doc->GetBrowsingContext();
return bc ? IsThirdPartyContext(bc) : true;
}
// We only care whether the channel is 3rd-party with respect to