Bug 1798986 - Track UnstrippedURI in SessionHistory, r=smaug,timhuang

Previously, we tracked UnstrippedURI on the nsDocShellLoadState and LoadInfo,
and manually filled it in to match the previous load when doing a
LOAD_CMD_RELOAD in nsDocShell. It is more consistent with other load types to
instead store the information in the load state, allowing it to be handled
consistently for reloads and other history operations.

Unfortunately, this patch has some extra complexity right now, as it needs to
support both SHIP and non-SHIP session history. This should disappear in the
future when we switch to using exclusively SHIP.

Differential Revision: https://phabricator.services.mozilla.com/D161196
This commit is contained in:
Nika Layzell
2022-11-14 17:10:29 +00:00
parent e2ea61a17b
commit bd8aaabe12
9 changed files with 90 additions and 49 deletions

View File

@@ -578,7 +578,7 @@ bool nsDocShellLoadState::LoadIsFromSessionHistory() const {
}
void nsDocShellLoadState::MaybeStripTrackerQueryStrings(
BrowsingContext* aContext, nsIURI* aCurrentUnstrippedURI) {
BrowsingContext* aContext) {
MOZ_ASSERT(aContext);
// Return early if the triggering principal doesn't exist. This could happen
@@ -619,17 +619,14 @@ void nsDocShellLoadState::MaybeStripTrackerQueryStrings(
uint32_t numStripped = URLQueryStringStripper::Strip(
URI(), aContext->UsePrivateBrowsing(), strippedURI);
if (numStripped) {
mUnstrippedURI = URI();
if (!mUnstrippedURI) {
mUnstrippedURI = URI();
}
SetURI(strippedURI);
Telemetry::AccumulateCategorical(
Telemetry::LABELS_QUERY_STRIPPING_COUNT::StripForNavigation);
Telemetry::Accumulate(Telemetry::QUERY_STRIPPING_PARAM_COUNT, numStripped);
} 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
@@ -1076,3 +1073,7 @@ DocShellLoadStateInit nsDocShellLoadState::Serialize() {
}
nsIURI* nsDocShellLoadState::GetUnstrippedURI() const { return mUnstrippedURI; }
void nsDocShellLoadState::SetUnstrippedURI(nsIURI* aUnstrippedURI) {
mUnstrippedURI = aUnstrippedURI;
}