Bug 1888494 - Make CanonicalBrowsingContext::FixupAndLoadURIString check set the correct TRR mode r=nika

It would seem sometimes in Firefox 77 we regressed the ability to set the TRR
mode for a browsing context when opening a new tab.
I confirmed that this bug didn't happen in Fx 77 when setting the
`browser.tabs.documentchannel.parent-initiated` pref to `false`.

The nsIWebNavigation::LOAD_FLAGS_DISABLE_TRR is correctly passed into
CanonicalBrowsingContext, but it doesn't end up getting used.

This sets the appropriate DefaultLoadFlags for BrowsingContext
when the LOAD_FLAGS_DISABLE_TRR or LOAD_TRR_ONLY_MODE flags are present
in nsDocShellLoadState::LoadFlags()

Differential Revision: https://phabricator.services.mozilla.com/D220550
This commit is contained in:
Valentin Gosu 2024-09-03 13:07:59 +00:00
parent c0daebf34e
commit 458409e041
2 changed files with 15 additions and 1 deletions

View File

@ -1980,6 +1980,17 @@ nsresult BrowsingContext::LoadURI(nsDocShellLoadState* aLoadState,
"Targeting occurs in InternalLoad");
aLoadState->AssertProcessCouldTriggerLoadIfSystem();
// When this tab sets these load flags, we disable or force TRR for the
// browsing context ensuring subsequent navigations will keep the same
// TRR mode.
if (aLoadState->HasLoadFlags(nsIWebNavigation::LOAD_FLAGS_DISABLE_TRR)) {
Unused << SetDefaultLoadFlags(GetDefaultLoadFlags() |
nsIRequest::LOAD_TRR_DISABLED_MODE);
} else if (aLoadState->HasLoadFlags(nsIWebNavigation::LOAD_FLAGS_FORCE_TRR)) {
Unused << SetDefaultLoadFlags(GetDefaultLoadFlags() |
nsIRequest::LOAD_TRR_ONLY_MODE);
}
if (mDocShell) {
nsCOMPtr<nsIDocShell> docShell = mDocShell;
return docShell->LoadURI(aLoadState, aSetNavigating);

View File

@ -253,7 +253,10 @@ interface nsIWebNavigation : nsISupports
const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;
/**
* These flags force TRR modes 1 or 3 for the load.
* These flags force TRR_DISABLED_MODE or TRR_ONLY_MODE on the
* browsingContext's defaultLoadFlags.
* The basic use case for this is the captive portal login tab
* that needs skip TRR even when the browser defaults to TRR-only mode.
*/
const unsigned long LOAD_FLAGS_DISABLE_TRR = 0x1000000;
const unsigned long LOAD_FLAGS_FORCE_TRR = 0x2000000;