diff --git a/docshell/shistory/SessionHistoryEntry.cpp b/docshell/shistory/SessionHistoryEntry.cpp index c43899387df1..3d9582be0314 100644 --- a/docshell/shistory/SessionHistoryEntry.cpp +++ b/docshell/shistory/SessionHistoryEntry.cpp @@ -595,6 +595,12 @@ SessionHistoryEntry::SetContentViewer(nsIContentViewer* aContentViewer) { return NS_ERROR_FAILURE; } +NS_IMETHODIMP +SessionHistoryEntry::GetIsInBFCache(bool* aResult) { + *aResult = !!SharedInfo()->mFrameLoader; + return NS_OK; +} + NS_IMETHODIMP SessionHistoryEntry::GetSticky(bool* aSticky) { *aSticky = SharedInfo()->mSticky; diff --git a/docshell/shistory/nsISHEntry.idl b/docshell/shistory/nsISHEntry.idl index 73ac40551d4e..ab8f86789138 100644 --- a/docshell/shistory/nsISHEntry.idl +++ b/docshell/shistory/nsISHEntry.idl @@ -110,6 +110,8 @@ interface nsISHEntry : nsISupports /** Content viewer, for fast restoration of presentation */ [infallible] attribute nsIContentViewer contentViewer; + [infallible] readonly attribute boolean isInBFCache; + /** Whether the content viewer is marked "sticky" */ [infallible] attribute boolean sticky; diff --git a/docshell/shistory/nsSHEntry.cpp b/docshell/shistory/nsSHEntry.cpp index 1e4000eacd2b..7cf6372df8ab 100644 --- a/docshell/shistory/nsSHEntry.cpp +++ b/docshell/shistory/nsSHEntry.cpp @@ -996,6 +996,12 @@ nsSHEntry::GetContentViewer(nsIContentViewer** aResult) { return NS_OK; } +NS_IMETHODIMP +nsSHEntry::GetIsInBFCache(bool* aResult) { + *aResult = !!GetState()->mContentViewer; + return NS_OK; +} + NS_IMETHODIMP nsSHEntry::Clone(nsISHEntry** aResult) { nsCOMPtr entry = new nsSHEntry(*this); diff --git a/docshell/shistory/nsSHistory.cpp b/docshell/shistory/nsSHistory.cpp index 82f86e318a21..c57e538e16d3 100644 --- a/docshell/shistory/nsSHistory.cpp +++ b/docshell/shistory/nsSHistory.cpp @@ -972,6 +972,10 @@ static void LogEntry(nsISHEntry* aEntry, int32_t aIndex, int32_t aTotal, MOZ_LOG(gSHLog, LogLevel::Debug, (" %s%s Name = %s\n", prefix.get(), childCount > 0 ? "|" : " ", NS_LossyConvertUTF16toASCII(name).get())); + MOZ_LOG( + gSHLog, LogLevel::Debug, + (" %s%s Is in BFCache = %s\n", prefix.get(), childCount > 0 ? "|" : " ", + aEntry->GetIsInBFCache() ? "true" : "false")); nsCOMPtr prevChild; for (int32_t i = 0; i < childCount; ++i) { diff --git a/docshell/test/chrome/bug396519_window.xhtml b/docshell/test/chrome/bug396519_window.xhtml index 31fb6d296bcd..303f1eb6d907 100644 --- a/docshell/test/chrome/bug396519_window.xhtml +++ b/docshell/test/chrome/bug396519_window.xhtml @@ -69,7 +69,7 @@ for (let i = 0; i < history.count; i++) { var shEntry = history.getEntryAtIndex(i). QueryInterface(Ci.nsISHEntry); - is(!!shEntry.contentViewer, gExpected[i], "content viewer "+i+", test "+gTestCount); + is(shEntry.isInBFCache, gExpected[i], `BFCache for shentry[${i}], test ${gTestCount}`); } // Make sure none of the SHEntries share bfcache entries with one