Bug 1960602 - More explicitly block bfcache when a subframe is loading. r=smaug

The test now passes with http2/http3 (where it didn't use to because the
frame was not OOP in that case).

Differential Revision: https://phabricator.services.mozilla.com/D245741
This commit is contained in:
Emilio Cobos Álvarez
2025-04-17 11:37:08 +00:00
parent b8004617a2
commit 4d8cd3814a
6 changed files with 17 additions and 5 deletions

View File

@@ -2987,6 +2987,9 @@ static void LogBFCacheBlockingForDoc(BrowsingContext* aBrowsingContext,
if (aBFCacheCombo & BFCacheStatus::ACTIVE_LOCK) {
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug, (" * has active Web Locks"));
}
if (aBFCacheCombo & BFCacheStatus::PAGE_LOADING) {
MOZ_LOG(gSHIPBFCacheLog, LogLevel::Debug, (" * has page loading"));
}
}
bool CanonicalBrowsingContext::AllowedInBFCache(

View File

@@ -105,10 +105,6 @@ support-files = [
"iframe_slow_onload.html",
"iframe_slow_onload_inner.html",
]
skip-if = [
"http3",
"http2",
]
["test_bug13871.html"]
skip-if = [

View File

@@ -98,7 +98,7 @@ const blockBFCacheTests = [
},
];
if (SpecialPowers.effectiveIsolationStrategy() == SpecialPowers.ISOLATION_STRATEGY.IsolateEverything) {
if (SpecialPowers.Services.appinfo.sessionHistoryInParent) {
blockBFCacheTests.push({
name: "Loading OOP iframe",
test: () => {

View File

@@ -8217,6 +8217,13 @@ void Document::SetScriptGlobalObject(
nsCOMPtr<nsPIDOMWindowInner> window = do_QueryInterface(mScriptGlobalObject);
mWindow = window;
if (mReadyState != READYSTATE_COMPLETE) {
if (auto* wgc = GetWindowGlobalChild()) {
// This gets unset on OnPageShow.
wgc->BlockBFCacheFor(BFCacheStatus::PAGE_LOADING);
}
}
// Now that we know what our window is, we can flush the CSP errors to the
// Web Console. We are flushing all messages that occurred and were stored in
// the queue prior to this point.
@@ -12353,6 +12360,10 @@ void Document::OnPageShow(bool aPersisted, EventTarget* aDispatchStartTarget,
DispatchPageTransition(target, u"pageshow"_ns, inFrameLoaderSwap,
aPersisted, aOnlySystemGroup);
}
if (auto* wgc = GetWindowGlobalChild()) {
wgc->UnblockBFCacheFor(BFCacheStatus::PAGE_LOADING);
}
}
static void DispatchFullscreenChange(Document& aDocument, nsINode* aTarget) {

View File

@@ -325,6 +325,7 @@ enum BFCacheStatus {
BEFOREUNLOAD_LISTENER = 1 << 15, // Status 15
ACTIVE_LOCK = 1 << 16, // Status 16
ACTIVE_WEBTRANSPORT = 1 << 17, // Status 17
PAGE_LOADING = 1 << 18, // Status 18
};
} // namespace dom

View File

@@ -1279,6 +1279,7 @@ nsCString BFCacheStatusToString(uint32_t aFlags) {
ADD_BFCACHESTATUS_TO_STRING(NOT_ONLY_TOPLEVEL_IN_BCG);
ADD_BFCACHESTATUS_TO_STRING(BEFOREUNLOAD_LISTENER);
ADD_BFCACHESTATUS_TO_STRING(ACTIVE_LOCK);
ADD_BFCACHESTATUS_TO_STRING(PAGE_LOADING);
#undef ADD_BFCACHESTATUS_TO_STRING