summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/browser_browsertest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/ui/browser_browsertest.cc')
-rw-r--r--chrome/browser/ui/browser_browsertest.cc654
1 files changed, 0 insertions, 654 deletions
diff --git a/chrome/browser/ui/browser_browsertest.cc b/chrome/browser/ui/browser_browsertest.cc
index 6979f48..f2e63e0 100644
--- a/chrome/browser/ui/browser_browsertest.cc
+++ b/chrome/browser/ui/browser_browsertest.cc
@@ -33,8 +33,6 @@
#include "chrome/browser/ui/browser_navigator.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/application_launch.h"
-#include "chrome/browser/ui/fullscreen_controller.h"
-#include "chrome/browser/ui/fullscreen_exit_bubble_type.h"
#include "chrome/browser/ui/startup/startup_browser_creator.h"
#include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
@@ -93,15 +91,11 @@ const char* kOpenNewBeforeUnloadPage =
const FilePath::CharType* kBeforeUnloadFile =
FILE_PATH_LITERAL("beforeunload.html");
-const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html");
const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
-const char* kFullscreenMouseLockHTML =
- "files/fullscreen_mouselock/fullscreen_mouselock.html";
-
// Given a page title, returns the expected window caption string.
string16 WindowCaptionFromPageTitle(const string16& page_title) {
#if defined(OS_MACOSX) || defined(OS_CHROMEOS)
@@ -184,22 +178,6 @@ class TestInterstitialPage : public content::InterstitialPageDelegate {
InterstitialPage* interstitial_page_; // Owns us.
};
-class FullscreenNotificationObserver
- : public ui_test_utils::WindowedNotificationObserver {
- public:
- FullscreenNotificationObserver() : WindowedNotificationObserver(
- chrome::NOTIFICATION_FULLSCREEN_CHANGED,
- content::NotificationService::AllSources()) {}
-};
-
-class MouseLockNotificationObserver
- : public ui_test_utils::WindowedNotificationObserver {
- public:
- MouseLockNotificationObserver() : WindowedNotificationObserver(
- chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
- content::NotificationService::AllSources()) {}
-};
-
} // namespace
class BrowserTest : public ExtensionBrowserTest {
@@ -239,110 +217,6 @@ class BrowserTest : public ExtensionBrowserTest {
NOTREACHED();
return NULL;
}
-
- void ToggleTabFullscreen(WebContents* tab, bool enter_fullscreen) {
- if (IsFullscreenForBrowser()) {
- // Changing tab fullscreen state will not actually change the window
- // when browser fullscreen is in effect.
- browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
- } else { // Not in browser fullscreen, expect window to actually change.
- FullscreenNotificationObserver fullscreen_observer;
- browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
- fullscreen_observer.Wait();
- ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
- }
- }
-
- void ToggleBrowserFullscreen(bool enter_fullscreen) {
- ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen);
- FullscreenNotificationObserver fullscreen_observer;
-
- browser()->ToggleFullscreenMode();
-
- fullscreen_observer.Wait();
- ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
- ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen);
- }
-
- void RequestToLockMouse(content::WebContents* tab,
- bool user_gesture,
- bool last_unlocked_by_target) {
- browser()->RequestToLockMouse(tab, user_gesture,
- last_unlocked_by_target);
- }
-
- void LostMouseLock() {
- browser()->LostMouseLock();
- }
-
- bool SendEscapeToFullscreenController() {
- return browser()->fullscreen_controller_->HandleUserPressedEscape();
- }
-
- bool IsFullscreenForBrowser() {
- return browser()->fullscreen_controller_->IsFullscreenForBrowser();
- }
-
- bool IsFullscreenForTabOrPending() {
- return browser()->IsFullscreenForTabOrPending();
- }
-
- bool IsMouseLocked() {
- // Verify that IsMouseLocked is consistent between the
- // Fullscreen Controller and the Render View Host View.
- EXPECT_TRUE(browser()->IsMouseLocked() ==
- browser()->GetSelectedWebContents()->
- GetRenderViewHost()->GetView()->IsMouseLocked());
- return browser()->IsMouseLocked();
- }
-
- bool IsMouseLockPermissionRequested() {
- FullscreenExitBubbleType type =
- browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- bool mouse_lock = false;
- fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock);
- return mouse_lock;
- }
-
- bool IsFullscreenPermissionRequested() {
- FullscreenExitBubbleType type =
- browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- bool fullscreen = false;
- fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL);
- return fullscreen;
- }
-
- FullscreenExitBubbleType GetFullscreenExitBubbleType() {
- return browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- }
-
- bool IsFullscreenBubbleDisplayed() {
- FullscreenExitBubbleType type =
- browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- return type != FEB_TYPE_NONE;
- }
-
- bool IsFullscreenBubbleDisplayingButtons() {
- FullscreenExitBubbleType type =
- browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- return fullscreen_bubble::ShowButtonsForType(type);
- }
-
- void AcceptCurrentFullscreenOrMouseLockRequest() {
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
- FullscreenExitBubbleType type =
- browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type);
- }
-
- void DenyCurrentFullscreenOrMouseLockRequest() {
- FullscreenExitBubbleType type =
- browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
- browser()->OnDenyFullscreenPermission(type);
- }
-
- // Helper method to be called by multiple tests.
- void TestFullscreenMouseLockContentSettings();
};
// Launch the app on a page with no title, check that the app title was set
@@ -1009,534 +883,6 @@ IN_PROC_BROWSER_TEST_F(BrowserTest, PageLanguageDetection) {
EXPECT_EQ("fr", helper->language_state().original_language());
}
-#if defined(OS_MACOSX)
-// http://crbug.com/104265
-#define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen
-#else
-#define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen
-#endif
-
-// Tests that while in fullscreen creating a new tab will exit fullscreen.
-IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) {
- ASSERT_TRUE(test_server()->Start());
-
- AddTabAtIndex(
- 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
-
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
-
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
-
- {
- FullscreenNotificationObserver fullscreen_observer;
- AddTabAtIndex(
- 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
- fullscreen_observer.Wait();
- ASSERT_FALSE(browser()->window()->IsFullscreen());
- }
-}
-
-#if defined(OS_MACOSX)
-// http://crbug.com/100467
-#define MAYBE_TestTabExitsItselfFromFullscreen \
- FAILS_TestTabExitsItselfFromFullscreen
-#else
-#define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen
-#endif
-
-// Tests a tab exiting fullscreen will bring the browser out of fullscreen.
-IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) {
- ASSERT_TRUE(test_server()->Start());
-
- AddTabAtIndex(
- 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
-
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false));
-}
-
-// Tests entering fullscreen and then requesting mouse lock results in
-// buttons for the user, and that after confirming the buttons are dismissed.
-IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) {
- ASSERT_TRUE(test_server()->Start());
-
- AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
- content::PAGE_TRANSITION_TYPED);
- AddTabAtIndex(1, GURL(chrome::kAboutBlankURL),
- content::PAGE_TRANSITION_TYPED);
-
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
-
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
-
- // Request mouse lock and verify the bubble is waiting for user confirmation.
- RequestToLockMouse(fullscreen_tab, true, false);
- ASSERT_TRUE(IsMouseLockPermissionRequested());
-
- // Accept mouse lock and verify bubble no longer shows confirmation buttons.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
-}
-
-// BrowserTest.MouseLockThenFullscreen is flaky on linux and win.
-// (http://crbug.com/130358)
-#if defined(OS_WIN) || defined(OS_LINUX)
-#define MAYBE_MouseLockThenFullscreen DISABLED_MouseLockThenFullscreen
-#else
-#define MAYBE_MouseLockThenFullscreen MouseLockThenFullscreen
-#endif
-
-// Tests mouse lock then fullscreen.
-IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_MouseLockThenFullscreen) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- test_server()->GetURL(kFullscreenMouseLockHTML));
-
- WebContents* tab = browser()->GetSelectedWebContents();
-
- ASSERT_FALSE(IsFullscreenBubbleDisplayed());
-
- // Lock the mouse without a user gesture, expect no response.
- 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());
-
- // Lock the mouse with a user gesture.
- 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());
-
- // Accept mouse lock.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_TRUE(IsMouseLocked());
- ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
-
- // Enter fullscreen mode, mouse lock should be dropped to present buttons.
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
- ASSERT_TRUE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
- ASSERT_FALSE(IsMouseLocked());
-
- // Request mouse lock also, expect fullscreen and mouse lock buttons.
- 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());
-
- // Accept fullscreen and mouse lock.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_TRUE(IsMouseLocked());
- ASSERT_TRUE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
-}
-
-// Tests mouse lock then fullscreen in same request.
-IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockAndFullscreen) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- test_server()->GetURL(kFullscreenMouseLockHTML));
-
- ASSERT_FALSE(IsFullscreenBubbleDisplayed());
-
- // Request to lock the mouse and enter fullscreen.
- {
- 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(IsFullscreenForTabOrPending());
-
- // Deny both first, to make sure we can.
- {
- FullscreenNotificationObserver fullscreen_observer;
- DenyCurrentFullscreenOrMouseLockRequest();
- fullscreen_observer.Wait();
- }
- ASSERT_FALSE(IsMouseLocked());
- ASSERT_FALSE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenPermissionRequested());
-
- // Request to lock the mouse and enter fullscreen.
- {
- 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(IsFullscreenForTabOrPending());
-
- // Accept both, confirm they are enabled and there is no prompt.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_TRUE(IsMouseLocked());
- ASSERT_TRUE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenPermissionRequested());
-}
-
-// Tests mouse lock can be escaped with ESC key.
-IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLock) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- test_server()->GetURL(kFullscreenMouseLockHTML));
-
- ASSERT_FALSE(IsFullscreenBubbleDisplayed());
-
- // Request to lock the mouse.
- {
- 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());
-
- // Escape, no prompts should remain.
- SendEscapeToFullscreenController();
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-
- // Request to lock the mouse.
- {
- 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());
-
- // Accept mouse lock, confirm it and that there is no prompt.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_TRUE(IsMouseLocked());
- ASSERT_FALSE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-
- // Escape, confirm we are out of mouse lock with no prompts.
- SendEscapeToFullscreenController();
- ASSERT_FALSE(IsMouseLocked());
- ASSERT_FALSE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-}
-
-// Tests mouse lock and fullscreen modes can be escaped with ESC key.
-IN_PROC_BROWSER_TEST_F(BrowserTest, EscapingMouseLockAndFullscreen) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- test_server()->GetURL(kFullscreenMouseLockHTML));
-
- ASSERT_FALSE(IsFullscreenBubbleDisplayed());
-
- // Request to lock the mouse and enter fullscreen.
- {
- 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());
-
- // Escape, no prompts should remain.
- {
- FullscreenNotificationObserver fullscreen_observer;
- SendEscapeToFullscreenController();
- fullscreen_observer.Wait();
- }
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-
- // Request to lock the mouse and enter fullscreen.
- {
- 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());
-
- // Accept both, confirm mouse lock and fullscreen and no prompts.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_TRUE(IsMouseLocked());
- ASSERT_TRUE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-
- // Escape, confirm we are out of mouse lock and fullscreen with no prompts.
- {
- FullscreenNotificationObserver fullscreen_observer;
- SendEscapeToFullscreenController();
- fullscreen_observer.Wait();
- }
- ASSERT_FALSE(IsMouseLocked());
- ASSERT_FALSE(IsFullscreenForTabOrPending());
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-}
-
-IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockSilentAfterTargetUnlock) {
- ASSERT_TRUE(test_server()->Start());
- ui_test_utils::NavigateToURL(browser(),
- test_server()->GetURL(kFullscreenMouseLockHTML));
-
- ASSERT_FALSE(IsFullscreenBubbleDisplayed());
-
- // Lock the mouse with a user gesture.
- 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());
-
- // Accept mouse lock.
- AcceptCurrentFullscreenOrMouseLockRequest();
- ASSERT_TRUE(IsMouseLocked());
- ASSERT_TRUE(IsFullscreenBubbleDisplayed());
-
- // Unlock the mouse from target, make sure it's unloacked
- 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());
-
- // Lock mouse again, make sure it works with no bubble
- 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());
-
- // Unlock the mouse again by target
- 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());
-
- // Lock from target, not user gesture, make sure it works
- 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());
-
- // Unlock by escape
- 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());
-
- // Lock the mouse with a user gesture, make sure we see bubble again
- 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());
-}
-
-// Helper method to be called by multiple tests.
-// Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
-void BrowserTest::TestFullscreenMouseLockContentSettings() {
- GURL url = test_server()->GetURL("simple.html");
- AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
- WebContents* tab = browser()->GetSelectedWebContents();
-
- // Validate that going fullscreen for a URL defaults to asking permision.
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
- ASSERT_TRUE(IsFullscreenPermissionRequested());
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false));
-
- // Add content setting to ALLOW fullscreen.
- 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);
-
- // Now, fullscreen should not prompt for permission.
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
- ASSERT_FALSE(IsFullscreenPermissionRequested());
-
- // Leaving tab in fullscreen, now test mouse lock ALLOW:
-
- // Validate that mouse lock defaults to asking permision.
- ASSERT_FALSE(IsMouseLockPermissionRequested());
- ASSERT_FALSE(IsMouseLocked());
- RequestToLockMouse(tab, true, false);
- ASSERT_TRUE(IsMouseLockPermissionRequested());
- LostMouseLock();
-
- // Add content setting to ALLOW mouse lock.
- settings_map->SetContentSetting(
- pattern, ContentSettingsPattern::Wildcard(),
- CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
- CONTENT_SETTING_ALLOW);
-
- // Now, mouse lock should not prompt for permission.
- ASSERT_FALSE(IsMouseLockPermissionRequested());
- RequestToLockMouse(tab, true, false);
- ASSERT_FALSE(IsMouseLockPermissionRequested());
- LostMouseLock();
-
- // Leaving tab in fullscreen, now test mouse lock BLOCK:
-
- // Add content setting to BLOCK mouse lock.
- settings_map->SetContentSetting(
- pattern, ContentSettingsPattern::Wildcard(),
- CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
- CONTENT_SETTING_BLOCK);
-
- // Now, mouse lock should not be pending.
- ASSERT_FALSE(IsMouseLockPermissionRequested());
- RequestToLockMouse(tab, true, false);
- ASSERT_FALSE(IsMouseLockPermissionRequested());
-}
-
-// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
-IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) {
- TestFullscreenMouseLockContentSettings();
-}
-
-// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK,
-// but with the browser initiated in fullscreen mode first.
-IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenMouseLockContentSettings) {
- // Enter browser fullscreen first.
- ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
- TestFullscreenMouseLockContentSettings();
- ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
-}
-
-// Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser.
-IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenExit) {
- // Enter browser fullscreen.
- ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
-
- // Enter tab fullscreen.
- AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
- content::PAGE_TRANSITION_TYPED);
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
-
- // Exit browser fullscreen.
- ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
- ASSERT_FALSE(browser()->window()->IsFullscreen());
-}
-
-// Tests Browser Fullscreen remains active after Tab mode entered and exited.
-IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenAfterTabFSExit) {
- // Enter browser fullscreen.
- ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
-
- // Enter and then exit tab fullscreen.
- AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
- content::PAGE_TRANSITION_TYPED);
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false));
-
- // Verify browser fullscreen still active.
- ASSERT_TRUE(IsFullscreenForBrowser());
-}
-
-// Tests fullscreen entered without permision prompt for file:// urls.
-IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenFileURL) {
- ui_test_utils::NavigateToURL(browser(),
- ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
- FilePath(kSimpleFile)));
- WebContents* tab = browser()->GetSelectedWebContents();
-
- // Validate that going fullscreen for a file does not ask permision.
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
- ASSERT_FALSE(IsFullscreenPermissionRequested());
- ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false));
-}
-
-#if defined(OS_MACOSX)
-// http://crbug.com/100467
-IN_PROC_BROWSER_TEST_F(
- BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) {
- ASSERT_TRUE(test_server()->Start());
-
- AddTabAtIndex(
- 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
-
- WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
-
- {
- FullscreenNotificationObserver fullscreen_observer;
- EXPECT_FALSE(browser()->window()->IsFullscreen());
- EXPECT_FALSE(browser()->window()->InPresentationMode());
- browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
- fullscreen_observer.Wait();
- ASSERT_TRUE(browser()->window()->IsFullscreen());
- ASSERT_TRUE(browser()->window()->InPresentationMode());
- }
-
- {
- FullscreenNotificationObserver fullscreen_observer;
- browser()->TogglePresentationMode();
- fullscreen_observer.Wait();
- ASSERT_FALSE(browser()->window()->IsFullscreen());
- ASSERT_FALSE(browser()->window()->InPresentationMode());
- }
-
- if (base::mac::IsOSLionOrLater()) {
- // Test that tab fullscreen mode doesn't make presentation mode the default
- // on Lion.
- FullscreenNotificationObserver fullscreen_observer;
- browser()->ToggleFullscreenMode();
- fullscreen_observer.Wait();
- ASSERT_TRUE(browser()->window()->IsFullscreen());
- ASSERT_FALSE(browser()->window()->InPresentationMode());
- }
-}
-#endif
-
// Chromeos defaults to restoring the last session, so this test isn't
// applicable.
#if !defined(OS_CHROMEOS)