This source file includes following definitions.
- IsMouseLocked
- ToggleTabFullscreen
- ToggleTabFullscreenNoRetries
- ToggleBrowserFullscreen
- TestFullscreenMouseLockContentSettings
- ToggleTabFullscreen_Internal
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
- IN_PROC_BROWSER_TEST_F
#include "build/build_config.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/fullscreen.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_window.h"
#include "chrome/browser/ui/fullscreen/fullscreen_controller_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
#if defined(OS_MACOSX)
#include "base/mac/mac_util.h"
#endif
using content::kAboutBlankURL;
using content::WebContents;
using content::PAGE_TRANSITION_TYPED;
namespace {
const base::FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
}
class FullscreenControllerInteractiveTest
: public FullscreenControllerTest {
protected:
void ToggleTabFullscreen(bool enter_fullscreen);
void ToggleTabFullscreenNoRetries(bool enter_fullscreen);
void ToggleBrowserFullscreen(bool enter_fullscreen);
bool IsMouseLocked() {
EXPECT_TRUE(browser()->IsMouseLocked() ==
browser()->tab_strip_model()->GetActiveWebContents()->
GetRenderViewHost()->GetView()->IsMouseLocked());
return browser()->IsMouseLocked();
}
void TestFullscreenMouseLockContentSettings();
private:
void ToggleTabFullscreen_Internal(bool enter_fullscreen,
bool retry_until_success);
};
void FullscreenControllerInteractiveTest::ToggleTabFullscreen(
bool enter_fullscreen) {
ToggleTabFullscreen_Internal(enter_fullscreen, true);
}
void FullscreenControllerInteractiveTest::ToggleTabFullscreenNoRetries(
bool enter_fullscreen) {
ToggleTabFullscreen_Internal(enter_fullscreen, false);
}
void FullscreenControllerInteractiveTest::ToggleBrowserFullscreen(
bool enter_fullscreen) {
ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen);
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen);
}
void
FullscreenControllerInteractiveTest::TestFullscreenMouseLockContentSettings() {
GURL url = test_server()->GetURL("simple.html");
AddTabAtIndex(0, url, PAGE_TRANSITION_TYPED);
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
HostContentSettingsMap* settings_map =
browser()->profile()->GetHostContentSettingsMap();
ContentSettingsPattern pattern =
ContentSettingsPattern::FromURL(url);
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(),
CONTENT_SETTING_ALLOW);
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_TRUE(IsMouseLockPermissionRequested());
LostMouseLock();
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
CONTENT_SETTING_ALLOW);
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_FALSE(IsMouseLockPermissionRequested());
LostMouseLock();
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
CONTENT_SETTING_BLOCK);
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
void FullscreenControllerInteractiveTest::ToggleTabFullscreen_Internal(
bool enter_fullscreen, bool retry_until_success) {
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
do {
FullscreenNotificationObserver fullscreen_observer;
browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
fullscreen_observer.Wait();
} while (retry_until_success &&
!IsFullscreenForBrowser() &&
browser()->window()->IsFullscreen() != enter_fullscreen);
ASSERT_EQ(IsWindowFullscreenForTabOrPending(), enter_fullscreen);
if (!IsFullscreenForBrowser())
ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestNewTabExitsFullscreen) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
{
FullscreenNotificationObserver fullscreen_observer;
AddTabAtIndex(1, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
fullscreen_observer.Wait();
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsItselfFromFullscreen) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestFullscreenBubbleMouseLockState) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
AddTabAtIndex(1, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
RequestToLockMouse(true, false);
ASSERT_TRUE(IsMouseLockPermissionRequested());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_FullscreenMouseLockContentSettings) {
TestFullscreenMouseLockContentSettings();
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_BrowserFullscreenMouseLockContentSettings) {
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
TestFullscreenMouseLockContentSettings();
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_BrowserFullscreenExit) {
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
AddTabAtIndex(0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_BrowserFullscreenAfterTabFSExit) {
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
AddTabAtIndex(0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
ASSERT_TRUE(IsFullscreenForBrowser());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_FullscreenFileURL) {
ui_test_utils::NavigateToURL(
browser(), ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath(kSimpleFile)));
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsFullscreenOnNavigation) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsFullscreenOnGoBack) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
GoBack();
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
IN_PROC_BROWSER_TEST_F(
FullscreenControllerInteractiveTest,
DISABLED_TestTabDoesntExitFullscreenOnSubFrameNavigation) {
ASSERT_TRUE(test_server()->Start());
GURL url(ui_test_utils::GetTestUrl(base::FilePath(
base::FilePath::kCurrentDirectory), base::FilePath(kSimpleFile)));
GURL url_with_fragment(url.spec() + "#fragment");
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ui_test_utils::NavigateToURL(browser(), url_with_fragment);
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
}
IN_PROC_BROWSER_TEST_F(
FullscreenControllerInteractiveTest,
DISABLED_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
GoBack();
ASSERT_TRUE(IsFullscreenForBrowser());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
}
#if defined(OS_MACOSX)
IN_PROC_BROWSER_TEST_F(
FullscreenControllerTest, DISABLED_TabEntersPresentationModeFromWindowed) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(kAboutBlankURL), PAGE_TRANSITION_TYPED);
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
{
FullscreenNotificationObserver fullscreen_observer;
EXPECT_FALSE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithChrome());
EXPECT_FALSE(browser()->window()->IsFullscreenWithoutChrome());
browser()->ToggleFullscreenModeForTab(tab, true);
fullscreen_observer.Wait();
EXPECT_TRUE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithChrome());
EXPECT_TRUE(browser()->window()->IsFullscreenWithoutChrome());
}
{
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
EXPECT_FALSE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithChrome());
EXPECT_FALSE(browser()->window()->IsFullscreenWithoutChrome());
}
if (chrome::mac::SupportsSystemFullscreen()) {
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
EXPECT_TRUE(browser()->window()->IsFullscreen());
EXPECT_TRUE(browser()->window()->IsFullscreenWithChrome());
EXPECT_FALSE(browser()->window()->IsFullscreenWithoutChrome());
}
}
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, EscapingMouseLock) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
{
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
}
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
SendEscapeToFullscreenController();
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
{
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
}
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
SendEscapeToFullscreenController();
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_EscapingMouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
{
FullscreenNotificationObserver fullscreen_observer;
SendEscapeToFullscreenController();
fullscreen_observer.Wait();
}
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
{
FullscreenNotificationObserver fullscreen_observer;
SendEscapeToFullscreenController();
fullscreen_observer.Wait();
}
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_MouseLockThenFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_D, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_MouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
{
FullscreenNotificationObserver fullscreen_observer;
DenyCurrentFullscreenOrMouseLockRequest();
fullscreen_observer.Wait();
}
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_PrivilegedMouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
SetPrivilegedFullscreen(true);
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
#define MAYBE_MouseLockSilentAfterTargetUnlock \
DISABLED_MouseLockSilentAfterTargetUnlock
#else
#define MAYBE_MouseLockSilentAfterTargetUnlock MouseLockSilentAfterTargetUnlock
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_MouseLockSilentAfterTargetUnlock) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_U, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_U, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_D, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_ESCAPE, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLocked());
}
#if defined(OS_WIN) || \
(defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA))
#define MAYBE_TestTabExitsMouseLockOnNavigation \
DISABLED_TestTabExitsMouseLockOnNavigation
#define MAYBE_TestTabExitsMouseLockOnGoBack \
DISABLED_TestTabExitsMouseLockOnGoBack
#else
#define MAYBE_TestTabExitsMouseLockOnNavigation \
TestTabExitsMouseLockOnNavigation
#define MAYBE_TestTabExitsMouseLockOnGoBack \
TestTabExitsMouseLockOnGoBack
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabExitsMouseLockOnNavigation) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_FALSE(IsMouseLocked());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabExitsMouseLockOnGoBack) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
GoBack();
ASSERT_FALSE(IsMouseLocked());
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
#define MAYBE_TestTabDoesntExitMouseLockOnSubFrameNavigation DISABLED_TestTabDoesntExitMouseLockOnSubFrameNavigation
#else
#define MAYBE_TestTabDoesntExitMouseLockOnSubFrameNavigation TestTabDoesntExitMouseLockOnSubFrameNavigation
#endif
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabDoesntExitMouseLockOnSubFrameNavigation) {
ASSERT_TRUE(test_server()->Start());
GURL url(test_server()->GetURL(kFullscreenMouseLockHTML));
GURL url_with_fragment(url.spec() + "#fragment");
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ui_test_utils::NavigateToURL(browser(), url_with_fragment);
ASSERT_TRUE(IsMouseLocked());
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_ReloadExitsMouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsMouseLockPermissionRequested());
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLockPermissionRequested());
{
MouseLockNotificationObserver mouselock_observer;
Reload();
mouselock_observer.Wait();
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLockPermissionRequested());
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
{
MouseLockNotificationObserver mouselock_observer;
Reload();
mouselock_observer.Wait();
ASSERT_FALSE(IsMouseLocked());
}
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
{
FullscreenNotificationObserver fullscreen_observer;
Reload();
fullscreen_observer.Wait();
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
}
}
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_ToggleFullscreenModeForTab) {
GURL url = test_server()->GetURL("simple.html");
AddTabAtIndex(0, url, PAGE_TRANSITION_TYPED);
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreenNoRetries(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreenNoRetries(false));
}