Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #if defined(OS_MACOSX) | 10 #if defined(OS_MACOSX) |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #endif | 12 #endif |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
| 15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 16 #include "chrome/browser/command_updater.h" | 16 #include "chrome/browser/command_updater.h" |
| 17 #include "chrome/browser/content_settings/host_content_settings_map.h" | |
| 17 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
| 18 #include "chrome/browser/extensions/extension_browsertest.h" | 19 #include "chrome/browser/extensions/extension_browsertest.h" |
| 19 #include "chrome/browser/extensions/extension_service.h" | 20 #include "chrome/browser/extensions/extension_service.h" |
| 20 #include "chrome/browser/extensions/extension_tab_helper.h" | 21 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 21 #include "chrome/browser/first_run/first_run.h" | 22 #include "chrome/browser/first_run/first_run.h" |
| 22 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 23 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 24 #include "chrome/browser/tabs/pinned_tab_codec.h" | 25 #include "chrome/browser/tabs/pinned_tab_codec.h" |
| 25 #include "chrome/browser/tabs/tab_strip_model.h" | 26 #include "chrome/browser/tabs/tab_strip_model.h" |
| 26 #include "chrome/browser/translate/translate_tab_helper.h" | 27 #include "chrome/browser/translate/translate_tab_helper.h" |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 169 } | 170 } |
| 170 | 171 |
| 171 virtual std::string GetHTMLContents() OVERRIDE { | 172 virtual std::string GetHTMLContents() OVERRIDE { |
| 172 return "<h1>INTERSTITIAL</h1>"; | 173 return "<h1>INTERSTITIAL</h1>"; |
| 173 } | 174 } |
| 174 | 175 |
| 175 private: | 176 private: |
| 176 InterstitialPage* interstitial_page_; // Owns us. | 177 InterstitialPage* interstitial_page_; // Owns us. |
| 177 }; | 178 }; |
| 178 | 179 |
| 180 // Fullscreen transition notification observer simplifies test code. | |
| 181 class FullscreenNotificationObserver : public | |
|
yzshen1
2012/03/16 07:33:28
Please move ": public" to the same line as ui_test
scheib
2012/03/16 21:20:03
Done.
| |
| 182 ui_test_utils::WindowedNotificationObserver { | |
| 183 public: | |
| 184 FullscreenNotificationObserver() : WindowedNotificationObserver( | |
| 185 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 186 content::NotificationService::AllSources()) { } | |
|
yzshen1
2012/03/16 07:33:28
nit: no need to have a space between {}.
scheib
2012/03/16 21:20:03
Done.
| |
| 187 }; | |
| 188 | |
| 179 } // namespace | 189 } // namespace |
| 180 | 190 |
| 181 class BrowserTest : public ExtensionBrowserTest { | 191 class BrowserTest : public ExtensionBrowserTest { |
| 182 protected: | 192 protected: |
| 183 // In RTL locales wrap the page title with RTL embedding characters so that it | 193 // In RTL locales wrap the page title with RTL embedding characters so that it |
| 184 // matches the value returned by GetWindowTitle(). | 194 // matches the value returned by GetWindowTitle(). |
| 185 std::wstring LocaleWindowCaptionFromPageTitle( | 195 std::wstring LocaleWindowCaptionFromPageTitle( |
| 186 const std::wstring& expected_title) { | 196 const std::wstring& expected_title) { |
| 187 std::wstring page_title = WindowCaptionFromPageTitle(expected_title); | 197 std::wstring page_title = WindowCaptionFromPageTitle(expected_title); |
| 188 #if defined(OS_WIN) | 198 #if defined(OS_WIN) |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 204 const ExtensionSet* extensions = | 214 const ExtensionSet* extensions = |
| 205 browser()->profile()->GetExtensionService()->extensions(); | 215 browser()->profile()->GetExtensionService()->extensions(); |
| 206 for (ExtensionSet::const_iterator it = extensions->begin(); | 216 for (ExtensionSet::const_iterator it = extensions->begin(); |
| 207 it != extensions->end(); ++it) { | 217 it != extensions->end(); ++it) { |
| 208 if ((*it)->name() == "App Test") | 218 if ((*it)->name() == "App Test") |
| 209 return *it; | 219 return *it; |
| 210 } | 220 } |
| 211 NOTREACHED(); | 221 NOTREACHED(); |
| 212 return NULL; | 222 return NULL; |
| 213 } | 223 } |
| 224 | |
| 225 void ToggleTabFullscreen(WebContents* tab, bool enter_fullscreen) { | |
| 226 if (browser()->fullscreen_controller_->IsFullscreenForBrowser()) { | |
| 227 // Changing tab fullscreen state will not actually change the window | |
| 228 // when browser fullscreen is in effect. | |
| 229 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); | |
| 230 } else { // Not in browser fullscreen, expect window to actually change. | |
|
yzshen1
2012/03/16 07:33:28
Please consider the following sequence:
browser fu
scheib
2012/03/16 21:20:03
Etner Browser FS | Will check for notification
En
yzshen1
2012/03/16 21:42:55
Ah, I see.
I mistakenly thought that IsFullscreen
scheib
2012/03/19 17:11:06
Done.
| |
| 231 FullscreenNotificationObserver fullscreen_observer; | |
| 232 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen); | |
| 233 fullscreen_observer.Wait(); | |
| 234 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | |
| 235 } | |
| 236 } | |
| 237 | |
| 238 void ToggleBrowserFullscreen(bool enter_fullscreen) { | |
|
yzshen1
2012/03/16 07:33:28
|enter_fullscreen| seems to be the expected result
scheib
2012/03/16 21:20:03
True, this is inherited from previous impl. I've a
| |
| 239 FullscreenNotificationObserver fullscreen_observer; | |
| 240 | |
| 241 browser()->ToggleFullscreenMode(); | |
| 242 | |
| 243 fullscreen_observer.Wait(); | |
| 244 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen); | |
| 245 ASSERT_EQ(browser()->fullscreen_controller_->IsFullscreenForBrowser(), | |
| 246 enter_fullscreen); | |
| 247 } | |
| 248 | |
| 249 void RequestToLockMouse(content::WebContents* tab) { | |
| 250 browser()->RequestToLockMouse(tab); | |
| 251 } | |
| 252 | |
| 253 void LostMouseLock() { | |
| 254 browser()->LostMouseLock(); | |
| 255 } | |
| 256 | |
| 257 bool IsFullscreenForTabOrPending() { | |
| 258 return browser()->IsFullscreenForTabOrPending(); | |
| 259 } | |
| 260 | |
| 261 bool IsMouseLockedOrPending() { | |
| 262 return browser()->IsMouseLockedOrPending(); | |
| 263 } | |
| 264 | |
| 265 bool IsMouseLockPermissionRequested() { | |
| 266 FullscreenExitBubbleType type = | |
| 267 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | |
| 268 bool mouse_lock = false; | |
| 269 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); | |
| 270 return mouse_lock; | |
| 271 } | |
| 272 | |
| 273 bool IsFullscreenPermissionRequested() { | |
| 274 FullscreenExitBubbleType type = | |
| 275 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | |
| 276 bool fullscreen = false; | |
| 277 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL); | |
| 278 return fullscreen; | |
| 279 } | |
| 280 | |
| 281 FullscreenExitBubbleType GetFullscreenExitBubbleType() { | |
| 282 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | |
| 283 } | |
| 284 | |
| 285 bool IsFullscreenBubbleDisplayed() { | |
| 286 FullscreenExitBubbleType type = | |
| 287 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | |
| 288 // TODO(scheib): Should be FEB_TYPE_NONE, crbug.com/107013 will include fix. | |
| 289 return type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION; | |
| 290 } | |
| 291 | |
| 292 bool IsFullscreenBubbleDisplayingButtons() { | |
| 293 FullscreenExitBubbleType type = | |
| 294 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | |
| 295 return fullscreen_bubble::ShowButtonsForType(type); | |
| 296 } | |
| 297 | |
| 298 void AcceptCurrentFullscreenOrMouseLockRequest() { | |
| 299 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | |
| 300 FullscreenExitBubbleType type = | |
| 301 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | |
| 302 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); | |
| 303 } | |
| 304 | |
| 305 void TestFullscreenMouseLockContentSettings(); | |
| 214 }; | 306 }; |
| 215 | 307 |
| 216 // Launch the app on a page with no title, check that the app title was set | 308 // Launch the app on a page with no title, check that the app title was set |
| 217 // correctly. | 309 // correctly. |
| 218 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { | 310 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { |
| 219 ui_test_utils::NavigateToURL(browser(), | 311 ui_test_utils::NavigateToURL(browser(), |
| 220 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 312 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 221 FilePath(kTitle1File))); | 313 FilePath(kTitle1File))); |
| 222 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"), | 314 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"), |
| 223 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab())); | 315 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab())); |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 868 EXPECT_EQ("fr", helper->language_state().original_language()); | 960 EXPECT_EQ("fr", helper->language_state().original_language()); |
| 869 } | 961 } |
| 870 | 962 |
| 871 #if defined(OS_MACOSX) | 963 #if defined(OS_MACOSX) |
| 872 // http://crbug.com/104265 | 964 // http://crbug.com/104265 |
| 873 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen | 965 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen |
| 874 #else | 966 #else |
| 875 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen | 967 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen |
| 876 #endif | 968 #endif |
| 877 | 969 |
| 970 // Tests that while in full screen creating a new tab will exit full screen. | |
|
yzshen1
2012/03/16 07:33:28
nit: we usually use 'fullscreen' as a word in the
scheib
2012/03/16 21:20:03
Done.
| |
| 878 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { | 971 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { |
| 879 ASSERT_TRUE(test_server()->Start()); | 972 ASSERT_TRUE(test_server()->Start()); |
| 880 | 973 |
| 881 AddTabAtIndex( | 974 AddTabAtIndex( |
| 882 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 975 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 883 | 976 |
| 884 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 977 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); |
| 885 | 978 |
| 886 { | 979 ToggleTabFullscreen(fullscreen_tab, true); |
| 887 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | |
| 888 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 889 content::NotificationService::AllSources()); | |
| 890 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | |
| 891 fullscreen_observer.Wait(); | |
| 892 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 893 } | |
| 894 | 980 |
| 895 { | 981 { |
| 896 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | 982 FullscreenNotificationObserver fullscreen_observer; |
| 897 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 898 content::NotificationService::AllSources()); | |
| 899 AddTabAtIndex( | 983 AddTabAtIndex( |
| 900 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 984 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 901 fullscreen_observer.Wait(); | 985 fullscreen_observer.Wait(); |
| 902 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 986 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 903 } | 987 } |
| 904 } | 988 } |
| 905 | 989 |
| 906 #if defined(OS_MACOSX) | 990 #if defined(OS_MACOSX) |
| 907 // http://crbug.com/100467 | 991 // http://crbug.com/100467 |
| 908 #define MAYBE_TestTabExitsItselfFromFullscreen \ | 992 #define MAYBE_TestTabExitsItselfFromFullscreen \ |
| 909 FAILS_TestTabExitsItselfFromFullscreen | 993 FAILS_TestTabExitsItselfFromFullscreen |
| 910 #else | 994 #else |
| 911 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen | 995 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen |
| 912 #endif | 996 #endif |
| 913 | 997 |
| 998 // Tests a tab exiting full screen will bring the browser out of full screen. | |
| 914 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) { | 999 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) { |
| 915 ASSERT_TRUE(test_server()->Start()); | 1000 ASSERT_TRUE(test_server()->Start()); |
| 916 | 1001 |
| 917 AddTabAtIndex( | 1002 AddTabAtIndex( |
| 918 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 1003 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 919 | 1004 |
| 920 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 1005 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); |
| 921 | 1006 ToggleTabFullscreen(fullscreen_tab, true); |
| 922 { | 1007 ToggleTabFullscreen(fullscreen_tab, false); |
| 923 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | |
| 924 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 925 content::NotificationService::AllSources()); | |
| 926 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | |
| 927 fullscreen_observer.Wait(); | |
| 928 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 929 } | |
| 930 | |
| 931 { | |
| 932 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | |
| 933 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 934 content::NotificationService::AllSources()); | |
| 935 browser()->ToggleFullscreenModeForTab(fullscreen_tab, false); | |
| 936 fullscreen_observer.Wait(); | |
| 937 ASSERT_FALSE(browser()->window()->IsFullscreen()); | |
| 938 } | |
| 939 } | 1008 } |
| 940 | 1009 |
| 1010 // Tests entering full screen and then requesting mouse lock results in | |
| 1011 // buttons for the user, and that after confirming the buttons are dismissed. | |
| 941 IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { | 1012 IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { |
| 942 ASSERT_TRUE(test_server()->Start()); | 1013 ASSERT_TRUE(test_server()->Start()); |
| 943 | 1014 |
| 944 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 1015 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), |
| 945 content::PAGE_TRANSITION_TYPED); | 1016 content::PAGE_TRANSITION_TYPED); |
| 946 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), | 1017 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), |
| 947 content::PAGE_TRANSITION_TYPED); | 1018 content::PAGE_TRANSITION_TYPED); |
| 948 | 1019 |
| 949 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 1020 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); |
| 950 | 1021 |
| 951 { | 1022 ToggleTabFullscreen(fullscreen_tab, true); |
| 952 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | |
| 953 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 954 content::NotificationService::AllSources()); | |
| 955 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | |
| 956 fullscreen_observer.Wait(); | |
| 957 ASSERT_TRUE(browser()->window()->IsFullscreen()); | |
| 958 } | |
| 959 | 1023 |
| 960 browser()->RequestToLockMouse(fullscreen_tab); | 1024 // Request mouse lock and verify the bubble is waiting for user confirmation. |
| 961 FullscreenExitBubbleType type = | 1025 RequestToLockMouse(fullscreen_tab); |
| 962 browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 1026 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
| 963 bool mouse_lock = false; | |
| 964 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock); | |
| 965 ASSERT_TRUE(mouse_lock); | |
| 966 | 1027 |
| 967 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type); | 1028 // Accept mouse lock and verify bubble no longer shows confirmation buttons. |
| 968 type = browser()->fullscreen_controller_->GetFullscreenExitBubbleType(); | 1029 AcceptCurrentFullscreenOrMouseLockRequest(); |
| 969 ASSERT_FALSE(fullscreen_bubble::ShowButtonsForType(type)); | 1030 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); |
| 1031 } | |
| 1032 | |
| 1033 // Tests mouse lock fails before fullscreen is entered. | |
| 1034 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) { | |
| 1035 WebContents* tab = browser()->GetSelectedWebContents(); | |
| 1036 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 1037 | |
| 1038 RequestToLockMouse(tab); | |
| 1039 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 1040 | |
| 1041 ToggleTabFullscreen(tab, true); | |
| 1042 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 1043 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 1044 } | |
| 1045 | |
| 1046 | |
|
yzshen1
2012/03/16 07:33:28
Please remove one blank line.
scheib
2012/03/16 21:20:03
Done.
| |
| 1047 // Helper method to be called by multiple tests. | |
| 1048 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | |
| 1049 void BrowserTest::TestFullscreenMouseLockContentSettings() { | |
| 1050 GURL url = test_server()->GetURL("simple.html"); | |
| 1051 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | |
| 1052 WebContents* tab = browser()->GetSelectedWebContents(); | |
| 1053 | |
| 1054 // Validate that going fullscreen for a URL defaults to asking permision. | |
| 1055 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 1056 ToggleTabFullscreen(tab, true); | |
| 1057 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 1058 ToggleTabFullscreen(tab, false); | |
| 1059 | |
| 1060 // Add content setting to ALLOW fullscreen. | |
| 1061 HostContentSettingsMap* settings_map = | |
| 1062 browser()->profile()->GetHostContentSettingsMap(); | |
| 1063 ContentSettingsPattern pattern = | |
| 1064 ContentSettingsPattern::FromURL(url); | |
| 1065 settings_map->SetContentSetting( | |
| 1066 pattern, ContentSettingsPattern::Wildcard(), | |
| 1067 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(), | |
| 1068 CONTENT_SETTING_ALLOW); | |
| 1069 | |
| 1070 // Now, fullscreen should not prompt for permission. | |
| 1071 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 1072 ToggleTabFullscreen(tab, true); | |
| 1073 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 1074 | |
| 1075 // Leaving tab in fullscreen, now test mouse lock ALLOW: | |
| 1076 | |
| 1077 // Validate that mouse lock defaults to asking permision. | |
| 1078 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 1079 ASSERT_FALSE(IsMouseLockedOrPending()); | |
| 1080 RequestToLockMouse(tab); | |
| 1081 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 1082 ASSERT_TRUE(IsMouseLockedOrPending()); | |
| 1083 LostMouseLock(); | |
| 1084 | |
| 1085 // Add content setting to ALLOW mouse lock. | |
| 1086 settings_map->SetContentSetting( | |
| 1087 pattern, ContentSettingsPattern::Wildcard(), | |
| 1088 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | |
| 1089 CONTENT_SETTING_ALLOW); | |
| 1090 | |
| 1091 // Now, mouse lock should not prompt for permission. | |
| 1092 ASSERT_FALSE(IsMouseLockedOrPending()); | |
| 1093 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 1094 RequestToLockMouse(tab); | |
| 1095 ASSERT_TRUE(IsMouseLockedOrPending()); | |
| 1096 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 1097 LostMouseLock(); | |
| 1098 | |
| 1099 // Leaving tab in fullscreen, now test mouse lock BLOCK: | |
| 1100 | |
| 1101 // Add content setting to BLOCK mouse lock. | |
| 1102 settings_map->SetContentSetting( | |
| 1103 pattern, ContentSettingsPattern::Wildcard(), | |
| 1104 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(), | |
| 1105 CONTENT_SETTING_BLOCK); | |
| 1106 | |
| 1107 // Now, mouse lock should not be pending. | |
| 1108 ASSERT_FALSE(IsMouseLockedOrPending()); | |
| 1109 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 1110 RequestToLockMouse(tab); | |
| 1111 ASSERT_FALSE(IsMouseLockedOrPending()); | |
| 1112 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 1113 } | |
| 1114 | |
| 1115 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | |
| 1116 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) { | |
| 1117 TestFullscreenMouseLockContentSettings(); | |
| 1118 } | |
| 1119 | |
| 1120 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK, | |
| 1121 // but with the browser initiated in fullscreen mode first. | |
| 1122 IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenMouseLockContentSettings) { | |
| 1123 // Enter browser fullscreen first. | |
| 1124 ToggleBrowserFullscreen(true); | |
| 1125 TestFullscreenMouseLockContentSettings(); | |
| 1126 ToggleBrowserFullscreen(false); | |
| 1127 } | |
| 1128 | |
| 1129 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. | |
|
yzshen1
2012/03/16 07:33:28
It would be great if we also test
browser fullscre
scheib
2012/03/16 21:20:03
Done. Added BrowserFullscreenAfterTabFSExit.
| |
| 1130 IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenExit) { | |
| 1131 // Enter browser fullscreen. | |
| 1132 ToggleBrowserFullscreen(true); | |
| 1133 | |
| 1134 // Enter tab fullscreen. | |
| 1135 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | |
| 1136 content::PAGE_TRANSITION_TYPED); | |
| 1137 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | |
| 1138 ToggleTabFullscreen(fullscreen_tab, true); | |
| 1139 | |
| 1140 // Exit browser fullscreen. | |
| 1141 ToggleBrowserFullscreen(false); | |
| 1142 ASSERT_FALSE(browser()->window()->IsFullscreen()); | |
| 1143 } | |
| 1144 | |
| 1145 // Tests fullscreen entered without permision prompt for file:// urls. | |
| 1146 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenFileURL) { | |
| 1147 GURL url = ui_test_utils::GetTestUrl(FilePath(""), FilePath("simple.html")); | |
| 1148 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | |
| 1149 WebContents* tab = browser()->GetSelectedWebContents(); | |
| 1150 | |
| 1151 // Validate that going fullscreen for a URL defaults to asking permision. | |
|
koz (OOO until 15th September)
2012/03/16 04:31:25
This comment seems to contradict the code and the
scheib
2012/03/16 21:20:03
Done.
| |
| 1152 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 1153 ToggleTabFullscreen(tab, true); | |
| 1154 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 1155 ToggleTabFullscreen(tab, false); | |
| 970 } | 1156 } |
| 971 | 1157 |
| 972 #if defined(OS_MACOSX) | 1158 #if defined(OS_MACOSX) |
| 973 // http://crbug.com/100467 | 1159 // http://crbug.com/100467 |
| 974 IN_PROC_BROWSER_TEST_F( | 1160 IN_PROC_BROWSER_TEST_F( |
| 975 BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) { | 1161 BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) { |
| 976 ASSERT_TRUE(test_server()->Start()); | 1162 ASSERT_TRUE(test_server()->Start()); |
| 977 | 1163 |
| 978 AddTabAtIndex( | 1164 AddTabAtIndex( |
| 979 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 1165 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
| 980 | 1166 |
| 981 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); | 1167 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); |
| 982 | 1168 |
| 983 { | 1169 { |
| 984 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | 1170 FullscreenNotificationObserver fullscreen_observer; |
| 985 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 986 content::NotificationService::AllSources()); | |
| 987 EXPECT_FALSE(browser()->window()->IsFullscreen()); | 1171 EXPECT_FALSE(browser()->window()->IsFullscreen()); |
| 988 EXPECT_FALSE(browser()->window()->InPresentationMode()); | 1172 EXPECT_FALSE(browser()->window()->InPresentationMode()); |
| 989 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | 1173 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); |
| 990 fullscreen_observer.Wait(); | 1174 fullscreen_observer.Wait(); |
| 991 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 1175 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 992 ASSERT_TRUE(browser()->window()->InPresentationMode()); | 1176 ASSERT_TRUE(browser()->window()->InPresentationMode()); |
| 993 } | 1177 } |
| 994 | 1178 |
| 995 { | 1179 { |
| 996 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | 1180 FullscreenNotificationObserver fullscreen_observer; |
| 997 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 998 content::NotificationService::AllSources()); | |
| 999 browser()->TogglePresentationMode(); | 1181 browser()->TogglePresentationMode(); |
| 1000 fullscreen_observer.Wait(); | 1182 fullscreen_observer.Wait(); |
| 1001 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 1183 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 1002 ASSERT_FALSE(browser()->window()->InPresentationMode()); | 1184 ASSERT_FALSE(browser()->window()->InPresentationMode()); |
| 1003 } | 1185 } |
| 1004 | 1186 |
| 1005 if (base::mac::IsOSLionOrLater()) { | 1187 if (base::mac::IsOSLionOrLater()) { |
| 1006 // Test that tab fullscreen mode doesn't make presentation mode the default | 1188 // Test that tab fullscreen mode doesn't make presentation mode the default |
| 1007 // on Lion. | 1189 // on Lion. |
| 1008 ui_test_utils::WindowedNotificationObserver fullscreen_observer( | 1190 FullscreenNotificationObserver fullscreen_observer; |
| 1009 chrome::NOTIFICATION_FULLSCREEN_CHANGED, | |
| 1010 content::NotificationService::AllSources()); | |
| 1011 browser()->ToggleFullscreenMode(); | 1191 browser()->ToggleFullscreenMode(); |
| 1012 fullscreen_observer.Wait(); | 1192 fullscreen_observer.Wait(); |
| 1013 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 1193 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
| 1014 ASSERT_FALSE(browser()->window()->InPresentationMode()); | 1194 ASSERT_FALSE(browser()->window()->InPresentationMode()); |
| 1015 } | 1195 } |
| 1016 } | 1196 } |
| 1017 #endif | 1197 #endif |
| 1018 | 1198 |
| 1019 // Chromeos defaults to restoring the last session, so this test isn't | 1199 // Chromeos defaults to restoring the last session, so this test isn't |
| 1020 // applicable. | 1200 // applicable. |
| (...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1539 | 1719 |
| 1540 // The normal browser should now have four. | 1720 // The normal browser should now have four. |
| 1541 EXPECT_EQ(4, browser()->tab_count()); | 1721 EXPECT_EQ(4, browser()->tab_count()); |
| 1542 | 1722 |
| 1543 // Close the additional browsers. | 1723 // Close the additional browsers. |
| 1544 popup_browser->CloseAllTabs(); | 1724 popup_browser->CloseAllTabs(); |
| 1545 app_browser->CloseAllTabs(); | 1725 app_browser->CloseAllTabs(); |
| 1546 app_popup_browser->CloseAllTabs(); | 1726 app_popup_browser->CloseAllTabs(); |
| 1547 } | 1727 } |
| 1548 #endif | 1728 #endif |
| OLD | NEW |