#include "base/command_line.h"
#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "base/metrics/metrics_hashes.h"
#include "base/task/single_thread_task_runner.h"
#include "base/test/bind.h"
#include "base/test/test_mock_time_task_runner.h"
#include "base/types/expected.h"
#include "build/build_config.h"
#include "content/browser/back_forward_cache_browsertest.h"
#include "content/browser/renderer_host/back_forward_cache_disable.h"
#include "content/browser/renderer_host/back_forward_cache_impl.h"
#include "content/browser/renderer_host/navigation_request.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/common/content_navigation_policy.h"
#include "content/common/features.h"
#include "content/public/browser/browser_accessibility_state.h"
#include "content/public/browser/disallow_activation_reason.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/test/accessibility_notification_waiter.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/fenced_frame_test_util.h"
#include "content/public/test/mock_web_contents_observer.h"
#include "content/public/test/scoped_accessibility_mode_override.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "content/shell/browser/shell.h"
#include "content/shell/browser/shell_content_browser_client.h"
#include "content/test/content_browser_test_utils_internal.h"
#include "content/test/did_commit_navigation_interceptor.h"
#include "content/test/echo.test-mojom.h"
#include "media/base/media_switches.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "third_party/blink/public/common/features.h"
#include "ui/accessibility/ax_action_data.h"
#include "ui/accessibility/ax_node_id_forward.h"
#include "ui/accessibility/platform/browser_accessibility.h"
_;
Each;
ElementsAre;
Not;
UnorderedElementsAreArray;
namespace content {
NotRestoredReason;
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BackForwardCacheFlush) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, ForEachRenderFrameHost) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ForEachRenderFrameHostWithSpeculative) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
NavigationsAreFullyCommitted) { … }
#if BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_ProxiesAreStoredAndRestored …
#else
#define MAYBE_ProxiesAreStoredAndRestored …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_ProxiesAreStoredAndRestored) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
RestoredProxiesAreFunctional) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DISABLED_LogIpcPostedToCachedFrame) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DisableBackforwardCacheForTesting) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictionOnJavaScriptExecution) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictionOnJavaScriptExecutionIframe) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictionOnJavaScriptExecutionInAnotherWorld) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, PostMessageDelivered) { … }
class BackForwardCacheBrowserTestDisallowBroadcastChannel
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTestDisallowBroadcastChannel,
PagehideMakesPageIneligibleForBackForwardCacheAndNotCountedInCacheSize) { … }
class BackForwardCacheEntryTimeoutBrowserTest
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheEntryTimeoutBrowserTest, BusyPagehide) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheEntryTimeoutBrowserTest,
EvictPageWithInfiniteLoop) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
ReissuesNavigationIfEvictedDuringNavigation_BeforeResponse) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
ReissuedBackForwardCacheNavigationIsCancelledWhenNewNavigationIsCreated) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
FlushCacheDuringNavigationToCachedPage) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictsFromCacheIfRendererProcessCrashes) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
SchedulerTrackedFeaturesUpdatedWhileStoring) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, SameSiteNavigationCaching) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, TimedEviction) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
DisableBackForwardCachePreventsDocumentsFromBeingCached) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DisableBackForwardIsNoOpIfRfhIsGone) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DisableBackForwardCacheIframe) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DisableBackForwardEvictsIfAlreadyInCache) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, MetricsNotRecorded) { … }
class BackForwardCacheBrowserTestWithDomainControlEnabled
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithDomainControlEnabled,
CachePagesWithMatchedURLs) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithDomainControlEnabled,
DoNotCachePagesWithUnMatchedURLs) { … }
class BackForwardCacheBrowserTestWithBlockedWebsites
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithBlockedWebsites,
NavigateFromAllowedPageToDisallowedPage) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithBlockedWebsites,
NavigateFromDisallowedPageToAllowedPage) { … }
class BackForwardCacheBrowserTestForAllowedWebsitesUrlPatterns
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestForAllowedWebsitesUrlPatterns,
AllowedWebsitesUrlPatterns) { … }
class BackForwardCacheBrowserTestForBlockedWebsitesUrlPatterns
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestForBlockedWebsitesUrlPatterns,
BlockedWebsitesUrlPatterns) { … }
class BackForwardCacheBrowserTestForWebsitesUrlPatterns
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestForWebsitesUrlPatterns,
WebsitesUrlPatterns) { … }
class BackForwardCacheBrowserTestWithBlockedCgiParams
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithBlockedCgiParams,
NavigateFromAllowedPageToDisallowedPage) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithBlockedCgiParams,
NavigateFromDisallowedPageToAllowedPage) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, WebPreferences) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NestedWebContents) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, RestoreWhilePendingCommit) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
IsInactiveAndDisallowActivationIsNoopWhenActive) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
IsInactiveAndDisallowActivationDoesEvictForCachedFrames) { … }
class BackForwardCacheDisabledThroughCommandLineBrowserTest
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheDisabledThroughCommandLineBrowserTest,
BFCacheDisabled) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheDisabledThroughCommandLineBrowserTest,
BFCacheDisabled_NetworkRequests) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
EvictingDocumentsInRelatedSiteInstancesDoesNotRestartNavigation) { … }
namespace {
class ExecJsInDidFinishNavigation : public WebContentsObserver { … };
}
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MessageFromDidFinishNavigation) { … }
#if BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ChildImportanceTestForBackForwardCachedPagesTest) {
web_contents()->SetPrimaryMainFrameImportance(
ChildProcessImportance::MODERATE);
ASSERT_TRUE(embedded_test_server()->Start());
GURL url_a(embedded_test_server()->GetURL("a.com", "/title1.html"));
GURL url_b(embedded_test_server()->GetURL("b.com", "/title1.html"));
EXPECT_TRUE(NavigateToURL(shell(), url_a));
RenderFrameHostImpl* rfh_a = current_frame_host();
RenderFrameDeletedObserver delete_observer_rfh_a(rfh_a);
EXPECT_TRUE(NavigateToURL(shell(), url_b));
ASSERT_FALSE(delete_observer_rfh_a.deleted());
EXPECT_EQ(ChildProcessImportance::NORMAL,
rfh_a->GetProcess()->GetEffectiveImportance());
ASSERT_TRUE(HistoryGoBack(web_contents()));
EXPECT_EQ(ChildProcessImportance::MODERATE,
rfh_a->GetProcess()->GetEffectiveImportance());
}
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, PageshowMetrics) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CheckIsActive) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CheckLifecycleStateTransition) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CheckLifecycleStateTransitionWithSubframes) { … }
namespace {
class EchoFakeWithFilter final : public mojom::Echo { … };
}
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MessageReceivedOnAssociatedInterfaceWhileCached) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
MessageReceivedOnAssociatedInterfaceWhileCachedForProcessWithNonCachedPages) { … }
IN_PROC_BROWSER_TEST_F(
HighCacheSizeBackForwardCacheBrowserTest,
MessageReceivedOnAssociatedInterfaceForProcessWithMultipleCachedPages) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MessageReceivedOnAssociatedInterfaceWhileFreezing) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ShouldNotSwapBrowsingInstanceWhenPageWillNotBeCached) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
RendererInitiatedSameSiteNavigationReusesProcess) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BrowserInitiatedSameSiteNavigationReusesProcess) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CrossSiteNavigationDoesNotReuseProcess) { … }
class RenderViewHostDeletedObserver : public WebContentsObserver { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
RenderViewHostDeletedOnEviction) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CrossProcessSubFrameRenderViewHostDeletedOnEviction) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
SameProcessSubFrameRenderViewHostDeletedOnEviction) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
NavigationCancelledAfterJsEvictionWasDisabled) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
SubframeNavigationDoesNotRecordMetrics) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EnsureIsolationInfoForSubresourcesNotEmpty) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoNotRestoreWhenIsOverridingUserAgentDiffers) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
RestoreWhenUserAgentOverrideDiffers) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
WebContentsDestroyedWhileRestoringThePageFromBFCache) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DelegateDoesNotSupportBackForwardCache) { … }
class BackForwardCacheDisabledBrowserTest : public ContentBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheDisabledBrowserTest,
MetricsOnHistoryNavigation) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheDisabledBrowserTest,
MetricsOnHistoryNavigation_SameSite) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheDisabledBrowserTest,
MetricsOnHistoryNavigation_BlocklistedFeature) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheDisabledBrowserTest,
MetricsOnHistoryNavigation_DisabledForRFH) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, NoThrottlesOnCacheRestore) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BackNavigationFromCrashedPage) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
TwoBackNavigationsToTheSameEntry) { … }
class InjectCreateChildFrame : public DidCommitNavigationInterceptor { … };
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
InjectSubframeDuringPendingCrossBrowsingInstanceNavigation) { … }
class BackForwardCacheBrowserTestWithFlagForScreenReader
: public BackForwardCacheBrowserTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(BackForwardCacheBrowserTestWithFlagForScreenReader,
ScreenReaderOn) { … }
class BackForwardCacheBrowserTestWithFlagForAXEvents
: public BackForwardCacheBrowserTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(BackForwardCacheBrowserTestWithFlagForAXEvents,
EvictOnAccessibilityEventsOrNot) { … }
class BackForwardCacheBrowserTestWithFlagForAXLocationChange
: public BackForwardCacheBrowserTest,
public ::testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(BackForwardCacheBrowserTestWithFlagForAXLocationChange,
EvictOnAXLocationChangeOrNot) { … }
class BackgroundForegroundProcessLimitBackForwardCacheBrowserTest
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(
BackgroundForegroundProcessLimitBackForwardCacheBrowserTest,
CacheEvictionSameSite) { … }
IN_PROC_BROWSER_TEST_F(
BackgroundForegroundProcessLimitBackForwardCacheBrowserTest,
CacheEvictionCrossSite) { … }
IN_PROC_BROWSER_TEST_F(
BackgroundForegroundProcessLimitBackForwardCacheBrowserTest,
ChangeToForeground) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, TestTimeToLiveParameter) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ErrorDocumentNotCachedWithSecondError) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ErrorDocumentNotCachedWithoutSecondError) { … }
class BackForwardCacheBrowserTestWithFencedFrames
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithFencedFrames,
CachesFencedFramesSimple) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithFencedFrames,
InnerFrameStorageSupport) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithFencedFrames,
OuterDocumentTimeEviction) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithFencedFrames,
TreeResults) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithFencedFrames,
EvictionOnInnerFrameTree) { … }
}