#include "base/command_line.h"
#include "base/feature_list.h"
#include "base/functional/callback_forward.h"
#include "base/functional/callback_helpers.h"
#include "base/memory/raw_ptr.h"
#include "base/test/bind.h"
#include "base/test/metrics/histogram_tester.h"
#include "build/build_config.h"
#include "build/chromeos_buildflags.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_context.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_manager.h"
#include "chrome/browser/ui/exclusive_access/exclusive_access_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/browser/ui/web_applications/test/isolated_web_app_test_utils.h"
#include "chrome/browser/web_applications/isolated_web_apps/isolated_web_app_url_info.h"
#include "chrome/browser/web_applications/test/os_integration_test_override_impl.h"
#include "chrome/common/chrome_features.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/blocked_content/popup_blocker_tab_helper.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "components/metrics/content/subprocess_metrics_provider.h"
#include "components/permissions/permission_request_manager.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/content_features.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/url_constants.h"
#include "content/public/test/browser_test.h"
#include "content/public/test/browser_test_utils.h"
#include "net/dns/mock_host_resolver.h"
#include "net/test/embedded_test_server/embedded_test_server.h"
#include "third_party/blink/public/common/features.h"
#include "third_party/blink/public/common/frame/user_activation_state.h"
#include "third_party/blink/public/common/switches.h"
#include "third_party/blink/public/mojom/frame/fullscreen.mojom.h"
#include "third_party/blink/public/mojom/use_counter/metrics/web_feature.mojom.h"
#include "ui/display/screen_base.h"
#include "ui/display/test/test_screen.h"
#include "ui/display/test/virtual_display_util.h"
#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/shell.h"
#include "ui/display/manager/display_manager.h"
#include "ui/display/test/display_manager_test_api.h"
#endif
#if BUILDFLAG(IS_LINUX) && BUILDFLAG(IS_OZONE)
#include "ui/ozone/public/ozone_platform.h"
#endif
#if BUILDFLAG(IS_MAC)
#include "ui/base/cocoa/nswindow_test_util.h"
#endif
#if defined(USE_AURA)
#include "ui/aura/window.h"
#endif
WebContents;
namespace {
const base::FilePath::CharType* kSimpleFile = …);
}
class FullscreenControllerInteractiveTest : public ExclusiveAccessTest { … };
void FullscreenControllerInteractiveTest::ToggleTabFullscreen(
bool enter_fullscreen) { … }
void FullscreenControllerInteractiveTest::ToggleTabFullscreenNoRetries(
bool enter_fullscreen) { … }
void FullscreenControllerInteractiveTest::ToggleBrowserFullscreen(
bool enter_fullscreen) { … }
void FullscreenControllerInteractiveTest::ToggleTabFullscreen_Internal(
bool enter_fullscreen, bool retry_until_success) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
TestNewTabExitsFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
TestTabExitsItselfFromFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
RunOrDeferClosureDuringTransition) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
BrowserFullscreenExit) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
BrowserFullscreenAfterTabFSExit) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, FullscreenFileURL) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
TestTabExitsFullscreenOnNavigation) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsFullscreenOnGoBack) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
TestTabDoesntExitFullscreenOnSubFrameNavigation) { … }
IN_PROC_BROWSER_TEST_F(
FullscreenControllerInteractiveTest,
DISABLED_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks) { … }
#if (BUILDFLAG(IS_LINUX) && BUILDFLAG(IS_OZONE)) || \
BUILDFLAG(IS_CHROMEOS_LACROS) || BUILDFLAG(IS_MAC)
#define MAYBE_TabEntersPresentationModeFromWindowed …
#else
#define MAYBE_TabEntersPresentationModeFromWindowed …
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TabEntersPresentationModeFromWindowed) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
EscapingPointerLock) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
EscapingPointerLockAndFullscreen) { … }
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_CHROMEOS)
#define MAYBE_PointerLockThenFullscreen …
#else
#define MAYBE_PointerLockThenFullscreen …
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_PointerLockThenFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_PointerLockAndFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
PointerLockSilentAfterTargetUnlock) { … }
#if BUILDFLAG(IS_CHROMEOS_LACROS)
#define MAYBE_SecondPointerLockShowsBubble …
#else
#define MAYBE_SecondPointerLockShowsBubble …
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_SecondPointerLockShowsBubble) { … }
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && defined(USE_AURA)
#define MAYBE_TestTabExitsPointerLockOnNavigation …
#else
#define MAYBE_TestTabExitsPointerLockOnNavigation …
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabExitsPointerLockOnNavigation) { … }
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && defined(USE_AURA)
#define MAYBE_TestTabExitsPointerLockOnGoBack …
#else
#define MAYBE_TestTabExitsPointerLockOnGoBack …
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabExitsPointerLockOnGoBack) { … }
#if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
defined(USE_AURA) || \
BUILDFLAG(IS_WIN) && defined(NDEBUG)
#define MAYBE_TestTabDoesntExitPointerLockOnSubFrameNavigation …
#else
#define MAYBE_TestTabDoesntExitPointerLockOnSubFrameNavigation …
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabDoesntExitPointerLockOnSubFrameNavigation) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
ReloadExitsPointerLockAndFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
ToggleFullscreenModeForTab) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
OpeningPopupExitsFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
BlockingContentsExitsFullscreen) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
CapturedContentEntersFullscreenWithinTab) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
OpeningPopupDoesNotExitFullscreenWithinTab) { … }
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
BlockingContentsDoesNotExitFullscreenWithinTab) { … }
class AutomaticFullscreenTest : public FullscreenControllerInteractiveTest,
public testing::WithParamInterface<bool> { … };
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, RequestFullscreenNoGesture) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, ImmediatelyAfterExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, WithGestureAfterExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, EventuallyAfterExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, Popup) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, PopupImmediatelyAfterExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, PopupEventuallyAfterExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, ImmediatelyAfterPopupExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, EventuallyAfterPopupExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, BlockingContentsDoesNotExit) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, QueryPermissionWithGesture) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, QueryPermissionWithoutGesture) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, CrossOriginIFrameDenied) { … }
IN_PROC_BROWSER_TEST_P(AutomaticFullscreenTest, CrossOriginIFrameGranted) { … }
INSTANTIATE_TEST_SUITE_P(…);
class TestScreenEnvironment { … };
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC) || BUILDFLAG(IS_WIN)
#define MAYBE_MultiScreenFullscreenControllerInteractiveTest …
#else
#define MAYBE_MultiScreenFullscreenControllerInteractiveTest …
#endif
class MAYBE_MultiScreenFullscreenControllerInteractiveTest
: public FullscreenControllerInteractiveTest { … };
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SeparateDisplay …
#else
#define MAYBE_SeparateDisplay …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_SeparateDisplay) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SeparateDisplayMaximized …
#else
#define MAYBE_SeparateDisplayMaximized …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_SeparateDisplayMaximized) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SameDisplayAndSwap …
#else
#define MAYBE_SameDisplayAndSwap …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_SameDisplayAndSwap) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SameDisplayAndSwapMaximized …
#else
#define MAYBE_SameDisplayAndSwapMaximized …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_SameDisplayAndSwapMaximized) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_BrowserFullscreenContentFullscreenSwapDisplay …
#else
#define MAYBE_BrowserFullscreenContentFullscreenSwapDisplay …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_BrowserFullscreenContentFullscreenSwapDisplay) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SeparateDisplayAndSwap …
#else
#define MAYBE_SeparateDisplayAndSwap …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_SeparateDisplayAndSwap) { … }
#if BUILDFLAG(IS_CHROMEOS_ASH) || BUILDFLAG(IS_MAC)
#define MAYBE_SwapShowsBubble …
#else
#define MAYBE_SwapShowsBubble …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_SwapShowsBubble) { … }
#if BUILDFLAG(IS_WIN)
#define MAYBE_FullscreenOnPermissionGrant …
#else
#define MAYBE_FullscreenOnPermissionGrant …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_FullscreenOnPermissionGrant) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_OpenPopupWhileFullscreen …
#else
#define MAYBE_OpenPopupWhileFullscreen …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_OpenPopupWhileFullscreen) { … }
#if !BUILDFLAG(IS_CHROMEOS_ASH)
#define MAYBE_FullscreenCompanionWindow …
#else
#define MAYBE_FullscreenCompanionWindow …
#endif
IN_PROC_BROWSER_TEST_F(MAYBE_MultiScreenFullscreenControllerInteractiveTest,
MAYBE_FullscreenCompanionWindow) { … }