Bug 1706615 - Part 8: Preserve the unstripped URI when doing a reload. r=smaug

To restore the stripped query parameters when ETP toggle has been set to
off, we preserve the current unstripped URI to the new loadState when
doing a reload. By doing this, it will redirect the channel back to the
unstripped URI because the loading channel is in the content blocking
allow list and it has a unstripped URI in its loadInfo.

Differential Revision: https://phabricator.services.mozilla.com/D116116
This commit is contained in:
Tim Huang
2021-06-02 19:46:22 +00:00
parent dd04813c7a
commit d19d74f38a
3 changed files with 31 additions and 3 deletions

View File

@@ -10451,8 +10451,18 @@ nsresult nsDocShell::DoURILoad(nsDocShellLoadState* aLoadState,
nsLoadFlags loadFlags = aLoadState->CalculateChannelLoadFlags(
mBrowsingContext, Some(uriModified), Some(isXFOError));
// Get the unstripped URI from the current document channel. The unstripped
// URI will be preserved if it's a reload.
nsCOMPtr<nsIURI> currentUnstrippedURI;
nsCOMPtr<nsIChannel> docChannel = GetCurrentDocChannel();
if (docChannel) {
nsCOMPtr<nsILoadInfo> docLoadInfo = docChannel->LoadInfo();
docLoadInfo->GetUnstrippedURI(getter_AddRefs(currentUnstrippedURI));
}
// Strip the target query parameters before creating the channel.
aLoadState->MaybeStripTrackerQueryStrings(mBrowsingContext);
aLoadState->MaybeStripTrackerQueryStrings(mBrowsingContext,
currentUnstrippedURI);
nsCOMPtr<nsIChannel> channel;
if (DocumentChannel::CanUseDocumentChannel(aLoadState->URI())) {