#include "content/public/browser/back_forward_cache.h"
#include <string>
#include <string_view>
#include "base/strings/utf_string_conversions.h"
#include "build/build_config.h"
#include "chrome/browser/extensions/extension_action_runner.h"
#include "chrome/browser/extensions/extension_browsertest.h"
#include "chrome/browser/extensions/tab_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/back_forward_cache/back_forward_cache_disable.h"
#include "components/ukm/test_ukm_recorder.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/test/back_forward_cache_util.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/prerender_test_util.h"
#include "content/public/test/test_utils.h"
#include "extensions/browser/api/messaging/message_service.h"
#include "extensions/common/extension.h"
#include "extensions/common/manifest_constants.h"
#include "net/dns/mock_host_resolver.h"
#include "services/metrics/public/cpp/ukm_builders.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/navigation/renderer_eviction_reason.mojom-shared.h"
namespace extensions {
ContextType;
struct TestParams { … };
class ExtensionBackForwardCacheBrowserTest
: public ExtensionBrowserTest,
public ::testing::WithParamInterface<TestParams> { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest, ScriptAllowed) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest, CSSAllowed) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
UnloadExtensionFlushCache) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
LoadExtensionFlushCache) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeRuntimeConnectUsage) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeRuntimeConnectUsageInIframeWithIframeNavigation) { … }
IN_PROC_BROWSER_TEST_P(
ExtensionBackForwardCacheBrowserTest,
ChromeRuntimeConnectUsageInIframeWithoutIframeNavigation) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeTabsConnectWithMultipleReceivers) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeRuntimeSendMessageUsage) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeRuntimeConnectDisconnect) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeTabsConnect) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeTabsConnectChannelWorksAfterRestore) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ChromeTabsConnectDisconnect) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ExtensionBackgroundOnDisconnectEvent) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
MessageSentToAllFramesDoesNotSendToBackForwardCache) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
MessageSentToCachedIdFails) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
StorageCallbackEvicts) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest, TabsOrigin) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ContentScriptsRunOnlyOnce) { … }
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheBrowserTest,
ActiveTabPermissionRevoked) { … }
class ExtensionBackForwardCacheMetricsBrowserTest
: public ExtensionBackForwardCacheBrowserTest { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
namespace {
constexpr int ToBackForwardCacheDisabledReasonMetricValue(
content::BackForwardCache::DisabledSource source,
back_forward_cache::DisabledReasonId reason) { … }
}
IN_PROC_BROWSER_TEST_P(
ExtensionBackForwardCacheMetricsBrowserTest,
BFCacheMetricsRecordedIfExtensionSendsMessageToCachedFrame) { … }
class ExtensionBackForwardCacheWithPrerenderBrowserTest
: public ExtensionBackForwardCacheBrowserTest { … };
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
INSTANTIATE_TEST_SUITE_P(…);
IN_PROC_BROWSER_TEST_P(ExtensionBackForwardCacheWithPrerenderBrowserTest,
PortIsStillOpenAfterPrerenderAndActivate) { … }
}