| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/ui/browser.h" | |
| 6 #include "chrome/browser/ui/browser_window.h" | |
| 7 #include "chrome/browser/ui/fullscreen_controller_test.h" | |
| 8 #include "content/public/browser/render_view_host.h" | |
| 9 #include "content/public/browser/render_widget_host_view.h" | |
| 10 #include "content/public/browser/web_contents.h" | |
| 11 | |
| 12 using content::WebContents; | |
| 13 | |
| 14 class FullscreenControllerInteractiveTest | |
| 15 : public FullscreenControllerTest { | |
| 16 protected: | |
| 17 // IsMouseLocked verifies that the FullscreenController state believes | |
| 18 // the mouse is locked. This is possible only for tests that initiate | |
| 19 // mouse lock from a renderer process, and uses logic that tests that the | |
| 20 // browser has focus. Thus, this can only be used in interactive ui tests | |
| 21 // and not on sharded tests. | |
| 22 bool IsMouseLocked() { | |
| 23 // Verify that IsMouseLocked is consistent between the | |
| 24 // Fullscreen Controller and the Render View Host View. | |
| 25 EXPECT_TRUE(browser()->IsMouseLocked() == | |
| 26 browser()->GetActiveWebContents()-> | |
| 27 GetRenderViewHost()->GetView()->IsMouseLocked()); | |
| 28 return browser()->IsMouseLocked(); | |
| 29 } | |
| 30 }; | |
| 31 | |
| 32 // Tests mouse lock can be escaped with ESC key. | |
| 33 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, EscapingMouseLock) { | |
| 34 ASSERT_TRUE(test_server()->Start()); | |
| 35 ui_test_utils::NavigateToURL(browser(), | |
| 36 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 37 | |
| 38 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 39 | |
| 40 // Request to lock the mouse. | |
| 41 { | |
| 42 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 43 browser(), ui::VKEY_1, false, false, false, false, | |
| 44 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 45 content::NotificationService::AllSources())); | |
| 46 } | |
| 47 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 48 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 49 | |
| 50 // Escape, no prompts should remain. | |
| 51 SendEscapeToFullscreenController(); | |
| 52 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 53 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 54 | |
| 55 // Request to lock the mouse. | |
| 56 { | |
| 57 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 58 browser(), ui::VKEY_1, false, false, false, false, | |
| 59 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 60 content::NotificationService::AllSources())); | |
| 61 } | |
| 62 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 63 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 64 | |
| 65 // Accept mouse lock, confirm it and that there is no prompt. | |
| 66 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 67 ASSERT_TRUE(IsMouseLocked()); | |
| 68 ASSERT_FALSE(IsFullscreenForTabOrPending()); | |
| 69 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 70 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 71 | |
| 72 // Escape, confirm we are out of mouse lock with no prompts. | |
| 73 SendEscapeToFullscreenController(); | |
| 74 ASSERT_FALSE(IsMouseLocked()); | |
| 75 ASSERT_FALSE(IsFullscreenForTabOrPending()); | |
| 76 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 77 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 78 } | |
| 79 | |
| 80 // Times out sometimes on Linux. http://crbug.com/135115 | |
| 81 #if defined(OS_LINUX) | |
| 82 #define MAYBE_EscapingMouseLockAndFullscreen \ | |
| 83 DISABLED_EscapingMouseLockAndFullscreen | |
| 84 #else | |
| 85 #define MAYBE_EscapingMouseLockAndFullscreen EscapingMouseLockAndFullscreen | |
| 86 #endif | |
| 87 // Tests mouse lock and fullscreen modes can be escaped with ESC key. | |
| 88 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 89 MAYBE_EscapingMouseLockAndFullscreen) { | |
| 90 ASSERT_TRUE(test_server()->Start()); | |
| 91 ui_test_utils::NavigateToURL(browser(), | |
| 92 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 93 | |
| 94 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 95 | |
| 96 // Request to lock the mouse and enter fullscreen. | |
| 97 { | |
| 98 FullscreenNotificationObserver fullscreen_observer; | |
| 99 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 100 browser(), ui::VKEY_B, false, true, false, false, | |
| 101 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 102 content::NotificationService::AllSources())); | |
| 103 fullscreen_observer.Wait(); | |
| 104 } | |
| 105 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 106 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 107 | |
| 108 // Escape, no prompts should remain. | |
| 109 { | |
| 110 FullscreenNotificationObserver fullscreen_observer; | |
| 111 SendEscapeToFullscreenController(); | |
| 112 fullscreen_observer.Wait(); | |
| 113 } | |
| 114 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 115 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 116 | |
| 117 // Request to lock the mouse and enter fullscreen. | |
| 118 { | |
| 119 FullscreenNotificationObserver fullscreen_observer; | |
| 120 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 121 browser(), ui::VKEY_B, false, true, false, false, | |
| 122 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 123 content::NotificationService::AllSources())); | |
| 124 fullscreen_observer.Wait(); | |
| 125 } | |
| 126 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 127 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 128 | |
| 129 // Accept both, confirm mouse lock and fullscreen and no prompts. | |
| 130 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 131 ASSERT_TRUE(IsMouseLocked()); | |
| 132 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
| 133 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 134 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 135 | |
| 136 // Escape, confirm we are out of mouse lock and fullscreen with no prompts. | |
| 137 { | |
| 138 FullscreenNotificationObserver fullscreen_observer; | |
| 139 SendEscapeToFullscreenController(); | |
| 140 fullscreen_observer.Wait(); | |
| 141 } | |
| 142 ASSERT_FALSE(IsMouseLocked()); | |
| 143 ASSERT_FALSE(IsFullscreenForTabOrPending()); | |
| 144 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 145 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 146 } | |
| 147 | |
| 148 // Tests mouse lock then fullscreen. | |
| 149 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 150 MouseLockThenFullscreen) { | |
| 151 ASSERT_TRUE(test_server()->Start()); | |
| 152 ui_test_utils::NavigateToURL(browser(), | |
| 153 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 154 | |
| 155 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 156 | |
| 157 // Lock the mouse without a user gesture, expect no response. | |
| 158 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 159 browser(), ui::VKEY_D, false, false, false, false, | |
| 160 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 161 content::NotificationService::AllSources())); | |
| 162 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 163 ASSERT_FALSE(IsMouseLocked()); | |
| 164 | |
| 165 // Lock the mouse with a user gesture. | |
| 166 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 167 browser(), ui::VKEY_1, false, false, false, false, | |
| 168 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 169 content::NotificationService::AllSources())); | |
| 170 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 171 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 172 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 173 ASSERT_FALSE(IsMouseLocked()); | |
| 174 | |
| 175 // Accept mouse lock. | |
| 176 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 177 ASSERT_TRUE(IsMouseLocked()); | |
| 178 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | |
| 179 | |
| 180 // Enter fullscreen mode, mouse lock should be dropped to present buttons. | |
| 181 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true)); | |
| 182 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 183 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 184 ASSERT_FALSE(IsMouseLocked()); | |
| 185 | |
| 186 // Request mouse lock also, expect fullscreen and mouse lock buttons. | |
| 187 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 188 browser(), ui::VKEY_1, false, false, false, false, | |
| 189 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 190 content::NotificationService::AllSources())); | |
| 191 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 192 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 193 ASSERT_FALSE(IsMouseLocked()); | |
| 194 | |
| 195 // Accept fullscreen and mouse lock. | |
| 196 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 197 ASSERT_TRUE(IsMouseLocked()); | |
| 198 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
| 199 ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons()); | |
| 200 } | |
| 201 | |
| 202 // Times out sometimes on Linux. http://crbug.com/135115 | |
| 203 #if defined(OS_LINUX) | |
| 204 #define MAYBE_MouseLockAndFullscreen DISABLED_MouseLockAndFullscreen | |
| 205 #else | |
| 206 #define MAYBE_MouseLockAndFullscreen MouseLockAndFullscreen | |
| 207 #endif | |
| 208 // Tests mouse lock then fullscreen in same request. | |
| 209 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 210 MAYBE_MouseLockAndFullscreen) { | |
| 211 ASSERT_TRUE(test_server()->Start()); | |
| 212 ui_test_utils::NavigateToURL(browser(), | |
| 213 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 214 | |
| 215 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 216 | |
| 217 // Request to lock the mouse and enter fullscreen. | |
| 218 { | |
| 219 FullscreenNotificationObserver fullscreen_observer; | |
| 220 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 221 browser(), ui::VKEY_B, false, true, false, false, | |
| 222 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 223 content::NotificationService::AllSources())); | |
| 224 fullscreen_observer.Wait(); | |
| 225 } | |
| 226 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 227 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 228 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 229 ASSERT_FALSE(IsMouseLocked()); | |
| 230 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
| 231 | |
| 232 // Deny both first, to make sure we can. | |
| 233 { | |
| 234 FullscreenNotificationObserver fullscreen_observer; | |
| 235 DenyCurrentFullscreenOrMouseLockRequest(); | |
| 236 fullscreen_observer.Wait(); | |
| 237 } | |
| 238 ASSERT_FALSE(IsMouseLocked()); | |
| 239 ASSERT_FALSE(IsFullscreenForTabOrPending()); | |
| 240 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 241 | |
| 242 // Request to lock the mouse and enter fullscreen. | |
| 243 { | |
| 244 FullscreenNotificationObserver fullscreen_observer; | |
| 245 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 246 browser(), ui::VKEY_B, false, true, false, false, | |
| 247 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 248 content::NotificationService::AllSources())); | |
| 249 fullscreen_observer.Wait(); | |
| 250 } | |
| 251 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 252 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 253 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 254 ASSERT_FALSE(IsMouseLocked()); | |
| 255 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
| 256 | |
| 257 // Accept both, confirm they are enabled and there is no prompt. | |
| 258 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 259 ASSERT_TRUE(IsMouseLocked()); | |
| 260 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
| 261 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 262 } | |
| 263 | |
| 264 // Tests mouse lock can be exited and re-entered by an application silently | |
| 265 // with no UI distraction for users. | |
| 266 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 267 MouseLockSilentAfterTargetUnlock) { | |
| 268 ASSERT_TRUE(test_server()->Start()); | |
| 269 ui_test_utils::NavigateToURL(browser(), | |
| 270 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 271 | |
| 272 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 273 | |
| 274 // Lock the mouse with a user gesture. | |
| 275 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 276 browser(), ui::VKEY_1, false, false, false, false, | |
| 277 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 278 content::NotificationService::AllSources())); | |
| 279 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 280 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 281 ASSERT_FALSE(IsMouseLocked()); | |
| 282 | |
| 283 // Accept mouse lock. | |
| 284 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 285 ASSERT_TRUE(IsMouseLocked()); | |
| 286 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 287 | |
| 288 // Unlock the mouse from target, make sure it's unlocked. | |
| 289 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 290 browser(), ui::VKEY_U, false, false, false, false, | |
| 291 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 292 content::NotificationService::AllSources())); | |
| 293 ASSERT_FALSE(IsMouseLocked()); | |
| 294 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 295 | |
| 296 // Lock mouse again, make sure it works with no bubble. | |
| 297 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 298 browser(), ui::VKEY_1, false, false, false, false, | |
| 299 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 300 content::NotificationService::AllSources())); | |
| 301 ASSERT_TRUE(IsMouseLocked()); | |
| 302 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 303 | |
| 304 // Unlock the mouse again by target. | |
| 305 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 306 browser(), ui::VKEY_U, false, false, false, false, | |
| 307 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 308 content::NotificationService::AllSources())); | |
| 309 ASSERT_FALSE(IsMouseLocked()); | |
| 310 | |
| 311 // Lock from target, not user gesture, make sure it works. | |
| 312 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 313 browser(), ui::VKEY_D, false, false, false, false, | |
| 314 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 315 content::NotificationService::AllSources())); | |
| 316 ASSERT_TRUE(IsMouseLocked()); | |
| 317 ASSERT_FALSE(IsFullscreenBubbleDisplayed()); | |
| 318 | |
| 319 // Unlock by escape. | |
| 320 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 321 browser(), ui::VKEY_ESCAPE, false, false, false, false, | |
| 322 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 323 content::NotificationService::AllSources())); | |
| 324 ASSERT_FALSE(IsMouseLocked()); | |
| 325 | |
| 326 // Lock the mouse with a user gesture, make sure we see bubble again. | |
| 327 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 328 browser(), ui::VKEY_1, false, false, false, false, | |
| 329 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 330 content::NotificationService::AllSources())); | |
| 331 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 332 ASSERT_TRUE(IsMouseLocked()); | |
| 333 } | |
| 334 | |
| 335 // Tests mouse lock is exited on page navigation. | |
| 336 // (Similar to fullscreen version in FullscreenControllerTest) | |
| 337 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 338 TestTabExitsMouseLockOnNavigation) { | |
| 339 ASSERT_TRUE(test_server()->Start()); | |
| 340 ui_test_utils::NavigateToURL(browser(), | |
| 341 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 342 | |
| 343 // Lock the mouse with a user gesture. | |
| 344 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 345 browser(), ui::VKEY_1, false, false, false, false, | |
| 346 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 347 content::NotificationService::AllSources())); | |
| 348 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 349 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 350 ASSERT_FALSE(IsMouseLocked()); | |
| 351 | |
| 352 // Accept mouse lock. | |
| 353 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 354 ASSERT_TRUE(IsMouseLocked()); | |
| 355 | |
| 356 ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab")); | |
| 357 | |
| 358 ASSERT_FALSE(IsMouseLocked()); | |
| 359 } | |
| 360 | |
| 361 // Tests mouse lock is exited when navigating back. | |
| 362 // (Similar to fullscreen version in FullscreenControllerTest) | |
| 363 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 364 TestTabExitsMouseLockOnGoBack) { | |
| 365 ASSERT_TRUE(test_server()->Start()); | |
| 366 | |
| 367 // Navigate twice to provide a place to go back to. | |
| 368 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | |
| 369 ui_test_utils::NavigateToURL(browser(), | |
| 370 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 371 | |
| 372 // Lock the mouse with a user gesture. | |
| 373 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 374 browser(), ui::VKEY_1, false, false, false, false, | |
| 375 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 376 content::NotificationService::AllSources())); | |
| 377 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 378 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 379 ASSERT_FALSE(IsMouseLocked()); | |
| 380 | |
| 381 // Accept mouse lock. | |
| 382 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 383 ASSERT_TRUE(IsMouseLocked()); | |
| 384 | |
| 385 GoBack(); | |
| 386 | |
| 387 ASSERT_FALSE(IsMouseLocked()); | |
| 388 } | |
| 389 | |
| 390 // Tests mouse lock is not exited on sub frame navigation. | |
| 391 // (Similar to fullscreen version in FullscreenControllerTest) | |
| 392 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 393 TestTabDoesntExitMouseLockOnSubFrameNavigation) { | |
| 394 ASSERT_TRUE(test_server()->Start()); | |
| 395 | |
| 396 // Create URLs for test page and test page with #fragment. | |
| 397 GURL url(test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 398 GURL url_with_fragment(url.spec() + "#fragment"); | |
| 399 | |
| 400 // Navigate to test page. | |
| 401 ui_test_utils::NavigateToURL(browser(), url); | |
| 402 | |
| 403 // Lock the mouse with a user gesture. | |
| 404 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 405 browser(), ui::VKEY_1, false, false, false, false, | |
| 406 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 407 content::NotificationService::AllSources())); | |
| 408 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 409 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 410 ASSERT_FALSE(IsMouseLocked()); | |
| 411 | |
| 412 // Accept mouse lock. | |
| 413 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 414 ASSERT_TRUE(IsMouseLocked()); | |
| 415 | |
| 416 // Navigate to url with fragment. Mouse lock should persist. | |
| 417 ui_test_utils::NavigateToURL(browser(), url_with_fragment); | |
| 418 ASSERT_TRUE(IsMouseLocked()); | |
| 419 } | |
| 420 | |
| 421 // Tests Mouse Lock and Fullscreen are exited upon reload. | |
| 422 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 423 ReloadExitsMouseLockAndFullscreen) { | |
| 424 ASSERT_TRUE(test_server()->Start()); | |
| 425 ui_test_utils::NavigateToURL(browser(), | |
| 426 test_server()->GetURL(kFullscreenMouseLockHTML)); | |
| 427 | |
| 428 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 429 | |
| 430 // Request mouse lock. | |
| 431 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 432 browser(), ui::VKEY_1, false, false, false, false, | |
| 433 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 434 content::NotificationService::AllSources())); | |
| 435 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 436 | |
| 437 // Reload. Mouse lock request should be cleared. | |
| 438 { | |
| 439 MouseLockNotificationObserver mouselock_observer; | |
| 440 Reload(); | |
| 441 mouselock_observer.Wait(); | |
| 442 ASSERT_FALSE(IsMouseLockPermissionRequested()); | |
| 443 } | |
| 444 | |
| 445 // Request mouse lock. | |
| 446 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 447 browser(), ui::VKEY_1, false, false, false, false, | |
| 448 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 449 content::NotificationService::AllSources())); | |
| 450 ASSERT_TRUE(IsMouseLockPermissionRequested()); | |
| 451 | |
| 452 // Accept mouse lock. | |
| 453 AcceptCurrentFullscreenOrMouseLockRequest(); | |
| 454 ASSERT_TRUE(IsMouseLocked()); | |
| 455 ASSERT_TRUE(IsFullscreenBubbleDisplayed()); | |
| 456 | |
| 457 // Reload. Mouse should be unlocked. | |
| 458 { | |
| 459 MouseLockNotificationObserver mouselock_observer; | |
| 460 Reload(); | |
| 461 mouselock_observer.Wait(); | |
| 462 ASSERT_FALSE(IsMouseLocked()); | |
| 463 } | |
| 464 | |
| 465 // Request to lock the mouse and enter fullscreen. | |
| 466 { | |
| 467 FullscreenNotificationObserver fullscreen_observer; | |
| 468 ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait( | |
| 469 browser(), ui::VKEY_B, false, true, false, false, | |
| 470 chrome::NOTIFICATION_MOUSE_LOCK_CHANGED, | |
| 471 content::NotificationService::AllSources())); | |
| 472 fullscreen_observer.Wait(); | |
| 473 } | |
| 474 | |
| 475 // We are fullscreen. | |
| 476 ASSERT_TRUE(IsFullscreenForTabOrPending()); | |
| 477 | |
| 478 // Reload. Mouse should be unlocked and fullscreen exited. | |
| 479 { | |
| 480 FullscreenNotificationObserver fullscreen_observer; | |
| 481 Reload(); | |
| 482 fullscreen_observer.Wait(); | |
| 483 ASSERT_FALSE(IsMouseLocked()); | |
| 484 ASSERT_FALSE(IsFullscreenForTabOrPending()); | |
| 485 } | |
| 486 } | |
| 487 | |
| 488 // Fails sometimes on Linux. http://crbug.com/135115 | |
| 489 #if defined(OS_LINUX) | |
| 490 #define MAYBE_ToggleFullscreenModeForTab DISABLED_ToggleFullscreenModeForTab | |
| 491 #else | |
| 492 #define MAYBE_ToggleFullscreenModeForTab ToggleFullscreenModeForTab | |
| 493 #endif | |
| 494 // Tests ToggleFullscreenModeForTab always causes window to change. | |
| 495 IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, | |
| 496 MAYBE_ToggleFullscreenModeForTab) { | |
| 497 // Most fullscreen tests run sharded in fullscreen_controller_browsertest.cc | |
| 498 // but flakiness required a while loop in | |
| 499 // FullscreenControllerTest::ToggleTabFullscreen. This test verifies that | |
| 500 // when running serially there is no flakiness. | |
| 501 // This test reproduces the same flow as | |
| 502 // FullscreenControllerBrowserTest::TestFullscreenMouseLockContentSettings. | |
| 503 // http://crbug.com/133831 | |
| 504 | |
| 505 GURL url = test_server()->GetURL("simple.html"); | |
| 506 AddTabAtIndexAndWait(0, url, content::PAGE_TRANSITION_TYPED); | |
| 507 | |
| 508 // Validate that going fullscreen for a URL defaults to asking permision. | |
| 509 ASSERT_FALSE(IsFullscreenPermissionRequested()); | |
| 510 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreenNoRetries(true)); | |
| 511 ASSERT_TRUE(IsFullscreenPermissionRequested()); | |
| 512 ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreenNoRetries(false)); | |
| 513 } | |
| OLD | NEW |