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:
@@ -573,7 +573,7 @@ bool nsDocShellLoadState::LoadIsFromSessionHistory() const {
|
||||
}
|
||||
|
||||
void nsDocShellLoadState::MaybeStripTrackerQueryStrings(
|
||||
BrowsingContext* aContext) {
|
||||
BrowsingContext* aContext, nsIURI* aCurrentUnstrippedURI) {
|
||||
MOZ_ASSERT(aContext);
|
||||
|
||||
// We don't need to strip for sub frames because the query string has been
|
||||
@@ -605,7 +605,24 @@ void nsDocShellLoadState::MaybeStripTrackerQueryStrings(
|
||||
if (URLQueryStringStripper::Strip(URI(), strippedURI)) {
|
||||
mUnstrippedURI = URI();
|
||||
SetURI(strippedURI);
|
||||
} else if (LoadType() & nsIDocShell::LOAD_CMD_RELOAD) {
|
||||
// Preserve the Unstripped URI if it's a reload. By doing this, we can
|
||||
// restore the stripped query parameters once the ETP has been toggled to
|
||||
// off.
|
||||
mUnstrippedURI = aCurrentUnstrippedURI;
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
// Make sure that unstripped URI is the same as URI() but only the query
|
||||
// string could be different.
|
||||
if (mUnstrippedURI) {
|
||||
nsCOMPtr<nsIURI> uri;
|
||||
URLQueryStringStripper::Strip(mUnstrippedURI, uri);
|
||||
bool equals = false;
|
||||
Unused << URI()->Equals(uri, &equals);
|
||||
MOZ_ASSERT(equals);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const nsString& nsDocShellLoadState::Target() const { return mTarget; }
|
||||
|
||||
Reference in New Issue
Block a user