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 "base/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/utf_string_conversions.h" |
6 #include "chrome/browser/content_settings/host_content_settings_map.h" | 7 #include "chrome/browser/content_settings/host_content_settings_map.h" |
7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/browser/ui/fullscreen_controller_test.h" | 11 #include "chrome/browser/ui/fullscreen_controller_test.h" |
| 12 #include "chrome/test/base/ui_test_utils.h" |
| 13 #include "content/public/browser/render_view_host.h" |
| 14 #include "content/public/browser/web_contents.h" |
11 #include "content/public/common/url_constants.h" | 15 #include "content/public/common/url_constants.h" |
12 #if defined(OS_MACOSX) | 16 #if defined(OS_MACOSX) |
13 #include "base/mac/mac_util.h" | 17 #include "base/mac/mac_util.h" |
14 #endif | 18 #endif |
15 | 19 |
16 using content::WebContents; | 20 using content::WebContents; |
17 | 21 |
18 namespace { | 22 namespace { |
19 | 23 |
20 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); | 24 const FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html"); |
(...skipping 10 matching lines...) Expand all Loading... |
31 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen | 35 #define MAYBE_TestNewTabExitsFullscreen DISABLED_TestNewTabExitsFullscreen |
32 #else | 36 #else |
33 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen | 37 #define MAYBE_TestNewTabExitsFullscreen TestNewTabExitsFullscreen |
34 #endif | 38 #endif |
35 | 39 |
36 // Tests that while in fullscreen creating a new tab will exit fullscreen. | 40 // Tests that while in fullscreen creating a new tab will exit fullscreen. |
37 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 41 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
38 MAYBE_TestNewTabExitsFullscreen) { | 42 MAYBE_TestNewTabExitsFullscreen) { |
39 ASSERT_TRUE(test_server()->Start()); | 43 ASSERT_TRUE(test_server()->Start()); |
40 | 44 |
41 AddTabAtIndex( | 45 AddTabAtIndexAndWait( |
42 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 46 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
43 | 47 |
44 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 48 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
45 | 49 |
46 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 50 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
47 | 51 |
48 { | 52 { |
49 FullscreenNotificationObserver fullscreen_observer; | 53 FullscreenNotificationObserver fullscreen_observer; |
50 AddTabAtIndex( | 54 AddTabAtIndexAndWait( |
51 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 55 1, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
52 fullscreen_observer.Wait(); | 56 fullscreen_observer.Wait(); |
53 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 57 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
54 } | 58 } |
55 } | 59 } |
56 | 60 |
57 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) |
58 // http://crbug.com/100467 | 62 // http://crbug.com/100467 |
59 #define MAYBE_TestTabExitsItselfFromFullscreen \ | 63 #define MAYBE_TestTabExitsItselfFromFullscreen \ |
60 FAILS_TestTabExitsItselfFromFullscreen | 64 FAILS_TestTabExitsItselfFromFullscreen |
61 #else | 65 #else |
62 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen | 66 #define MAYBE_TestTabExitsItselfFromFullscreen TestTabExitsItselfFromFullscreen |
63 #endif | 67 #endif |
64 | 68 |
65 // Tests a tab exiting fullscreen will bring the browser out of fullscreen. | 69 // Tests a tab exiting fullscreen will bring the browser out of fullscreen. |
66 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 70 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
67 MAYBE_TestTabExitsItselfFromFullscreen) { | 71 MAYBE_TestTabExitsItselfFromFullscreen) { |
68 ASSERT_TRUE(test_server()->Start()); | 72 ASSERT_TRUE(test_server()->Start()); |
69 | 73 |
70 AddTabAtIndex( | 74 AddTabAtIndexAndWait( |
71 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 75 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
72 | 76 |
73 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 77 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
74 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 78 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
75 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); | 79 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); |
76 } | 80 } |
77 | 81 |
78 // Tests entering fullscreen and then requesting mouse lock results in | 82 // Tests entering fullscreen and then requesting mouse lock results in |
79 // buttons for the user, and that after confirming the buttons are dismissed. | 83 // buttons for the user, and that after confirming the buttons are dismissed. |
80 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 84 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
81 TestFullscreenBubbleMouseLockState) { | 85 TestFullscreenBubbleMouseLockState) { |
82 ASSERT_TRUE(test_server()->Start()); | 86 ASSERT_TRUE(test_server()->Start()); |
83 | 87 |
84 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 88 AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), |
85 content::PAGE_TRANSITION_TYPED); | 89 content::PAGE_TRANSITION_TYPED); |
86 AddTabAtIndex(1, GURL(chrome::kAboutBlankURL), | 90 AddTabAtIndexAndWait(1, GURL(chrome::kAboutBlankURL), |
87 content::PAGE_TRANSITION_TYPED); | 91 content::PAGE_TRANSITION_TYPED); |
88 | 92 |
89 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 93 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
90 | 94 |
91 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 95 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
92 | 96 |
93 // Request mouse lock and verify the bubble is waiting for user confirmation. | 97 // Request mouse lock and verify the bubble is waiting for user confirmation. |
94 RequestToLockMouse(fullscreen_tab, true, false); | 98 RequestToLockMouse(fullscreen_tab, true, false); |
95 ASSERT_TRUE(IsMouseLockPermissionRequested()); | 99 ASSERT_TRUE(IsMouseLockPermissionRequested()); |
96 | 100 |
97 // Accept mouse lock and verify bubble no longer shows confirmation buttons. | 101 // Accept mouse lock and verify bubble no longer shows confirmation buttons. |
98 AcceptCurrentFullscreenOrMouseLockRequest(); | 102 AcceptCurrentFullscreenOrMouseLockRequest(); |
99 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | 103 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); |
100 } | 104 } |
101 | 105 |
102 // Helper method to be called by multiple tests. | 106 // Helper method to be called by multiple tests. |
103 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. | 107 // Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK. |
104 void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() { | 108 void FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings() { |
105 GURL url = test_server()->GetURL("simple.html"); | 109 GURL url = test_server()->GetURL("simple.html"); |
106 AddTabAtIndex(0, url, content::PAGE_TRANSITION_TYPED); | 110 AddTabAtIndexAndWait(0, url, content::PAGE_TRANSITION_TYPED); |
107 WebContents* tab = browser()->GetActiveWebContents(); | 111 WebContents* tab = browser()->GetActiveWebContents(); |
108 | 112 |
109 // Validate that going fullscreen for a URL defaults to asking permision. | 113 // Validate that going fullscreen for a URL defaults to asking permision. |
110 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 114 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
111 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 115 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
112 ASSERT_TRUE(IsFullscreenPermissionRequested()); | 116 ASSERT_TRUE(IsFullscreenPermissionRequested()); |
113 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); | 117 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); |
114 | 118 |
115 // Add content setting to ALLOW fullscreen. | 119 // Add content setting to ALLOW fullscreen. |
116 HostContentSettingsMap* settings_map = | 120 HostContentSettingsMap* settings_map = |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 TestFullscreenMouseLockContentSettings(); | 180 TestFullscreenMouseLockContentSettings(); |
177 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); | 181 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); |
178 } | 182 } |
179 | 183 |
180 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. | 184 // Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser. |
181 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, BrowserFullscreenExit) { | 185 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, BrowserFullscreenExit) { |
182 // Enter browser fullscreen. | 186 // Enter browser fullscreen. |
183 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); | 187 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
184 | 188 |
185 // Enter tab fullscreen. | 189 // Enter tab fullscreen. |
186 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 190 AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), |
187 content::PAGE_TRANSITION_TYPED); | 191 content::PAGE_TRANSITION_TYPED); |
188 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 192 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
189 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 193 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
190 | 194 |
191 // Exit browser fullscreen. | 195 // Exit browser fullscreen. |
192 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); | 196 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false)); |
193 ASSERT_FALSE(browser()->window()->IsFullscreen()); | 197 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
194 } | 198 } |
195 | 199 |
196 // Tests Browser Fullscreen remains active after Tab mode entered and exited. | 200 // Tests Browser Fullscreen remains active after Tab mode entered and exited. |
197 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, | 201 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
198 BrowserFullscreenAfterTabFSExit) { | 202 BrowserFullscreenAfterTabFSExit) { |
199 // Enter browser fullscreen. | 203 // Enter browser fullscreen. |
200 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); | 204 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
201 | 205 |
202 // Enter and then exit tab fullscreen. | 206 // Enter and then exit tab fullscreen. |
203 AddTabAtIndex(0, GURL(chrome::kAboutBlankURL), | 207 AddTabAtIndexAndWait(0, GURL(chrome::kAboutBlankURL), |
204 content::PAGE_TRANSITION_TYPED); | 208 content::PAGE_TRANSITION_TYPED); |
205 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 209 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
206 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); | 210 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
207 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); | 211 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, false)); |
208 | 212 |
209 // Verify browser fullscreen still active. | 213 // Verify browser fullscreen still active. |
210 ASSERT_TRUE(IsFullscreenForBrowser()); | 214 ASSERT_TRUE(IsFullscreenForBrowser()); |
211 } | 215 } |
212 | 216 |
213 // Tests fullscreen entered without permision prompt for file:// urls. | 217 // Tests fullscreen entered without permision prompt for file:// urls. |
214 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenFileURL) { | 218 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, FullscreenFileURL) { |
215 ui_test_utils::NavigateToURL(browser(), | 219 ui_test_utils::NavigateToURL(browser(), |
216 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), | 220 ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
217 FilePath(kSimpleFile))); | 221 FilePath(kSimpleFile))); |
218 WebContents* tab = browser()->GetActiveWebContents(); | 222 WebContents* tab = browser()->GetActiveWebContents(); |
219 | 223 |
220 // Validate that going fullscreen for a file does not ask permision. | 224 // Validate that going fullscreen for a file does not ask permision. |
221 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 225 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
222 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); | 226 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, true)); |
223 ASSERT_FALSE(IsFullscreenPermissionRequested()); | 227 ASSERT_FALSE(IsFullscreenPermissionRequested()); |
224 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); | 228 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(tab, false)); |
225 } | 229 } |
226 | 230 |
| 231 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 232 TestTabExitsFullscreenOnNavigation) { |
| 233 ASSERT_TRUE(test_server()->Start()); |
| 234 |
| 235 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 236 |
| 237 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 238 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 239 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
| 240 |
| 241 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 242 } |
| 243 |
| 244 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 245 TestTabExitsFullscreenOnGoBack) { |
| 246 ASSERT_TRUE(test_server()->Start()); |
| 247 |
| 248 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 249 |
| 250 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 251 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
| 252 |
| 253 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 254 |
| 255 GoBack(); |
| 256 |
| 257 ASSERT_FALSE(browser()->window()->IsFullscreen()); |
| 258 } |
| 259 |
| 260 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 261 TestTabDoesntExitFullscreenOnSubFrameNavigation) { |
| 262 ASSERT_TRUE(test_server()->Start()); |
| 263 |
| 264 GURL url(ui_test_utils::GetTestUrl(FilePath(FilePath::kCurrentDirectory), |
| 265 FilePath(kSimpleFile))); |
| 266 GURL url_with_fragment(url.spec() + "#fragment"); |
| 267 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 268 |
| 269 ui_test_utils::NavigateToURL(browser(), url); |
| 270 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 271 ui_test_utils::NavigateToURL(browser(), url_with_fragment); |
| 272 ASSERT_TRUE(IsFullscreenForTabOrPending()); |
| 273 } |
| 274 |
| 275 IN_PROC_BROWSER_TEST_F(FullscreenControllerTest, |
| 276 TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks)
{ |
| 277 ASSERT_TRUE(test_server()->Start()); |
| 278 |
| 279 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 280 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); |
| 281 |
| 282 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
| 283 |
| 284 ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true)); |
| 285 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(fullscreen_tab, true)); |
| 286 |
| 287 GoBack(); |
| 288 |
| 289 ASSERT_TRUE(IsFullscreenForBrowser()); |
| 290 ASSERT_FALSE(IsFullscreenForTabOrPending()); |
| 291 } |
| 292 |
227 #if defined(OS_MACOSX) | 293 #if defined(OS_MACOSX) |
228 // http://crbug.com/100467 | 294 // http://crbug.com/100467 |
229 IN_PROC_BROWSER_TEST_F( | 295 IN_PROC_BROWSER_TEST_F( |
230 FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) { | 296 FullscreenControllerTest, FAILS_TabEntersPresentationModeFromWindowed) { |
231 ASSERT_TRUE(test_server()->Start()); | 297 ASSERT_TRUE(test_server()->Start()); |
232 | 298 |
233 AddTabAtIndex( | 299 AddTabAtIndexAndWait( |
234 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); | 300 0, GURL(chrome::kAboutBlankURL), content::PAGE_TRANSITION_TYPED); |
235 | 301 |
236 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); | 302 WebContents* fullscreen_tab = browser()->GetActiveWebContents(); |
237 | 303 |
238 { | 304 { |
239 FullscreenNotificationObserver fullscreen_observer; | 305 FullscreenNotificationObserver fullscreen_observer; |
240 EXPECT_FALSE(browser()->window()->IsFullscreen()); | 306 EXPECT_FALSE(browser()->window()->IsFullscreen()); |
241 EXPECT_FALSE(browser()->window()->InPresentationMode()); | 307 EXPECT_FALSE(browser()->window()->InPresentationMode()); |
242 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); | 308 browser()->ToggleFullscreenModeForTab(fullscreen_tab, true); |
243 fullscreen_observer.Wait(); | 309 fullscreen_observer.Wait(); |
(...skipping 14 matching lines...) Expand all Loading... |
258 // on Lion. | 324 // on Lion. |
259 FullscreenNotificationObserver fullscreen_observer; | 325 FullscreenNotificationObserver fullscreen_observer; |
260 browser()->ToggleFullscreenMode(); | 326 browser()->ToggleFullscreenMode(); |
261 fullscreen_observer.Wait(); | 327 fullscreen_observer.Wait(); |
262 ASSERT_TRUE(browser()->window()->IsFullscreen()); | 328 ASSERT_TRUE(browser()->window()->IsFullscreen()); |
263 ASSERT_FALSE(browser()->window()->InPresentationMode()); | 329 ASSERT_FALSE(browser()->window()->InPresentationMode()); |
264 } | 330 } |
265 } | 331 } |
266 #endif | 332 #endif |
267 | 333 |
OLD | NEW |