Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/ui/browser_browsertest.cc

Issue 9875028: Reverting due to memory (Valgrind) errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:mergeinfo
OLDNEW
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"
18 #include "chrome/browser/defaults.h" 17 #include "chrome/browser/defaults.h"
19 #include "chrome/browser/extensions/extension_browsertest.h" 18 #include "chrome/browser/extensions/extension_browsertest.h"
20 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_tab_helper.h" 20 #include "chrome/browser/extensions/extension_tab_helper.h"
22 #include "chrome/browser/first_run/first_run.h" 21 #include "chrome/browser/first_run/first_run.h"
23 #include "chrome/browser/prefs/incognito_mode_prefs.h" 22 #include "chrome/browser/prefs/incognito_mode_prefs.h"
24 #include "chrome/browser/profiles/profile.h" 23 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/tabs/pinned_tab_codec.h" 24 #include "chrome/browser/tabs/pinned_tab_codec.h"
26 #include "chrome/browser/tabs/tab_strip_model.h" 25 #include "chrome/browser/tabs/tab_strip_model.h"
27 #include "chrome/browser/translate/translate_tab_helper.h" 26 #include "chrome/browser/translate/translate_tab_helper.h"
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 "<html><head><title>beforeunload</title></head><body>" 79 "<html><head><title>beforeunload</title></head><body>"
81 "<script>window.onbeforeunload=function(e){return 'foo'}</script>" 80 "<script>window.onbeforeunload=function(e){return 'foo'}</script>"
82 "</body></html>"; 81 "</body></html>";
83 82
84 const char* kOpenNewBeforeUnloadPage = 83 const char* kOpenNewBeforeUnloadPage =
85 "w=window.open(); w.onbeforeunload=function(e){return 'foo'};"; 84 "w=window.open(); w.onbeforeunload=function(e){return 'foo'};";
86 85
87 const FilePath::CharType* kBeforeUnloadFile = 86 const FilePath::CharType* kBeforeUnloadFile =
88 FILE_PATH_LITERAL("beforeunload.html"); 87 FILE_PATH_LITERAL("beforeunload.html");
89 88
90 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
91 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html"); 89 const FilePath::CharType* kTitle1File = FILE_PATH_LITERAL("title1.html");
92 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html"); 90 const FilePath::CharType* kTitle2File = FILE_PATH_LITERAL("title2.html");
93 91
94 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); 92 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data");
95 93
96 // Given a page title, returns the expected window caption string. 94 // Given a page title, returns the expected window caption string.
97 std::wstring WindowCaptionFromPageTitle(std::wstring page_title) { 95 std::wstring WindowCaptionFromPageTitle(std::wstring page_title) {
98 #if defined(OS_MACOSX) || defined(OS_CHROMEOS) 96 #if defined(OS_MACOSX) || defined(OS_CHROMEOS)
99 // On Mac or ChromeOS, we don't want to suffix the page title with 97 // On Mac or ChromeOS, we don't want to suffix the page title with
100 // the application name. 98 // the application name.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 } 169 }
172 170
173 virtual std::string GetHTMLContents() OVERRIDE { 171 virtual std::string GetHTMLContents() OVERRIDE {
174 return "<h1>INTERSTITIAL</h1>"; 172 return "<h1>INTERSTITIAL</h1>";
175 } 173 }
176 174
177 private: 175 private:
178 InterstitialPage* interstitial_page_; // Owns us. 176 InterstitialPage* interstitial_page_; // Owns us.
179 }; 177 };
180 178
181 // Fullscreen transition notification observer simplifies test code.
182 class FullscreenNotificationObserver
183 : public ui_test_utils::WindowedNotificationObserver {
184 public:
185 FullscreenNotificationObserver() : WindowedNotificationObserver(
186 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
187 content::NotificationService::AllSources()) {}
188 };
189
190 } // namespace 179 } // namespace
191 180
192 class BrowserTest : public ExtensionBrowserTest { 181 class BrowserTest : public ExtensionBrowserTest {
193 protected: 182 protected:
194 // In RTL locales wrap the page title with RTL embedding characters so that it 183 // In RTL locales wrap the page title with RTL embedding characters so that it
195 // matches the value returned by GetWindowTitle(). 184 // matches the value returned by GetWindowTitle().
196 std::wstring LocaleWindowCaptionFromPageTitle( 185 std::wstring LocaleWindowCaptionFromPageTitle(
197 const std::wstring& expected_title) { 186 const std::wstring& expected_title) {
198 std::wstring page_title = WindowCaptionFromPageTitle(expected_title); 187 std::wstring page_title = WindowCaptionFromPageTitle(expected_title);
199 #if defined(OS_WIN) 188 #if defined(OS_WIN)
(...skipping 15 matching lines...) Expand all
215 const ExtensionSet* extensions = 204 const ExtensionSet* extensions =
216 browser()->profile()->GetExtensionService()->extensions(); 205 browser()->profile()->GetExtensionService()->extensions();
217 for (ExtensionSet::const_iterator it = extensions->begin(); 206 for (ExtensionSet::const_iterator it = extensions->begin();
218 it != extensions->end(); ++it) { 207 it != extensions->end(); ++it) {
219 if ((*it)->name() == "App Test") 208 if ((*it)->name() == "App Test")
220 return *it; 209 return *it;
221 } 210 }
222 NOTREACHED(); 211 NOTREACHED();
223 return NULL; 212 return NULL;
224 } 213 }
225
226 void ToggleTabFullscreen(WebContents* tab, bool enter_fullscreen) {
227 if (IsFullscreenForBrowser()) {
228 // Changing tab fullscreen state will not actually change the window
229 // when browser fullscreen is in effect.
230 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
231 } else { // Not in browser fullscreen, expect window to actually change.
232 FullscreenNotificationObserver fullscreen_observer;
233 browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
234 fullscreen_observer.Wait();
235 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
236 }
237 }
238
239 void ToggleBrowserFullscreen(bool enter_fullscreen) {
240 ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen);
241 FullscreenNotificationObserver fullscreen_observer;
242
243 browser()->ToggleFullscreenMode();
244
245 fullscreen_observer.Wait();
246 ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
247 ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen);
248 }
249
250 void RequestToLockMouse(content::WebContents* tab) {
251 browser()->RequestToLockMouse(tab);
252 }
253
254 void LostMouseLock() {
255 browser()->LostMouseLock();
256 }
257
258 bool IsFullscreenForBrowser() {
259 return browser()->fullscreen_controller_->IsFullscreenForBrowser();
260 }
261
262 bool IsFullscreenForTabOrPending() {
263 return browser()->IsFullscreenForTabOrPending();
264 }
265
266 bool IsMouseLockedOrPending() {
267 return browser()->IsMouseLockedOrPending();
268 }
269
270 bool IsMouseLockPermissionRequested() {
271 FullscreenExitBubbleType type =
272 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
273 bool mouse_lock = false;
274 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock);
275 return mouse_lock;
276 }
277
278 bool IsFullscreenPermissionRequested() {
279 FullscreenExitBubbleType type =
280 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
281 bool fullscreen = false;
282 fullscreen_bubble::PermissionRequestedByType(type, &fullscreen, NULL);
283 return fullscreen;
284 }
285
286 FullscreenExitBubbleType GetFullscreenExitBubbleType() {
287 return browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
288 }
289
290 bool IsFullscreenBubbleDisplayed() {
291 FullscreenExitBubbleType type =
292 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
293 // TODO(scheib): Should be FEB_TYPE_NONE, crbug.com/107013 will include fix.
294 return type != FEB_TYPE_BROWSER_FULLSCREEN_EXIT_INSTRUCTION;
295 }
296
297 bool IsFullscreenBubbleDisplayingButtons() {
298 FullscreenExitBubbleType type =
299 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
300 return fullscreen_bubble::ShowButtonsForType(type);
301 }
302
303 void AcceptCurrentFullscreenOrMouseLockRequest() {
304 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
305 FullscreenExitBubbleType type =
306 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
307 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type);
308 }
309
310 // Helper method to be called by multiple tests.
311 void TestFullscreenMouseLockContentSettings();
312 }; 214 };
313 215
314 // Launch the app on a page with no title, check that the app title was set 216 // Launch the app on a page with no title, check that the app title was set
315 // correctly. 217 // correctly.
316 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) { 218 IN_PROC_BROWSER_TEST_F(BrowserTest, NoTitle) {
317 ui_test_utils::NavigateToURL(browser(), 219 ui_test_utils::NavigateToURL(browser(),
318 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), 220 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
319 FilePath(kTitle1File))); 221 FilePath(kTitle1File)));
320 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"), 222 EXPECT_EQ(LocaleWindowCaptionFromPageTitle(L"title1.html"),
321 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab())); 223 UTF16ToWideHack(browser()->GetWindowTitleForCurrentTab()));
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
966 EXPECT_EQ("fr", helper->language_state().original_language()); 868 EXPECT_EQ("fr", helper->language_state().original_language());
967 } 869 }
968 870
969 #if defined(OS_MACOSX) 871 #if defined(OS_MACOSX)
970 // http://crbug.com/104265 872 // http://crbug.com/104265
971 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen 873 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen
972 #else 874 #else
973 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen 875 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen
974 #endif 876 #endif
975 877
976 // Tests that while in fullscreen creating a new tab will exit fullscreen.
977 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) { 878 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestNewTabExitsFullscreen) {
978 ASSERT_TRUE(test_server()->Start()); 879 ASSERT_TRUE(test_server()->Start());
979 880
980 AddTabAtIndex( 881 AddTabAtIndex(
981 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 882 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
982 883
983 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 884 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
984 885
985 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); 886 {
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 }
986 894
987 { 895 {
988 FullscreenNotificationObserver fullscreen_observer; 896 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
897 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
898 content::NotificationService::AllSources());
989 AddTabAtIndex( 899 AddTabAtIndex(
990 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 900 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
991 fullscreen_observer.Wait(); 901 fullscreen_observer.Wait();
992 ASSERT_FALSE(browser()->window()->IsFullscreen()); 902 ASSERT_FALSE(browser()->window()->IsFullscreen());
993 } 903 }
994 } 904 }
995 905
996 #if defined(OS_MACOSX) 906 #if defined(OS_MACOSX)
997 // http://crbug.com/100467 907 // http://crbug.com/100467
998 #define MAYBE_TestTabExitsItselfFromFullscreen \ 908 #define MAYBE_TestTabExitsItselfFromFullscreen \
999 FAILS_TestTabExitsItselfFromFullscreen 909 FAILS_TestTabExitsItselfFromFullscreen
1000 #else 910 #else
1001 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen 911 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen
1002 #endif 912 #endif
1003 913
1004 // Tests a tab exiting fullscreen will bring the browser out of fullscreen.
1005 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) { 914 IN_PROC_BROWSER_TEST_F(BrowserTest, MAYBE_TestTabExitsItselfFromFullscreen) {
1006 ASSERT_TRUE(test_server()->Start()); 915 ASSERT_TRUE(test_server()->Start());
1007 916
1008 AddTabAtIndex( 917 AddTabAtIndex(
1009 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 918 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
1010 919
1011 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 920 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
1012 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); 921
1013 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); 922 {
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 }
1014 } 939 }
1015 940
1016 // Tests entering fullscreen and then requesting mouse lock results in
1017 // buttons for the user, and that after confirming the buttons are dismissed.
1018 IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) { 941 IN_PROC_BROWSER_TEST_F(BrowserTest, TestFullscreenBubbleMouseLockState) {
1019 ASSERT_TRUE(test_server()->Start()); 942 ASSERT_TRUE(test_server()->Start());
1020 943
1021 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), 944 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
1022 content::PAGE_TRANSITION_TYPED); 945 content::PAGE_TRANSITION_TYPED);
1023 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), 946 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL),
1024 content::PAGE_TRANSITION_TYPED); 947 content::PAGE_TRANSITION_TYPED);
1025 948
1026 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 949 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
1027 950
1028 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); 951 {
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 }
1029 959
1030 // Request mouse lock and verify the bubble is waiting for user confirmation. 960 browser()->RequestToLockMouse(fullscreen_tab);
1031 RequestToLockMouse(fullscreen_tab); 961 FullscreenExitBubbleType type =
1032 ASSERT_TRUE(IsMouseLockPermissionRequested()); 962 browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
963 bool mouse_lock = false;
964 fullscreen_bubble::PermissionRequestedByType(type, NULL, &mouse_lock);
965 ASSERT_TRUE(mouse_lock);
1033 966
1034 // Accept mouse lock and verify bubble no longer shows confirmation buttons. 967 browser()->OnAcceptFullscreenPermission(fullscreen_tab->GetURL(), type);
1035 AcceptCurrentFullscreenOrMouseLockRequest(); 968 type = browser()->fullscreen_controller_->GetFullscreenExitBubbleType();
1036 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); 969 ASSERT_FALSE(fullscreen_bubble::ShowButtonsForType(type));
1037 }
1038
1039 // Tests mouse lock fails before fullscreen is entered.
1040 IN_PROC_BROWSER_TEST_F(BrowserTest, MouseLockThenFullscreen) {
1041 WebContents* tab = browser()->GetSelectedWebContents();
1042 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1043
1044 RequestToLockMouse(tab);
1045 ASSERT_FALSE(IsFullscreenBubbleDisplayed());
1046
1047 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1048 ASSERT_TRUE(IsFullscreenPermissionRequested());
1049 ASSERT_FALSE(IsMouseLockPermissionRequested());
1050 }
1051
1052 // Helper method to be called by multiple tests.
1053 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
1054 void BrowserTest::TestFullscreenMouseLockContentSettings() {
1055 GURL url = test_server()->GetURL("simple.html");
1056 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED);
1057 WebContents* tab = browser()->GetSelectedWebContents();
1058
1059 // Validate that going fullscreen for a URL defaults to asking permision.
1060 ASSERT_FALSE(IsFullscreenPermissionRequested());
1061 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1062 ASSERT_TRUE(IsFullscreenPermissionRequested());
1063 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false));
1064
1065 // Add content setting to ALLOW fullscreen.
1066 HostContentSettingsMap* settings_map =
1067 browser()->profile()->GetHostContentSettingsMap();
1068 ContentSettingsPattern pattern =
1069 ContentSettingsPattern::FromURL(url);
1070 settings_map->SetContentSetting(
1071 pattern, ContentSettingsPattern::Wildcard(),
1072 CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(),
1073 CONTENT_SETTING_ALLOW);
1074
1075 // Now, fullscreen should not prompt for permission.
1076 ASSERT_FALSE(IsFullscreenPermissionRequested());
1077 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1078 ASSERT_FALSE(IsFullscreenPermissionRequested());
1079
1080 // Leaving tab in fullscreen, now test mouse lock ALLOW:
1081
1082 // Validate that mouse lock defaults to asking permision.
1083 ASSERT_FALSE(IsMouseLockPermissionRequested());
1084 ASSERT_FALSE(IsMouseLockedOrPending());
1085 RequestToLockMouse(tab);
1086 ASSERT_TRUE(IsMouseLockPermissionRequested());
1087 ASSERT_TRUE(IsMouseLockedOrPending());
1088 LostMouseLock();
1089
1090 // Add content setting to ALLOW mouse lock.
1091 settings_map->SetContentSetting(
1092 pattern, ContentSettingsPattern::Wildcard(),
1093 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
1094 CONTENT_SETTING_ALLOW);
1095
1096 // Now, mouse lock should not prompt for permission.
1097 ASSERT_FALSE(IsMouseLockedOrPending());
1098 ASSERT_FALSE(IsMouseLockPermissionRequested());
1099 RequestToLockMouse(tab);
1100 ASSERT_TRUE(IsMouseLockedOrPending());
1101 ASSERT_FALSE(IsMouseLockPermissionRequested());
1102 LostMouseLock();
1103
1104 // Leaving tab in fullscreen, now test mouse lock BLOCK:
1105
1106 // Add content setting to BLOCK mouse lock.
1107 settings_map->SetContentSetting(
1108 pattern, ContentSettingsPattern::Wildcard(),
1109 CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
1110 CONTENT_SETTING_BLOCK);
1111
1112 // Now, mouse lock should not be pending.
1113 ASSERT_FALSE(IsMouseLockedOrPending());
1114 ASSERT_FALSE(IsMouseLockPermissionRequested());
1115 RequestToLockMouse(tab);
1116 ASSERT_FALSE(IsMouseLockedOrPending());
1117 ASSERT_FALSE(IsMouseLockPermissionRequested());
1118 }
1119
1120 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
1121 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenMouseLockContentSettings) {
1122 TestFullscreenMouseLockContentSettings();
1123 }
1124
1125 // Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK,
1126 // but with the browser initiated in fullscreen mode first.
1127 IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenMouseLockContentSettings) {
1128 // Enter browser fullscreen first.
1129 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
1130 TestFullscreenMouseLockContentSettings();
1131 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
1132 }
1133
1134 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser.
1135 IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenExit) {
1136 // Enter browser fullscreen.
1137 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
1138
1139 // Enter tab fullscreen.
1140 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
1141 content::PAGE_TRANSITION_TYPED);
1142 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
1143 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
1144
1145 // Exit browser fullscreen.
1146 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
1147 ASSERT_FALSE(browser()->window()->IsFullscreen());
1148 }
1149
1150 // Tests Browser Fullscreen remains active after Tab mode entered and exited.
1151 IN_PROC_BROWSER_TEST_F(BrowserTest, BrowserFullscreenAfterTabFSExit) {
1152 // Enter browser fullscreen.
1153 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
1154
1155 // Enter and then exit tab fullscreen.
1156 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL),
1157 content::PAGE_TRANSITION_TYPED);
1158 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
1159 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true));
1160 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false));
1161
1162 // Verify browser fullscreen still active.
1163 ASSERT_TRUE(IsFullscreenForBrowser());
1164 }
1165
1166 // Tests fullscreen entered without permision prompt for file:// urls.
1167 IN_PROC_BROWSER_TEST_F(BrowserTest, FullscreenFileURL) {
1168 ui_test_utils::NavigateToURL(browser(),
1169 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory),
1170 FilePath(kSimpleFile)));
1171 WebContents* tab = browser()->GetSelectedWebContents();
1172
1173 // Validate that going fullscreen for a file does not ask permision.
1174 ASSERT_FALSE(IsFullscreenPermissionRequested());
1175 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true));
1176 ASSERT_FALSE(IsFullscreenPermissionRequested());
1177 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false));
1178 } 970 }
1179 971
1180 #if defined(OS_MACOSX) 972 #if defined(OS_MACOSX)
1181 // http://crbug.com/100467 973 // http://crbug.com/100467
1182 IN_PROC_BROWSER_TEST_F( 974 IN_PROC_BROWSER_TEST_F(
1183 BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) { 975 BrowserTest, FAILS_TabEntersPresentationModeFromWindowed) {
1184 ASSERT_TRUE(test_server()->Start()); 976 ASSERT_TRUE(test_server()->Start());
1185 977
1186 AddTabAtIndex( 978 AddTabAtIndex(
1187 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); 979 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED);
1188 980
1189 WebContents* fullscreen_tab = browser()->GetSelectedWebContents(); 981 WebContents* fullscreen_tab = browser()->GetSelectedWebContents();
1190 982
1191 { 983 {
1192 FullscreenNotificationObserver fullscreen_observer; 984 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
985 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
986 content::NotificationService::AllSources());
1193 EXPECT_FALSE(browser()->window()->IsFullscreen()); 987 EXPECT_FALSE(browser()->window()->IsFullscreen());
1194 EXPECT_FALSE(browser()->window()->InPresentationMode()); 988 EXPECT_FALSE(browser()->window()->InPresentationMode());
1195 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); 989 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true);
1196 fullscreen_observer.Wait(); 990 fullscreen_observer.Wait();
1197 ASSERT_TRUE(browser()->window()->IsFullscreen()); 991 ASSERT_TRUE(browser()->window()->IsFullscreen());
1198 ASSERT_TRUE(browser()->window()->InPresentationMode()); 992 ASSERT_TRUE(browser()->window()->InPresentationMode());
1199 } 993 }
1200 994
1201 { 995 {
1202 FullscreenNotificationObserver fullscreen_observer; 996 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
997 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
998 content::NotificationService::AllSources());
1203 browser()->TogglePresentationMode(); 999 browser()->TogglePresentationMode();
1204 fullscreen_observer.Wait(); 1000 fullscreen_observer.Wait();
1205 ASSERT_FALSE(browser()->window()->IsFullscreen()); 1001 ASSERT_FALSE(browser()->window()->IsFullscreen());
1206 ASSERT_FALSE(browser()->window()->InPresentationMode()); 1002 ASSERT_FALSE(browser()->window()->InPresentationMode());
1207 } 1003 }
1208 1004
1209 if (base::mac::IsOSLionOrLater()) { 1005 if (base::mac::IsOSLionOrLater()) {
1210 // Test that tab fullscreen mode doesn't make presentation mode the default 1006 // Test that tab fullscreen mode doesn't make presentation mode the default
1211 // on Lion. 1007 // on Lion.
1212 FullscreenNotificationObserver fullscreen_observer; 1008 ui_test_utils::WindowedNotificationObserver fullscreen_observer(
1009 chrome::NOTIFICATION_FULLSCREEN_CHANGED,
1010 content::NotificationService::AllSources());
1213 browser()->ToggleFullscreenMode(); 1011 browser()->ToggleFullscreenMode();
1214 fullscreen_observer.Wait(); 1012 fullscreen_observer.Wait();
1215 ASSERT_TRUE(browser()->window()->IsFullscreen()); 1013 ASSERT_TRUE(browser()->window()->IsFullscreen());
1216 ASSERT_FALSE(browser()->window()->InPresentationMode()); 1014 ASSERT_FALSE(browser()->window()->InPresentationMode());
1217 } 1015 }
1218 } 1016 }
1219 #endif 1017 #endif
1220 1018
1221 // Chromeos defaults to restoring the last session, so this test isn't 1019 // Chromeos defaults to restoring the last session, so this test isn't
1222 // applicable. 1020 // applicable.
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 1539
1742 // The normal browser should now have four. 1540 // The normal browser should now have four.
1743 EXPECT_EQ(4, browser()->tab_count()); 1541 EXPECT_EQ(4, browser()->tab_count());
1744 1542
1745 // Close the additional browsers. 1543 // Close the additional browsers.
1746 popup_browser->CloseAllTabs(); 1544 popup_browser->CloseAllTabs();
1747 app_browser->CloseAllTabs(); 1545 app_browser->CloseAllTabs();
1748 app_popup_browser->CloseAllTabs(); 1546 app_popup_browser->CloseAllTabs();
1749 } 1547 }
1750 #endif 1548 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser.cc ('k') | chrome/browser/ui/browser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698