diff --git a/docshell/base/CanonicalBrowsingContext.cpp b/docshell/base/CanonicalBrowsingContext.cpp index eb99262d3e8c..a9ff63156be0 100644 --- a/docshell/base/CanonicalBrowsingContext.cpp +++ b/docshell/base/CanonicalBrowsingContext.cpp @@ -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( diff --git a/docshell/test/navigation/mochitest.toml b/docshell/test/navigation/mochitest.toml index 2942b3ec9c3c..f2c0f816dd62 100644 --- a/docshell/test/navigation/mochitest.toml +++ b/docshell/test/navigation/mochitest.toml @@ -105,10 +105,6 @@ support-files = [ "iframe_slow_onload.html", "iframe_slow_onload_inner.html", ] -skip-if = [ - "http3", - "http2", -] ["test_bug13871.html"] skip-if = [ diff --git a/docshell/test/navigation/test_blockBFCache.html b/docshell/test/navigation/test_blockBFCache.html index c8f3ccc2e42a..c0de48f26e21 100644 --- a/docshell/test/navigation/test_blockBFCache.html +++ b/docshell/test/navigation/test_blockBFCache.html @@ -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: () => { diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 493e926df5ad..9386ff062858 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -8217,6 +8217,13 @@ void Document::SetScriptGlobalObject( nsCOMPtr 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) { diff --git a/dom/base/Document.h b/dom/base/Document.h index 0172e5df4a61..11d440082409 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -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 diff --git a/dom/ipc/WindowGlobalParent.cpp b/dom/ipc/WindowGlobalParent.cpp index 63055ad953d2..0ac660ba6536 100644 --- a/dom/ipc/WindowGlobalParent.cpp +++ b/dom/ipc/WindowGlobalParent.cpp @@ -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