Verified Commit 9d8af849 authored by Timothy Nikkel's avatar Timothy Nikkel Committed by ma1
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 823e74d9
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -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);