Bug 1608713 - Add nsIWebNavigation load flags to force TRR mode and use them to load captive portal tabs with TRR disabled. r=valentin,Gijs,baku

Differential Revision: https://phabricator.services.mozilla.com/D60860
This commit is contained in:
Nihanth Subramanya
2020-01-24 17:18:35 +00:00
parent 17893c7f64
commit fd86f8fa69
5 changed files with 20 additions and 0 deletions

View File

@@ -282,6 +282,7 @@ var CaptivePortalWatcher = {
userContextId: gBrowser.contentPrincipal.userContextId, userContextId: gBrowser.contentPrincipal.userContextId,
} }
), ),
disableTRR: true,
}); });
this._captivePortalTab = Cu.getWeakReference(tab); this._captivePortalTab = Cu.getWeakReference(tab);
} }

View File

@@ -2538,6 +2538,7 @@
bulkOrderedOpen, bulkOrderedOpen,
charset, charset,
createLazyBrowser, createLazyBrowser,
disableTRR,
eventDetail, eventDetail,
focusUrlBar, focusUrlBar,
forceNotRemote, forceNotRemote,
@@ -2865,6 +2866,9 @@
if (!allowInheritPrincipal) { if (!allowInheritPrincipal) {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL; flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISALLOW_INHERIT_PRINCIPAL;
} }
if (disableTRR) {
flags |= Ci.nsIWebNavigation.LOAD_FLAGS_DISABLE_TRR;
}
try { try {
b.loadURI(aURI, { b.loadURI(aURI, {
flags, flags,

View File

@@ -713,6 +713,12 @@ nsDocShell::LoadURI(nsDocShellLoadState* aLoadState, bool aSetNavigating) {
return NS_OK; // JS may not handle returning of an error code return NS_OK; // JS may not handle returning of an error code
} }
if (aLoadState->LoadFlags() & LOAD_FLAGS_FORCE_TRR) {
mDefaultLoadFlags |= nsIRequest::LOAD_TRR_ONLY_MODE;
} else if (aLoadState->LoadFlags() & LOAD_FLAGS_DISABLE_TRR) {
mDefaultLoadFlags |= nsIRequest::LOAD_TRR_DISABLED_MODE;
}
if (!StartupTimeline::HasRecord(StartupTimeline::FIRST_LOAD_URI) && if (!StartupTimeline::HasRecord(StartupTimeline::FIRST_LOAD_URI) &&
mItemType == typeContent && !NS_IsAboutBlank(aLoadState->URI())) { mItemType == typeContent && !NS_IsAboutBlank(aLoadState->URI())) {
StartupTimeline::RecordOnce(StartupTimeline::FIRST_LOAD_URI); StartupTimeline::RecordOnce(StartupTimeline::FIRST_LOAD_URI);

View File

@@ -226,6 +226,12 @@ interface nsIWebNavigation : nsISupports
*/ */
const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000; const unsigned long LOAD_FLAGS_IS_REDIRECT = 0x800000;
/**
* These flags force TRR modes 1 or 3 for the load.
*/
const unsigned long LOAD_FLAGS_DISABLE_TRR = 0x1000000;
const unsigned long LOAD_FLAGS_FORCE_TRR = 0x2000000;
/** /**
* Loads a given URI. This will give priority to loading the requested URI * Loads a given URI. This will give priority to loading the requested URI
* in the object implementing this interface. If it can't be loaded here * in the object implementing this interface. If it can't be loaded here

View File

@@ -199,6 +199,9 @@ interface nsIRequest : nsISupports
* Do not get/set manually, rather use the getTRRMode/setTRRMode methods. * Do not get/set manually, rather use the getTRRMode/setTRRMode methods.
*/ */
const unsigned long LOAD_TRR_MASK = (1 << 3) | (1 << 4); const unsigned long LOAD_TRR_MASK = (1 << 3) | (1 << 4);
const unsigned long LOAD_TRR_DISABLED_MODE = 1 << 3;
const unsigned long LOAD_TRR_FIRST_MODE = 1 << 4;
const unsigned long LOAD_TRR_ONLY_MODE = (1 << 3) | (1 << 4);
/************************************************************************** /**************************************************************************
* The following flags control the flow of data into the cache. * The following flags control the flow of data into the cache.