Bug 1696266, limit the load types which may cause the page to enter bfcache, r=peterv

The change to dom/base/nsFrameLoaderOwner.cpp is to log about the issues but still ensure we don't crash.

I'd prefer to not put error loads to bfcache.

Differential Revision: https://phabricator.services.mozilla.com/D107300
This commit is contained in:
Olli Pettay 2021-03-09 13:42:43 +00:00
Родитель 9ff110ad01
Коммит a46567f045
3 изменённых файлов: 16 добавлений и 2 удалений

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

@ -6951,7 +6951,6 @@ bool nsDocShell::CanSavePresentation(uint32_t aLoadType,
// Only save presentation for "normal" loads and link loads. Anything else
// probably wants to refetch the page, so caching the old presentation
// would be incorrect.
// XXXBFCache in parent needs something like this!
if (aLoadType != LOAD_NORMAL && aLoadType != LOAD_HISTORY &&
aLoadType != LOAD_LINK && aLoadType != LOAD_STOP_CONTENT &&
aLoadType != LOAD_STOP_CONTENT_AND_REPLACE &&

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

@ -142,6 +142,18 @@ void nsFrameLoaderOwner::ChangeRemotenessCommon(
("nsFrameLoaderOwner::ChangeRemotenessCommon: store the old "
"page in bfcache"));
Unused << bc->SetIsInBFCache(true);
if (she->GetFrameLoader()) {
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug,
("nsFrameLoaderOwner::ChangeRemotenessCommon: active "
"session history entry "
"has already an nsFrameLoader!, FIXME"));
MOZ_DIAGNOSTIC_ASSERT(false,
"The current session history entry has "
"already an nsFrameLoader!");
RefPtr<nsFrameLoader> oldFrameLoader = she->GetFrameLoader();
she->SetFrameLoader(nullptr);
oldFrameLoader->Destroy();
}
she->SetFrameLoader(mFrameLoader);
// Session history owns now the frameloader.
mFrameLoader = nullptr;

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

@ -1631,7 +1631,10 @@ bool DocumentLoadListener::MaybeTriggerProcessSwitch(
browsingContext->Group()->Toplevels().Length() == 1 &&
!options.mRemoteType.IsEmpty() &&
browsingContext->GetHasLoadedNonInitialDocument() &&
mLoadStateLoadType != LOAD_ERROR_PAGE) {
(mLoadStateLoadType == LOAD_NORMAL ||
mLoadStateLoadType == LOAD_HISTORY || mLoadStateLoadType == LOAD_LINK ||
mLoadStateLoadType == LOAD_STOP_CONTENT ||
mLoadStateLoadType == LOAD_STOP_CONTENT_AND_REPLACE)) {
options.mReplaceBrowsingContext = true;
options.mTryUseBFCache = true;
}