1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "build/build_config.h"
#include "chrome/browser/fullscreen.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/exclusive_access/fullscreen_controller_test.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "chrome/test/base/interactive_test_utils.h"
#include "chrome/test/base/ui_test_utils.h"
#include "components/content_settings/core/browser/host_content_settings_map.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/url_constants.h"
using url::kAboutBlankURL;
using content::WebContents;
using ui::PAGE_TRANSITION_TYPED;
namespace {
const base::FilePath::CharType* kSimpleFile = FILE_PATH_LITERAL("simple.html");
} // namespace
class FullscreenControllerInteractiveTest
: public FullscreenControllerTest {
protected:
// Tests that actually make the browser fullscreen have been flaky when
// run sharded, and so are restricted here to interactive ui tests.
void ToggleTabFullscreen(bool enter_fullscreen);
void ToggleTabFullscreenNoRetries(bool enter_fullscreen);
void ToggleBrowserFullscreen(bool enter_fullscreen);
// IsMouseLocked verifies that the FullscreenController state believes
// the mouse is locked. This is possible only for tests that initiate
// mouse lock from a renderer process, and uses logic that tests that the
// browser has focus. Thus, this can only be used in interactive ui tests
// and not on sharded tests.
bool IsMouseLocked() {
// Verify that IsMouseLocked is consistent between the
// Fullscreen Controller and the Render View Host View.
EXPECT_TRUE(browser()->IsMouseLocked() ==
browser()->tab_strip_model()->GetActiveWebContents()->
GetRenderViewHost()->GetView()->IsMouseLocked());
return browser()->IsMouseLocked();
}
void TestFullscreenMouseLockContentSettings();
private:
void ToggleTabFullscreen_Internal(bool enter_fullscreen,
bool retry_until_success);
};
void FullscreenControllerInteractiveTest::ToggleTabFullscreen(
bool enter_fullscreen) {
ToggleTabFullscreen_Internal(enter_fullscreen, true);
}
// |ToggleTabFullscreen| should not need to tolerate the transition failing.
// Most fullscreen tests run sharded in fullscreen_controller_browsertest.cc
// and some flakiness has occurred when calling |ToggleTabFullscreen|, so that
// method has been made robust by retrying if the transition fails.
// The root cause of that flakiness should still be tracked down, see
// http://crbug.com/133831. In the mean time, this method
// allows a fullscreen_controller_interactive_browsertest.cc test to verify
// that when running serially there is no flakiness in the transition.
void FullscreenControllerInteractiveTest::ToggleTabFullscreenNoRetries(
bool enter_fullscreen) {
ToggleTabFullscreen_Internal(enter_fullscreen, false);
}
void FullscreenControllerInteractiveTest::ToggleBrowserFullscreen(
bool enter_fullscreen) {
ASSERT_EQ(browser()->window()->IsFullscreen(), !enter_fullscreen);
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
ASSERT_EQ(IsFullscreenForBrowser(), enter_fullscreen);
}
// Helper method to be called by multiple tests.
// Tests Fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
void
FullscreenControllerInteractiveTest::TestFullscreenMouseLockContentSettings() {
GURL url = test_server()->GetURL("simple.html");
AddTabAtIndex(0, url, PAGE_TRANSITION_TYPED);
// Validate that going fullscreen for a URL defaults to asking permision.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
// Add content setting to ALLOW fullscreen.
HostContentSettingsMap* settings_map =
browser()->profile()->GetHostContentSettingsMap();
ContentSettingsPattern pattern =
ContentSettingsPattern::FromURL(url);
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_FULLSCREEN, std::string(),
CONTENT_SETTING_ALLOW);
// Now, fullscreen should not prompt for permission.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_FALSE(IsFullscreenPermissionRequested());
// Leaving tab in fullscreen, now test mouse lock ALLOW:
// Validate that mouse lock defaults to asking permision.
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_TRUE(IsMouseLockPermissionRequested());
LostMouseLock();
// Add content setting to ALLOW mouse lock.
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
CONTENT_SETTING_ALLOW);
// Now, mouse lock should not prompt for permission.
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_FALSE(IsMouseLockPermissionRequested());
LostMouseLock();
// Leaving tab in fullscreen, now test mouse lock BLOCK:
// Add content setting to BLOCK mouse lock.
settings_map->SetContentSetting(
pattern, ContentSettingsPattern::Wildcard(),
CONTENT_SETTINGS_TYPE_MOUSELOCK, std::string(),
CONTENT_SETTING_BLOCK);
// Now, mouse lock should not be pending.
ASSERT_FALSE(IsMouseLockPermissionRequested());
RequestToLockMouse(true, false);
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
void FullscreenControllerInteractiveTest::ToggleTabFullscreen_Internal(
bool enter_fullscreen, bool retry_until_success) {
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
do {
FullscreenNotificationObserver fullscreen_observer;
browser()->ToggleFullscreenModeForTab(tab, enter_fullscreen);
fullscreen_observer.Wait();
// Repeat ToggleFullscreenModeForTab until the correct state is entered.
// This addresses flakiness on test bots running many fullscreen
// tests in parallel.
} while (retry_until_success &&
!IsFullscreenForBrowser() &&
browser()->window()->IsFullscreen() != enter_fullscreen);
ASSERT_EQ(IsWindowFullscreenForTabOrPending(), enter_fullscreen);
if (!IsFullscreenForBrowser())
ASSERT_EQ(browser()->window()->IsFullscreen(), enter_fullscreen);
}
// Tests ///////////////////////////////////////////////////////////////////////
// Tests that while in fullscreen creating a new tab will exit fullscreen.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestNewTabExitsFullscreen) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
{
FullscreenNotificationObserver fullscreen_observer;
AddTabAtIndex(1, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
fullscreen_observer.Wait();
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
}
// Tests a tab exiting fullscreen will bring the browser out of fullscreen.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsItselfFromFullscreen) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
}
// Tests entering fullscreen and then requesting mouse lock results in
// buttons for the user, and that after confirming the buttons are dismissed.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestFullscreenBubbleMouseLockState) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
AddTabAtIndex(1, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
// Request mouse lock and verify the bubble is waiting for user confirmation.
RequestToLockMouse(true, false);
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Accept mouse lock and verify bubble no longer shows confirmation buttons.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
}
// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK.
// http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_FullscreenMouseLockContentSettings) {
TestFullscreenMouseLockContentSettings();
}
// Tests fullscreen and Mouse Lock with varying content settings ALLOW & BLOCK,
// but with the browser initiated in fullscreen mode first.
// Test is flaky: http://crbug.com/103912, http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_BrowserFullscreenMouseLockContentSettings) {
// Enter browser fullscreen first.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
TestFullscreenMouseLockContentSettings();
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
}
// Tests Fullscreen entered in Browser, then Tab mode, then exited via Browser.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_BrowserFullscreenExit) {
// Enter browser fullscreen.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
// Enter tab fullscreen.
AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
// Exit browser fullscreen.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(false));
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
// Tests Browser Fullscreen remains active after Tab mode entered and exited.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_BrowserFullscreenAfterTabFSExit) {
// Enter browser fullscreen.
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
// Enter and then exit tab fullscreen.
AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
// Verify browser fullscreen still active.
ASSERT_TRUE(IsFullscreenForBrowser());
}
// Tests fullscreen entered without permision prompt for file:// urls.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_FullscreenFileURL) {
ui_test_utils::NavigateToURL(
browser(), ui_test_utils::GetTestUrl(
base::FilePath(base::FilePath::kCurrentDirectory),
base::FilePath(kSimpleFile)));
// Validate that going fullscreen for a file does not ask permision.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(false));
}
// Tests fullscreen is exited on page navigation.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsFullscreenOnNavigation) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
// Tests fullscreen is exited when navigating back.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_TestTabExitsFullscreenOnGoBack) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
GoBack();
ASSERT_FALSE(browser()->window()->IsFullscreen());
}
// Tests fullscreen is not exited on sub frame navigation.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(
FullscreenControllerInteractiveTest,
DISABLED_TestTabDoesntExitFullscreenOnSubFrameNavigation) {
ASSERT_TRUE(test_server()->Start());
GURL url(ui_test_utils::GetTestUrl(base::FilePath(
base::FilePath::kCurrentDirectory), base::FilePath(kSimpleFile)));
GURL url_with_fragment(url.spec() + "#fragment");
ui_test_utils::NavigateToURL(browser(), url);
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ui_test_utils::NavigateToURL(browser(), url_with_fragment);
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
}
// Tests tab fullscreen exits, but browser fullscreen remains, on navigation.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(
FullscreenControllerInteractiveTest,
DISABLED_TestFullscreenFromTabWhenAlreadyInBrowserFullscreenWorks) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_NO_FATAL_FAILURE(ToggleBrowserFullscreen(true));
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
GoBack();
ASSERT_TRUE(IsFullscreenForBrowser());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
}
#if defined(OS_MACOSX)
// http://crbug.com/100467
IN_PROC_BROWSER_TEST_F(
FullscreenControllerTest, DISABLED_TabEntersPresentationModeFromWindowed) {
ASSERT_TRUE(test_server()->Start());
AddTabAtIndex(0, GURL(url::kAboutBlankURL), PAGE_TRANSITION_TYPED);
WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents();
{
FullscreenNotificationObserver fullscreen_observer;
EXPECT_FALSE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithToolbar());
browser()->ToggleFullscreenModeForTab(tab, true);
fullscreen_observer.Wait();
EXPECT_TRUE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithToolbar());
}
{
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
EXPECT_FALSE(browser()->window()->IsFullscreen());
EXPECT_FALSE(browser()->window()->IsFullscreenWithToolbar());
}
if (chrome::mac::SupportsSystemFullscreen()) {
// Test that tab fullscreen mode doesn't make presentation mode the default
// on Lion.
FullscreenNotificationObserver fullscreen_observer;
chrome::ToggleFullscreenMode(browser());
fullscreen_observer.Wait();
EXPECT_TRUE(browser()->window()->IsFullscreen());
EXPECT_TRUE(browser()->window()->IsFullscreenWithToolbar());
}
}
#endif
// Tests mouse lock can be escaped with ESC key.
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest, EscapingMouseLock) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Request to lock the mouse.
{
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
}
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Escape, no prompts should remain.
SendEscapeToFullscreenController();
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
// Request to lock the mouse.
{
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
}
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Accept mouse lock, confirm it and that there is no prompt.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
// Escape, confirm we are out of mouse lock with no prompts.
SendEscapeToFullscreenController();
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
// Tests mouse lock and fullscreen modes can be escaped with ESC key.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_EscapingMouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Request to lock the mouse and enter fullscreen.
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Escape, no prompts should remain.
{
FullscreenNotificationObserver fullscreen_observer;
SendEscapeToFullscreenController();
fullscreen_observer.Wait();
}
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
// Request to lock the mouse and enter fullscreen.
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Accept both, confirm mouse lock and fullscreen and no prompts.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
// Escape, confirm we are out of mouse lock and fullscreen with no prompts.
{
FullscreenNotificationObserver fullscreen_observer;
SendEscapeToFullscreenController();
fullscreen_observer.Wait();
}
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
// Tests mouse lock then fullscreen.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_MouseLockThenFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Lock the mouse without a user gesture, expect no response.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_D, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_FALSE(IsMouseLocked());
// Lock the mouse with a user gesture.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Accept mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
// Enter fullscreen mode, mouse lock should be dropped to present buttons.
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreen(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Request mouse lock also, expect fullscreen and mouse lock buttons.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Accept fullscreen and mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenBubbleDisplayingButtons());
}
// Times out sometimes on Linux. http://crbug.com/135115
// Mac: http://crbug.com/103912
// Windows: Failing flakily on try jobs also.
// Tests mouse lock then fullscreen in same request.
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_MouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Request to lock the mouse and enter fullscreen.
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
// Deny both first, to make sure we can.
{
FullscreenNotificationObserver fullscreen_observer;
DenyCurrentFullscreenOrMouseLockRequest();
fullscreen_observer.Wait();
}
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
// Request to lock the mouse and enter fullscreen.
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
// Accept both, confirm they are enabled and there is no prompt.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
ASSERT_FALSE(IsFullscreenPermissionRequested());
}
// Tests mouse lock and fullscreen for the privileged fullscreen case (e.g.,
// embedded flash fullscreen, since the Flash plugin handles user permissions
// requests itself).
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_PrivilegedMouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
SetPrivilegedFullscreen(true);
// Request to lock the mouse and enter fullscreen.
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
// Confirm they are enabled and there is no prompt.
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_FALSE(IsMouseLockPermissionRequested());
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
}
// Flaky on Windows, Linux, CrOS: http://crbug.com/159000
#if defined(OS_WIN) || defined(OS_LINUX) || defined(OS_CHROMEOS)
#define MAYBE_MouseLockSilentAfterTargetUnlock \
DISABLED_MouseLockSilentAfterTargetUnlock
#else
#define MAYBE_MouseLockSilentAfterTargetUnlock MouseLockSilentAfterTargetUnlock
#endif
// Tests mouse lock can be exited and re-entered by an application silently
// with no UI distraction for users.
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_MouseLockSilentAfterTargetUnlock) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Lock the mouse with a user gesture.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Accept mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
// Unlock the mouse from target, make sure it's unlocked.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_U, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Lock mouse again, make sure it works with no bubble.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Unlock the mouse again by target.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_U, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsMouseLocked());
// Lock from target, not user gesture, make sure it works.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_D, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLocked());
ASSERT_FALSE(IsFullscreenBubbleDisplayed());
// Unlock by escape.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_ESCAPE, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_FALSE(IsMouseLocked());
// Lock the mouse with a user gesture, make sure we see bubble again.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLocked());
}
#if defined(OS_WIN) || \
(defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA))
// These tests are very flaky on Vista.
// http://crbug.com/158762
// These are flaky on linux_aura.
// http://crbug.com/163931
#define MAYBE_TestTabExitsMouseLockOnNavigation \
DISABLED_TestTabExitsMouseLockOnNavigation
#define MAYBE_TestTabExitsMouseLockOnGoBack \
DISABLED_TestTabExitsMouseLockOnGoBack
#else
#define MAYBE_TestTabExitsMouseLockOnNavigation \
TestTabExitsMouseLockOnNavigation
#define MAYBE_TestTabExitsMouseLockOnGoBack \
TestTabExitsMouseLockOnGoBack
#endif
// Tests mouse lock is exited on page navigation.
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabExitsMouseLockOnNavigation) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
// Lock the mouse with a user gesture.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Accept mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ui_test_utils::NavigateToURL(browser(), GURL("chrome://newtab"));
ASSERT_FALSE(IsMouseLocked());
}
// Tests mouse lock is exited when navigating back.
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabExitsMouseLockOnGoBack) {
ASSERT_TRUE(test_server()->Start());
// Navigate twice to provide a place to go back to.
ui_test_utils::NavigateToURL(browser(), GURL("about:blank"));
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
// Lock the mouse with a user gesture.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Accept mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
GoBack();
ASSERT_FALSE(IsMouseLocked());
}
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
// TODO(erg): linux_aura bringup: http://crbug.com/163931
#define MAYBE_TestTabDoesntExitMouseLockOnSubFrameNavigation DISABLED_TestTabDoesntExitMouseLockOnSubFrameNavigation
#else
#define MAYBE_TestTabDoesntExitMouseLockOnSubFrameNavigation TestTabDoesntExitMouseLockOnSubFrameNavigation
#endif
// Tests mouse lock is not exited on sub frame navigation.
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
MAYBE_TestTabDoesntExitMouseLockOnSubFrameNavigation) {
ASSERT_TRUE(test_server()->Start());
// Create URLs for test page and test page with #fragment.
GURL url(test_server()->GetURL(kFullscreenMouseLockHTML));
GURL url_with_fragment(url.spec() + "#fragment");
// Navigate to test page.
ui_test_utils::NavigateToURL(browser(), url);
// Lock the mouse with a user gesture.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
ASSERT_TRUE(IsMouseLockPermissionRequested());
ASSERT_FALSE(IsMouseLocked());
// Accept mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
// Navigate to url with fragment. Mouse lock should persist.
ui_test_utils::NavigateToURL(browser(), url_with_fragment);
ASSERT_TRUE(IsMouseLocked());
}
// Tests Mouse Lock and Fullscreen are exited upon reload.
// http://crbug.com/137486
// mac: http://crbug.com/103912
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_ReloadExitsMouseLockAndFullscreen) {
ASSERT_TRUE(test_server()->Start());
ui_test_utils::NavigateToURL(browser(),
test_server()->GetURL(kFullscreenMouseLockHTML));
ASSERT_FALSE(IsMouseLockPermissionRequested());
// Request mouse lock.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Reload. Mouse lock request should be cleared.
{
MouseLockNotificationObserver mouselock_observer;
Reload();
mouselock_observer.Wait();
ASSERT_FALSE(IsMouseLockPermissionRequested());
}
// Request mouse lock.
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_1, false, false, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
ASSERT_TRUE(IsMouseLockPermissionRequested());
// Accept mouse lock.
AcceptCurrentFullscreenOrMouseLockRequest();
ASSERT_TRUE(IsMouseLocked());
ASSERT_TRUE(IsFullscreenBubbleDisplayed());
// Reload. Mouse should be unlocked.
{
MouseLockNotificationObserver mouselock_observer;
Reload();
mouselock_observer.Wait();
ASSERT_FALSE(IsMouseLocked());
}
// Request to lock the mouse and enter fullscreen.
{
FullscreenNotificationObserver fullscreen_observer;
ASSERT_TRUE(ui_test_utils::SendKeyPressAndWait(
browser(), ui::VKEY_B, false, true, false, false,
chrome::NOTIFICATION_MOUSE_LOCK_CHANGED,
content::NotificationService::AllSources()));
fullscreen_observer.Wait();
}
// We are fullscreen.
ASSERT_TRUE(IsWindowFullscreenForTabOrPending());
// Reload. Mouse should be unlocked and fullscreen exited.
{
FullscreenNotificationObserver fullscreen_observer;
Reload();
fullscreen_observer.Wait();
ASSERT_FALSE(IsMouseLocked());
ASSERT_FALSE(IsWindowFullscreenForTabOrPending());
}
}
// Tests ToggleFullscreenModeForTab always causes window to change.
// Test is flaky: http://crbug.com/146006
IN_PROC_BROWSER_TEST_F(FullscreenControllerInteractiveTest,
DISABLED_ToggleFullscreenModeForTab) {
// Most fullscreen tests run sharded in fullscreen_controller_browsertest.cc
// but flakiness required a while loop in
// FullscreenControllerTest::ToggleTabFullscreen. This test verifies that
// when running serially there is no flakiness.
// This test reproduces the same flow as
// TestFullscreenMouseLockContentSettings.
// http://crbug.com/133831
GURL url = test_server()->GetURL("simple.html");
AddTabAtIndex(0, url, PAGE_TRANSITION_TYPED);
// Validate that going fullscreen for a URL defaults to asking permision.
ASSERT_FALSE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreenNoRetries(true));
ASSERT_TRUE(IsFullscreenPermissionRequested());
ASSERT_NO_FATAL_FAILURE(ToggleTabFullscreenNoRetries(false));
}
|