#include "content/browser/back_forward_cache_browsertest.h"
#include "base/containers/contains.h"
#include "base/threading/platform_thread.h"
#include "base/time/time.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "content/browser/generic_sensor/web_contents_sensor_provider_proxy.h"
#include "content/browser/presentation/presentation_test_utils.h"
#include "content/browser/renderer_host/back_forward_cache_disable.h"
#include "content/browser/renderer_host/media/media_devices_dispatcher_host.h"
#include "content/browser/renderer_host/render_frame_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/browser/worker_host/dedicated_worker_hosts_for_document.h"
#include "content/public/browser/disallow_activation_reason.h"
#include "content/public/browser/media_session.h"
#include "content/public/browser/payment_app_provider.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.h"
#include "content/public/test/content_browser_test_utils.h"
#include "content/public/test/media_start_stop_observer.h"
#include "content/public/test/test_navigation_observer.h"
#include "content/public/test/test_utils.h"
#include "content/public/test/web_transport_simple_test_server.h"
#include "content/shell/browser/shell.h"
#include "device/bluetooth/bluetooth_adapter_factory.h"
#include "device/bluetooth/test/mock_bluetooth_adapter.h"
#include "net/test/embedded_test_server/controllable_http_response.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "net/test/spawned_test_server/spawned_test_server.h"
#include "net/test/test_data_directory.h"
#include "services/device/public/cpp/test/fake_sensor_and_provider.h"
#include "services/device/public/cpp/test/scoped_geolocation_overrider.h"
#include "services/device/public/mojom/vibration_manager.mojom.h"
#include "services/service_manager/public/cpp/interface_provider.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/scheduler/web_scheduler_tracked_feature.h"
#include "third_party/blink/public/mojom/app_banner/app_banner.mojom.h"
#include "ui/base/idle/idle_time_provider.h"
#include "ui/base/test/idle_test_utils.h"
_;
Each;
ElementsAre;
Not;
UnorderedElementsAreArray;
namespace content {
NotRestoredReason;
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
PageWithDedicatedWorkerCachedOrNot) { … }
class BackForwardCacheWithDedicatedWorkerBrowserTest
: public BackForwardCacheBrowserTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
CacheWithDedicatedWorker) { … }
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
PageWithDedicatedWorkerAndImportScriptsWontTriggerReload) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
DoNotCacheWithDedicatedWorkerWithWebTransport) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
CacheWithDedicatedWorkerWithWebTransportClosed) { … }
#if BUILDFLAG(IS_LINUX)
#define MAYBE_DoNotCacheWithDedicatedWorkerWithWebTransportAndDocumentWithBlockingFeature …
#else
#define MAYBE_DoNotCacheWithDedicatedWorkerWithWebTransportAndDocumentWithBlockingFeature …
#endif
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
MAYBE_DoNotCacheWithDedicatedWorkerWithWebTransportAndDocumentWithBlockingFeature) { … }
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
DISABLED_DoNotCacheWithDedicatedWorkerWithClosedWebTransportAndDocumentWithBroadcastChannel) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
FetchRedirectedWhileStoring) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
FetchRedirectedWhileStoring_Nested) { … }
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
FetchStillLoading_ResponseStartedWhileFrozen_ExceedsPerProcessBytesLimit) { … }
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
FetchStillLoading_ResponseStartedWhileFrozen_ExceedsPerProcessBytesLimit_Nested) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
PageWithDrainedDatapipeRequestsForFetchShouldBeEvicted) { … }
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
PageWithDrainedDatapipeRequestsForFetchShouldBeEvicted_Nested) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
ImageStillLoading_ResponseStartedWhileFrozen_Timeout) { … }
IN_PROC_BROWSER_TEST_P(
BackForwardCacheWithDedicatedWorkerBrowserTest,
ImageStillLoading_ResponseStartedWhileFrozen_Timeout_Nested) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
ServiceWorkerClientMatchAll) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
ServiceWorkerClientMatchAll_Nested) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithDedicatedWorkerBrowserTest,
ServiceWorkerClientMatchAll_LoadWorkerAfterRestoring) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_PageWithSharedWorkerNotCached …
#else
#define MAYBE_PageWithSharedWorkerNotCached …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_PageWithSharedWorkerNotCached) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
AllowedFeaturesForSubframesDoNotEvict) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheIfRecordingAudio) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheIfSubframeRecordingAudio) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheIfMediaDeviceSubscribedButDoesCache) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
RestoreIfDevicesEnumerated) { … }
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheIfDisplayMediaAccessGranted) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfMediaStreamTrackUsingGetDisplayMediaEnded) { … }
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CacheIfWebGL) { … }
#if !BUILDFLAG(IS_ANDROID)
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIfWebHID) { … }
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
WakeLockReleasedUponEnteringBfcache) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, CacheWithWebFileSystem) { … }
namespace {
class FakeIdleTimeProvider : public ui::IdleTimeProvider { … };
}
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheIdleManager) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DoesNotCacheSMSService) { … }
namespace {
void OnInstallPaymentApp(base::OnceClosure done_callback,
bool* out_success,
bool success) { … }
}
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCachePaymentManager) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheOnKeyboardLock) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfKeyboardLockReleasedMultipleRestores) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoNotCacheIfKeyboardLockIsHeldAfterRelease) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfKeyboardLockReleased) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfKeyboardLockReleasedInPagehide) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheWithDummyStickyFeature) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_BrowserInitiated) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_RendererInitiated) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_SameSite) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_BrowserInitiated_NonSticky) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_CrossSite_RendererInitiated_NonSticky) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
BlocklistedFeaturesTracking_SameSite_NonSticky) { … }
class BackForwardCacheBrowserTestWithJavaScriptDetails
: public BackForwardCacheBrowserTest { … };
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_MultipleBlocksFromJavaScriptFile …
#else
#define MAYBE_MultipleBlocksFromJavaScriptFile …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithJavaScriptDetails,
MAYBE_MultipleBlocksFromJavaScriptFile) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_BlockAndUnblockFromJavaScriptFile …
#else
#define MAYBE_BlockAndUnblockFromJavaScriptFile …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithJavaScriptDetails,
MAYBE_BlockAndUnblockFromJavaScriptFile) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_MultipleBlocksFromHTMLFile …
#else
#define MAYBE_MultipleBlocksFromHTMLFile …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithJavaScriptDetails,
MAYBE_MultipleBlocksFromHTMLFile) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_BlockAndUnblockFromHTMLFile …
#else
#define MAYBE_BlockAndUnblockFromHTMLFile …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithJavaScriptDetails,
MAYBE_BlockAndUnblockFromHTMLFile) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_StickyFeaturesWithDetails …
#else
#define MAYBE_StickyFeaturesWithDetails …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithJavaScriptDetails,
MAYBE_StickyFeaturesWithDetails) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DISABLED_DoesNotCacheIfWebDatabase) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfOpenIndexedDBConnection) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictCacheIfOnVersionChangeEventReceived) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
DoesNotCacheIfVersionChangeEventIsSentButIndexedDBConnectionIsNotClosed) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
CacheIfVersionChangeEventIsSentAndIndexedDBConnectionIsClosed) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfIndexedDBConnectionClosedInPagehide) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfIndexedDBTransactionNotCommitted) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfIndexedDBConnectionTransactionCommit) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
IndexedDBClientDoesntBlockSelf) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
IndexedDBClientWithDedicatedWorkerDoesntBlockSelf) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
IndexedDBDoNotCacheIfInactiveAndBlockingActive) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTest,
DoNotCacheIfIndexedDBTransactionHoldingLocksAndBlockingOthers) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictCacheIfPageBlocksNewIndexedDBTransaction) { … }
class BackForwardCacheWithBroadcastChannelTest
: public BackForwardCacheBrowserTest,
public testing::WithParamInterface<bool> { … };
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithBroadcastChannelTest,
MaybeCacheIfBroadcastChannelStillOpen) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CacheIfBroadcastChannelIsClosedInPagehide) { … }
IN_PROC_BROWSER_TEST_P(BackForwardCacheWithBroadcastChannelTest,
MaybeEvictOnMessage) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_WebSocketCachedIfClosed …
#else
#define MAYBE_WebSocketCachedIfClosed …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_WebSocketCachedIfClosed) { … }
class WebTransportBackForwardCacheBrowserTest
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(WebTransportBackForwardCacheBrowserTest,
ActiveWebTransportEvictsPage) { … }
IN_PROC_BROWSER_TEST_F(WebTransportBackForwardCacheBrowserTest,
WebTransportCachedIfClosed) { … }
#if BUILDFLAG(IS_ANDROID)
#define MAYBE_WebSocketNotCached …
#else
#define MAYBE_WebSocketNotCached …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, MAYBE_WebSocketNotCached) { … }
namespace {
void RegisterServiceWorker(RenderFrameHostImpl* rfh) { … }
std::unique_ptr<net::test_server::HttpResponse> RequestHandlerForUpdateWorker(
const net::test_server::HttpRequest& request) { … }
}
class TestVibrationManager : public device::mojom::VibrationManager { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
VibrationStopsAfterEnteringCache) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
ShortVibrationSequenceStopsAfterEnteringCache) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CachedPagesWithServiceWorkers) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictIfCacheBlocksServiceWorkerVersionActivation) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictWithPostMessageToCachedClient) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, EvictOnServiceWorkerClaim) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
EvictOnServiceWorkerUnregistration) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, BeaconAndBfCache) { … }
class GeolocationBackForwardCacheBrowserTest
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(GeolocationBackForwardCacheBrowserTest,
CacheAfterGeolocationRequest) { … }
IN_PROC_BROWSER_TEST_F(GeolocationBackForwardCacheBrowserTest,
CancelGeolocationRequestInFlight) { … }
class BluetoothForwardCacheBrowserTest : public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BluetoothForwardCacheBrowserTest, WebBluetooth) { … }
enum class SerialContext { … };
enum class SerialType { … };
class BackForwardCacheBrowserWebUsbTest
: public BackForwardCacheBrowserTest,
public ::testing::WithParamInterface<
std::tuple<SerialContext, SerialType>> { … };
IN_PROC_BROWSER_TEST_P(BackForwardCacheBrowserWebUsbTest, Serials) { … }
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, AudioSuspendAndResume) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, VideoSuspendAndResume) { … }
class SensorBackForwardCacheBrowserTest : public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(SensorBackForwardCacheBrowserTest,
AccelerometerNotCached) { … }
IN_PROC_BROWSER_TEST_F(SensorBackForwardCacheBrowserTest, OrientationCached) { … }
#if BUILDFLAG(IS_MAC)
#define MAYBE_SensorPausedWhileCached …
#else
#define MAYBE_SensorPausedWhileCached …
#endif
IN_PROC_BROWSER_TEST_F(SensorBackForwardCacheBrowserTest,
MAYBE_SensorPausedWhileCached) { … }
#if !BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_MAC)
#define MAYBE_TrivialRTCPeerConnectionCached …
#else
#define MAYBE_TrivialRTCPeerConnectionCached …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_TrivialRTCPeerConnectionCached) { … }
#endif
#if !BUILDFLAG(IS_ANDROID)
#if BUILDFLAG(IS_MAC)
#define MAYBE_NonTrivialRTCPeerConnectionNotCached …
#else
#define MAYBE_NonTrivialRTCPeerConnectionNotCached …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_NonTrivialRTCPeerConnectionNotCached) { … }
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, WebLocksNotCached) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest, DISABLED_WebMidiNotCached) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DISABLED_PresentationConnectionClosed) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheIfSpeechRecognitionIsStarted) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
CanCacheIfSpeechRecognitionIsNotStarted) { … }
#if BUILDFLAG(IS_CHROMEOS)
#define MAYBE_CacheIfUsingSpeechSynthesis …
#else
#define MAYBE_CacheIfUsingSpeechSynthesis …
#endif
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
MAYBE_CacheIfUsingSpeechSynthesis) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTest,
DoesNotCacheIfRunFileChooserIsInvoked) { … }
class BackForwardCacheBrowserTestNoTestingConfig
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestNoTestingConfig,
CacheWithMediaSession) { … }
class BackForwardCacheBrowserTestWithSupportedFeatures
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithSupportedFeatures,
CacheWithSpecifiedFeatures) { … }
class BackForwardCacheBrowserTestWithNoSupportedFeatures
: public BackForwardCacheBrowserTest { … };
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithNoSupportedFeatures,
DontCache) { … }
class BackForwardCacheBrowserTestWithMediaSession
: public BackForwardCacheBrowserTest { … };
class BackForwardCacheBrowserTestWithMediaSessionNoTestingConfig
: public BackForwardCacheBrowserTestWithMediaSession { … };
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTestWithMediaSessionNoTestingConfig,
CacheWhenMediaSessionPlaybackStateIsChanged) { … }
IN_PROC_BROWSER_TEST_F(BackForwardCacheBrowserTestWithMediaSession,
CacheWhenMediaSessionServiceIsNotUsed) { … }
IN_PROC_BROWSER_TEST_F(
BackForwardCacheBrowserTestWithMediaSessionNoTestingConfig,
DontCacheWhenMediaSessionServiceIsUsed) { … }
}