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-16 18:25:21 +00:00
Родитель b3214f51b9
Коммит fb1cb73fa2
10 изменённых файлов: 120 добавлений и 112 удалений

Просмотреть файл

@ -2073,10 +2073,6 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
wgc->SendLoadURI(this, aLoadState, aSetNavigating);
}
} else if (XRE_IsParentProcess()) {
// Strip the target query parameters before loading the URI in the parent.
// The loading in content will be handled in nsDocShell.
aLoadState->MaybeStripTrackerQueryStrings(this);
if (Canonical()->LoadInParent(aLoadState, aSetNavigating)) {
return NS_OK;
}

Просмотреть файл

@ -9870,6 +9870,9 @@ nsIPrincipal* nsDocShell::GetInheritedPrincipal(
isSrcdoc);
}
// Strip the target query parameters before creating the channel.
aLoadState->MaybeStripTrackerQueryStrings(aBrowsingContext);
OriginAttributes attrs;
// Inherit origin attributes from PrincipalToInherit if inheritAttrs is
@ -10540,19 +10543,6 @@ 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,
currentUnstrippedURI);
nsCOMPtr<nsIChannel> channel;
if (DocumentChannel::CanUseDocumentChannel(aLoadState->URI()) &&
!isAboutBlankLoadOntoInitialAboutBlank) {
@ -11571,6 +11561,9 @@ nsresult nsDocShell::UpdateURLAndHistory(Document* aDocument, nsIURI* aNewURI,
newSHEntry->SetURI(aNewURI);
newSHEntry->SetOriginalURI(aNewURI);
// We replaced the URI of the entry, clear the unstripped URI as it
// shouldn't be used for reloads anymore.
newSHEntry->SetUnstrippedURI(nullptr);
// Setting the resultPrincipalURI to nullptr is fine here: it will cause
// NS_GetFinalChannelURI to use the originalURI as the URI, which is aNewURI
// in our case. We could also set it to aNewURI, with the same result.
@ -11798,6 +11791,7 @@ nsresult nsDocShell::AddToSessionHistory(
nsCOMPtr<nsIInputStream> inputStream;
nsCOMPtr<nsIURI> originalURI;
nsCOMPtr<nsIURI> resultPrincipalURI;
nsCOMPtr<nsIURI> unstrippedURI;
bool loadReplace = false;
nsCOMPtr<nsIReferrerInfo> referrerInfo;
uint32_t cacheKey = 0;
@ -11851,6 +11845,8 @@ nsresult nsDocShell::AddToSessionHistory(
loadInfo->GetResultPrincipalURI(getter_AddRefs(resultPrincipalURI));
loadInfo->GetUnstrippedURI(getter_AddRefs(unstrippedURI));
userActivation = loadInfo->GetHasValidUserGestureActivation();
// For now keep storing just the principal in the SHEntry.
@ -11920,8 +11916,9 @@ nsresult nsDocShell::AddToSessionHistory(
triggeringPrincipal, // Channel or provided principal
principalToInherit, partitionedPrincipalToInherit, csp,
HistoryID(), GetCreatedDynamically(), originalURI,
resultPrincipalURI, loadReplace, referrerInfo, srcdoc,
srcdocEntry, baseURI, saveLayoutState, expired, userActivation);
resultPrincipalURI, unstrippedURI, loadReplace, referrerInfo,
srcdoc, srcdocEntry, baseURI, saveLayoutState, expired,
userActivation);
if (mBrowsingContext->IsTop() && GetSessionHistory()) {
bool shouldPersist = ShouldAddToSessionHistory(aURI, aChannel);
@ -12006,6 +12003,7 @@ void nsDocShell::UpdateActiveEntry(
aURI, aTriggeringPrincipal, nullptr, nullptr, aCsp, mContentTypeHint);
}
mActiveEntry->SetOriginalURI(aOriginalURI);
mActiveEntry->SetUnstrippedURI(nullptr);
mActiveEntry->SetReferrerInfo(aReferrerInfo);
mActiveEntry->SetTitle(aTitle);
mActiveEntry->SetStateData(static_cast<nsStructuredCloneContainer*>(aData));

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -249,6 +249,8 @@ class nsDocShellLoadState final {
nsIURI* GetUnstrippedURI() const;
void SetUnstrippedURI(nsIURI* aUnstrippedURI);
// Give the type of DocShell we're loading into (chrome/content/etc) and
// origin attributes for the URI we're loading, figure out if we should
// inherit our principal from the document the load was requested from, or
@ -329,8 +331,7 @@ class nsDocShellLoadState final {
void SetLoadIsFromSessionHistory(int32_t aOffset, bool aLoadingCurrentEntry);
void ClearLoadIsFromSessionHistory();
void MaybeStripTrackerQueryStrings(mozilla::dom::BrowsingContext* aContext,
nsIURI* aCurrentUnstrippedURI = nullptr);
void MaybeStripTrackerQueryStrings(mozilla::dom::BrowsingContext* aContext);
protected:
// Destructor can't be defaulted or inlined, as header doesn't have all type

Просмотреть файл

@ -45,6 +45,7 @@ SessionHistoryInfo::SessionHistoryInfo(nsDocShellLoadState* aLoadState,
: mURI(aLoadState->URI()),
mOriginalURI(aLoadState->OriginalURI()),
mResultPrincipalURI(aLoadState->ResultPrincipalURI()),
mUnstrippedURI(aLoadState->GetUnstrippedURI()),
mLoadType(aLoadState->LoadType()),
mSrcdocData(aLoadState->SrcdocData().IsVoid()
? Nothing()
@ -103,6 +104,7 @@ SessionHistoryInfo::SessionHistoryInfo(
aChannel->GetLoadInfo(getter_AddRefs(loadInfo));
loadInfo->GetResultPrincipalURI(getter_AddRefs(mResultPrincipalURI));
loadInfo->GetUnstrippedURI(getter_AddRefs(mUnstrippedURI));
loadInfo->GetTriggeringPrincipal(
getter_AddRefs(mSharedState.Get()->mTriggeringPrincipal));
loadInfo->GetPrincipalToInherit(
@ -135,6 +137,7 @@ void SessionHistoryInfo::Reset(nsIURI* aURI, const nsID& aDocShellID,
mURI = aURI;
mOriginalURI = nullptr;
mResultPrincipalURI = nullptr;
mUnstrippedURI = nullptr;
mReferrerInfo = nullptr;
// Default title is the URL.
nsAutoCString spec;
@ -245,6 +248,7 @@ void SessionHistoryInfo::SetSaveLayoutStateFlag(bool aSaveLayoutStateFlag) {
void SessionHistoryInfo::FillLoadInfo(nsDocShellLoadState& aLoadState) const {
aLoadState.SetOriginalURI(mOriginalURI);
aLoadState.SetMaybeResultPrincipalURI(Some(mResultPrincipalURI));
aLoadState.SetUnstrippedURI(mUnstrippedURI);
aLoadState.SetLoadReplace(mLoadReplace);
nsCOMPtr<nsIInputStream> postData = GetPostData();
aLoadState.SetPostDataStream(postData);
@ -528,6 +532,19 @@ SessionHistoryEntry::SetResultPrincipalURI(nsIURI* aResultPrincipalURI) {
return NS_OK;
}
NS_IMETHODIMP
SessionHistoryEntry::GetUnstrippedURI(nsIURI** aUnstrippedURI) {
nsCOMPtr<nsIURI> unstrippedURI = mInfo->mUnstrippedURI;
unstrippedURI.forget(aUnstrippedURI);
return NS_OK;
}
NS_IMETHODIMP
SessionHistoryEntry::SetUnstrippedURI(nsIURI* aUnstrippedURI) {
mInfo->mUnstrippedURI = aUnstrippedURI;
return NS_OK;
}
NS_IMETHODIMP
SessionHistoryEntry::GetLoadReplace(bool* aLoadReplace) {
*aLoadReplace = mInfo->mLoadReplace;
@ -1049,9 +1066,9 @@ SessionHistoryEntry::Create(
nsIPrincipal* aPartitionedPrincipalToInherit,
nsIContentSecurityPolicy* aCsp, const nsID& aDocshellID,
bool aDynamicCreation, nsIURI* aOriginalURI, nsIURI* aResultPrincipalURI,
bool aLoadReplace, nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdoc,
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState, bool aExpired,
bool aUserActivation) {
nsIURI* aUnstrippedURI, bool aLoadReplace, nsIReferrerInfo* aReferrerInfo,
const nsAString& aSrcdoc, bool aSrcdocEntry, nsIURI* aBaseURI,
bool aSaveLayoutState, bool aExpired, bool aUserActivation) {
MOZ_CRASH("Might need to implement this");
return NS_ERROR_NOT_IMPLEMENTED;
}
@ -1513,6 +1530,7 @@ void IPDLParamTraits<dom::SessionHistoryInfo>::Write(
WriteIPDLParam(aWriter, aActor, aParam.mURI);
WriteIPDLParam(aWriter, aActor, aParam.mOriginalURI);
WriteIPDLParam(aWriter, aActor, aParam.mResultPrincipalURI);
WriteIPDLParam(aWriter, aActor, aParam.mUnstrippedURI);
WriteIPDLParam(aWriter, aActor, aParam.mReferrerInfo);
WriteIPDLParam(aWriter, aActor, aParam.mTitle);
WriteIPDLParam(aWriter, aActor, aParam.mName);
@ -1554,6 +1572,7 @@ bool IPDLParamTraits<dom::SessionHistoryInfo>::Read(
if (!ReadIPDLParam(aReader, aActor, &aResult->mURI) ||
!ReadIPDLParam(aReader, aActor, &aResult->mOriginalURI) ||
!ReadIPDLParam(aReader, aActor, &aResult->mResultPrincipalURI) ||
!ReadIPDLParam(aReader, aActor, &aResult->mUnstrippedURI) ||
!ReadIPDLParam(aReader, aActor, &aResult->mReferrerInfo) ||
!ReadIPDLParam(aReader, aActor, &aResult->mTitle) ||
!ReadIPDLParam(aReader, aActor, &aResult->mName) ||

Просмотреть файл

@ -67,6 +67,11 @@ class SessionHistoryInfo {
void SetOriginalURI(nsIURI* aOriginalURI) { mOriginalURI = aOriginalURI; }
nsIURI* GetUnstrippedURI() const { return mUnstrippedURI; }
void SetUnstrippedURI(nsIURI* aUnstrippedURI) {
mUnstrippedURI = aUnstrippedURI;
}
void SetResultPrincipalURI(nsIURI* aResultPrincipalURI) {
mResultPrincipalURI = aResultPrincipalURI;
}
@ -160,6 +165,7 @@ class SessionHistoryInfo {
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mResultPrincipalURI;
nsCOMPtr<nsIURI> mUnstrippedURI;
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
nsString mTitle;
nsString mName;

Просмотреть файл

@ -65,6 +65,11 @@ interface nsISHEntry : nsISupports
*/
[infallible] attribute nsIURI resultPrincipalURI;
/**
* If non-null, the URI as it was before query stripping was performed.
*/
[infallible] attribute nsIURI unstrippedURI;
/**
* This flag remembers whether channel has LOAD_REPLACE set.
*/
@ -324,6 +329,7 @@ interface nsISHEntry : nsISupports
in boolean dynamicCreation,
in nsIURI originalURI,
in nsIURI resultPrincipalURI,
in nsIURI unstrippedURI,
in bool loadReplace,
in nsIReferrerInfo referrerInfo,
in AString srcdoc,

Просмотреть файл

@ -51,16 +51,14 @@ nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
mURI(aOther.mURI),
mOriginalURI(aOther.mOriginalURI),
mResultPrincipalURI(aOther.mResultPrincipalURI),
mUnstrippedURI(aOther.mUnstrippedURI),
mReferrerInfo(aOther.mReferrerInfo),
mTitle(aOther.mTitle),
mPostData(aOther.mPostData),
mLoadType(0) // XXX why not copy?
,
mLoadType(0), // XXX why not copy?
mID(aOther.mID),
mScrollPositionX(0) // XXX why not copy?
,
mScrollPositionY(0) // XXX why not copy?
,
mScrollPositionX(0), // XXX why not copy?
mScrollPositionY(0), // XXX why not copy?
mParent(aOther.mParent),
mStateData(aOther.mStateData),
mSrcdocData(aOther.mSrcdocData),
@ -150,6 +148,19 @@ nsSHEntry::SetResultPrincipalURI(nsIURI* aResultPrincipalURI) {
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetUnstrippedURI(nsIURI** aUnstrippedURI) {
*aUnstrippedURI = mUnstrippedURI;
NS_IF_ADDREF(*aUnstrippedURI);
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::SetUnstrippedURI(nsIURI* aUnstrippedURI) {
mUnstrippedURI = aUnstrippedURI;
return NS_OK;
}
NS_IMETHODIMP
nsSHEntry::GetLoadReplace(bool* aLoadReplace) {
*aLoadReplace = mLoadReplace;
@ -363,18 +374,16 @@ nsSHEntry::SetContentType(const nsACString& aContentType) {
}
NS_IMETHODIMP
nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
nsIInputStream* aInputStream, uint32_t aCacheKey,
const nsACString& aContentType,
nsIPrincipal* aTriggeringPrincipal,
nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aPartitionedPrincipalToInherit,
nsIContentSecurityPolicy* aCsp, const nsID& aDocShellID,
bool aDynamicCreation, nsIURI* aOriginalURI,
nsIURI* aResultPrincipalURI, bool aLoadReplace,
nsIReferrerInfo* aReferrerInfo, const nsAString& aSrcdocData,
bool aSrcdocEntry, nsIURI* aBaseURI, bool aSaveLayoutState,
bool aExpired, bool aUserActivation) {
nsSHEntry::Create(
nsIURI* aURI, const nsAString& aTitle, nsIInputStream* aInputStream,
uint32_t aCacheKey, const nsACString& aContentType,
nsIPrincipal* aTriggeringPrincipal, nsIPrincipal* aPrincipalToInherit,
nsIPrincipal* aPartitionedPrincipalToInherit,
nsIContentSecurityPolicy* aCsp, const nsID& aDocShellID,
bool aDynamicCreation, nsIURI* aOriginalURI, nsIURI* aResultPrincipalURI,
nsIURI* aUnstrippedURI, bool aLoadReplace, nsIReferrerInfo* aReferrerInfo,
const nsAString& aSrcdocData, bool aSrcdocEntry, nsIURI* aBaseURI,
bool aSaveLayoutState, bool aExpired, bool aUserActivation) {
MOZ_ASSERT(
aTriggeringPrincipal,
"need a valid triggeringPrincipal to create a session history entry");
@ -413,6 +422,7 @@ nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
mOriginalURI = aOriginalURI;
mResultPrincipalURI = aResultPrincipalURI;
mUnstrippedURI = aUnstrippedURI;
mLoadReplace = aLoadReplace;
mReferrerInfo = aReferrerInfo;
@ -893,6 +903,9 @@ nsSHEntry::CreateLoadInfo(nsDocShellLoadState** aLoadState) {
emplacedResultPrincipalURI.emplace(std::move(resultPrincipalURI));
loadState->SetMaybeResultPrincipalURI(emplacedResultPrincipalURI);
nsCOMPtr<nsIURI> unstrippedURI = GetUnstrippedURI();
loadState->SetUnstrippedURI(unstrippedURI);
loadState->SetLoadReplace(GetLoadReplace());
nsCOMPtr<nsIInputStream> postData = GetPostData();
loadState->SetPostDataStream(postData);

Просмотреть файл

@ -45,6 +45,7 @@ class nsSHEntry : public nsISHEntry {
nsCOMPtr<nsIURI> mURI;
nsCOMPtr<nsIURI> mOriginalURI;
nsCOMPtr<nsIURI> mResultPrincipalURI;
nsCOMPtr<nsIURI> mUnstrippedURI;
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
nsString mTitle;
nsString mName;

Просмотреть файл

@ -50,7 +50,10 @@ async function clearTelemetry() {
// sync first to avoid any race conditions where telemetry arrives after
// clearing.
if (!isCleared()) {
await TestUtils.waitForCondition(isCleared);
await TestUtils.waitForCondition(
isCleared,
"waiting for query stripping probes to be cleared"
);
}
ok(true, "Telemetry has been cleared.");
@ -65,23 +68,15 @@ async function verifyQueryString(browser, expected) {
});
}
async function getTelemetryProbe(probeInParent, key, label, checkCntFn) {
async function getTelemetryProbe(key, label, checkCntFn) {
let histogram;
// Wait until the telemetry probe appears.
await TestUtils.waitForCondition(() => {
let histograms;
if (probeInParent) {
histograms = Services.telemetry.getSnapshotForHistograms(
"main",
false /* clear */
).parent;
} else {
histograms = Services.telemetry.getSnapshotForHistograms(
"main",
false /* clear */
).content;
}
let histograms = Services.telemetry.getSnapshotForHistograms(
"main",
false /* clear */
).parent;
histogram = histograms[key];
let checkRes = false;
@ -91,18 +86,13 @@ async function getTelemetryProbe(probeInParent, key, label, checkCntFn) {
}
return checkRes;
});
}, `waiting for telemetry probe (key=${key}, label=${label}) to appear`);
return histogram.values[label];
}
async function checkTelemetryProbe(probeInParent, key, expectedCnt, label) {
let cnt = await getTelemetryProbe(
probeInParent,
key,
label,
cnt => cnt == expectedCnt
);
async function checkTelemetryProbe(key, expectedCnt, label) {
let cnt = await getTelemetryProbe(key, label, cnt => cnt == expectedCnt);
is(cnt, expectedCnt, "There should be expected count in telemetry.");
}
@ -131,21 +121,18 @@ add_task(async function testQueryStrippingNavigationInParent() {
await verifyQueryString(browser, "");
});
// Verify the telemetry probe. The stripping for new tab loading would happen
// in the parent process, so we check values in parent process.
// Verify the telemetry probe.
await checkTelemetryProbe(
true,
QUERY_STRIPPING_COUNT,
1,
LABEL_STRIP_FOR_NAVIGATION
);
await checkTelemetryProbe(true, QUERY_STRIPPING_PARAM_COUNT, 1, "1");
await checkTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, 1, "1");
// Because there would be some loading happening during the test and they
// could interfere the count here. So, we only verify if the counter is
// increased, but not the exact count.
let newNavigationCnt = await getTelemetryProbe(
true,
QUERY_STRIPPING_COUNT,
LABEL_NAVIGATION,
cnt => cnt > 0
@ -176,18 +163,16 @@ add_task(async function testQueryStrippingNavigationInContent() {
await verifyQueryString(browser, "");
});
// Verify the telemetry probe in content process.
// Verify the telemetry probe.
await checkTelemetryProbe(
false,
QUERY_STRIPPING_COUNT,
1,
LABEL_STRIP_FOR_NAVIGATION
);
await checkTelemetryProbe(false, QUERY_STRIPPING_PARAM_COUNT, 1, "1");
await checkTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, 1, "1");
// Check if the navigation count is increased.
let newNavigationCnt = await getTelemetryProbe(
false,
QUERY_STRIPPING_COUNT,
LABEL_NAVIGATION,
cnt => cnt > 0
@ -220,29 +205,22 @@ add_task(async function testQueryStrippingNavigationInContentQueryCount() {
await verifyQueryString(browser, "");
});
// Verify the telemetry probe in content process.
// Verify the telemetry probe.
await checkTelemetryProbe(
false,
QUERY_STRIPPING_COUNT,
1,
LABEL_STRIP_FOR_NAVIGATION
);
await getTelemetryProbe(false, QUERY_STRIPPING_PARAM_COUNT, "0", cnt => !cnt);
await getTelemetryProbe(false, QUERY_STRIPPING_PARAM_COUNT, "1", cnt => !cnt);
await getTelemetryProbe(false, QUERY_STRIPPING_PARAM_COUNT, "2", cnt => !cnt);
await getTelemetryProbe(false, QUERY_STRIPPING_PARAM_COUNT, "3", cnt => !cnt);
await getTelemetryProbe(
false,
QUERY_STRIPPING_PARAM_COUNT,
"4",
cnt => cnt == 1
);
await getTelemetryProbe(false, QUERY_STRIPPING_PARAM_COUNT, "5", cnt => !cnt);
await getTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, "0", cnt => !cnt);
await getTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, "1", cnt => !cnt);
await getTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, "2", cnt => !cnt);
await getTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, "3", cnt => !cnt);
await getTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, "4", cnt => cnt == 1);
await getTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, "5", cnt => !cnt);
// Check if the navigation count is increased.
let newNavigationCnt = await getTelemetryProbe(
false,
QUERY_STRIPPING_COUNT,
LABEL_NAVIGATION,
cnt => cnt > 0
@ -275,14 +253,9 @@ add_task(async function testQueryStrippingRedirect() {
// Verify the telemetry probe in parent process. Note that there is no
// non-test loading is using redirect. So, we can check the exact count here.
await checkTelemetryProbe(
true,
QUERY_STRIPPING_COUNT,
1,
LABEL_STRIP_FOR_REDIRECT
);
await checkTelemetryProbe(true, QUERY_STRIPPING_COUNT, 1, LABEL_REDIRECT);
await checkTelemetryProbe(true, QUERY_STRIPPING_PARAM_COUNT, 1, "1");
await checkTelemetryProbe(QUERY_STRIPPING_COUNT, 1, LABEL_STRIP_FOR_REDIRECT);
await checkTelemetryProbe(QUERY_STRIPPING_COUNT, 1, LABEL_REDIRECT);
await checkTelemetryProbe(QUERY_STRIPPING_PARAM_COUNT, 1, "1");
await clearTelemetry();
});
@ -301,17 +274,14 @@ add_task(async function testQueryStrippingDisabled() {
await verifyQueryString(browser, "paramToStrip=value");
});
// Verify the telemetry probe. There should be no stripped navigation count in
// parent.
// Verify the telemetry probe. There should be no stripped navigation count.
await checkTelemetryProbe(
true,
QUERY_STRIPPING_COUNT,
undefined,
LABEL_STRIP_FOR_NAVIGATION
);
// Check if the navigation count is increased.
let newNavigationCnt = await getTelemetryProbe(
true,
QUERY_STRIPPING_COUNT,
LABEL_NAVIGATION,
cnt => cnt > 0
@ -339,17 +309,15 @@ add_task(async function testQueryStrippingDisabled() {
await verifyQueryString(browser, "paramToStrip=value");
});
// Verify the telemetry probe in content process. There should be no stripped
// navigation count in content.
// Verify the telemetry probe in content process. There should be no stripped
// navigation count.
await checkTelemetryProbe(
false,
QUERY_STRIPPING_COUNT,
undefined,
LABEL_STRIP_FOR_NAVIGATION
);
// Check if the navigation count is increased.
newNavigationCnt = await getTelemetryProbe(
false,
QUERY_STRIPPING_COUNT,
LABEL_NAVIGATION,
cnt => cnt > 0
@ -379,12 +347,11 @@ add_task(async function testQueryStrippingDisabled() {
// Verify the telemetry probe. The stripped redirect count should not exist.
await checkTelemetryProbe(
true,
QUERY_STRIPPING_COUNT,
undefined,
LABEL_STRIP_FOR_REDIRECT
);
await checkTelemetryProbe(true, QUERY_STRIPPING_COUNT, 1, LABEL_REDIRECT);
await checkTelemetryProbe(QUERY_STRIPPING_COUNT, 1, LABEL_REDIRECT);
await clearTelemetry();
});