Skip to content
Snippets Groups Projects
Verified Commit 4956a689 authored by Timothy Nikkel's avatar Timothy Nikkel Committed by Pier Angelo Vendrame
Browse files

Bug 1899180. If a channel is not nsIPrivateBrowsingChannel and has no load...

Bug 1899180. If a channel is not nsIPrivateBrowsingChannel and has no load context, use the private browsing field from it's origin attributes. r=necko-reviewers,anti-tracking-reviewers,valentin

If the channel is not a nsIPrivateBrowsingChannel, and it also has no load context (eg inside svg images) then we will over write a non-zero mPrivateBrowsingId on the OriginAttributes of the channel with 0, making NS_UsePrivateBrowsing return false for the channel.

Differential Revision: https://phabricator.services.mozilla.com/D212083
parent 6cd4e069
Branches
1 merge request!1453TB 43587: Rebased legacy onto 115.22.0esr
......@@ -445,7 +445,7 @@ bool StoragePrincipalHelper::GetOriginAttributes(
nsCOMPtr<nsILoadInfo> loadInfo = aChannel->LoadInfo();
loadInfo->GetOriginAttributes(&aAttributes);
bool isPrivate = false;
bool isPrivate = aAttributes.mPrivateBrowsingId > 0;
nsCOMPtr<nsIPrivateBrowsingChannel> pbChannel = do_QueryInterface(aChannel);
if (pbChannel) {
nsresult rv = pbChannel->GetIsChannelPrivate(&isPrivate);
......@@ -454,7 +454,9 @@ bool StoragePrincipalHelper::GetOriginAttributes(
// Some channels may not implement nsIPrivateBrowsingChannel
nsCOMPtr<nsILoadContext> loadContext;
NS_QueryNotificationCallbacks(aChannel, loadContext);
isPrivate = loadContext && loadContext->UsePrivateBrowsing();
if (loadContext) {
isPrivate = loadContext->UsePrivateBrowsing();
}
}
aAttributes.SyncAttributesWithPrivateBrowsing(isPrivate);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment