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

Side by Side Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 2474323002: Implement WebContentsViewChildFrame::TakeFocus. (Closed)
Patch Set: Remove logging code. Created 3 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/location.h" 7 #include "base/location.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/single_thread_task_runner.h" 9 #include "base/single_thread_task_runner.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 ::features::kGuestViewCrossProcessFrames.name); 507 ::features::kGuestViewCrossProcessFrames.name);
508 } else { 508 } else {
509 command_line->AppendSwitchASCII( 509 command_line->AppendSwitchASCII(
510 switches::kDisableFeatures, 510 switches::kDisableFeatures,
511 ::features::kGuestViewCrossProcessFrames.name); 511 ::features::kGuestViewCrossProcessFrames.name);
512 } 512 }
513 } 513 }
514 }; 514 };
515 515
516 class WebViewNewWindowInteractiveTest : public WebViewInteractiveTest {}; 516 class WebViewNewWindowInteractiveTest : public WebViewInteractiveTest {};
517 class WebViewFocusInteractiveTest : public WebViewInteractiveTest {};
517 class WebViewPointerLockInteractiveTest : public WebViewInteractiveTest {}; 518 class WebViewPointerLockInteractiveTest : public WebViewInteractiveTest {};
518 519
519 // The tests below aren't needed in --use-cross-process-frames-for-guests. 520 // The tests below aren't needed in --use-cross-process-frames-for-guests.
520 class WebViewContextMenuInteractiveTest : public WebViewInteractiveTestBase {}; 521 class WebViewContextMenuInteractiveTest : public WebViewInteractiveTestBase {};
521 522
522 // The following class of tests do not work for OOPIF <webview>. 523 // The following class of tests do not work for OOPIF <webview>.
523 // TODO(ekaramad): Make this tests work with OOPIF and replace the test classes 524 // TODO(ekaramad): Make this tests work with OOPIF and replace the test classes
524 // with WebViewInteractiveTest (see crbug.com/582562). 525 // with WebViewInteractiveTest (see crbug.com/582562).
525 class WebViewFocusInteractiveTest : public WebViewInteractiveTestBase {};
526 class WebViewPopupInteractiveTest : public WebViewInteractiveTestBase {}; 526 class WebViewPopupInteractiveTest : public WebViewInteractiveTestBase {};
527 class WebViewDragDropInteractiveTest : public WebViewInteractiveTestBase {}; 527 class WebViewDragDropInteractiveTest : public WebViewInteractiveTestBase {};
528 528
529 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests, 529 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
530 WebViewInteractiveTest, 530 WebViewInteractiveTest,
531 testing::Bool()); 531 testing::Bool());
532 532
533 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests, 533 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
534 WebViewNewWindowInteractiveTest, 534 WebViewNewWindowInteractiveTest,
535 testing::Bool()); 535 testing::Bool());
536 536
537 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests, 537 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
538 WebViewFocusInteractiveTest,
539 testing::Bool());
540
541 INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
538 WebViewPointerLockInteractiveTest, 542 WebViewPointerLockInteractiveTest,
539 testing::Bool()); 543 testing::Bool());
540 544
541 // ui_test_utils::SendMouseMoveSync doesn't seem to work on OS_MACOSX, and 545 // ui_test_utils::SendMouseMoveSync doesn't seem to work on OS_MACOSX, and
542 // likely won't work on many other platforms as well, so for now this test 546 // likely won't work on many other platforms as well, so for now this test
543 // is for Windows and Linux only. As of Sept 17th, 2013 this test is disabled 547 // is for Windows and Linux only. As of Sept 17th, 2013 this test is disabled
544 // on Windows due to flakines, see http://crbug.com/293445. 548 // on Windows due to flakines, see http://crbug.com/293445.
545 549
546 // Disabled on Linux Aura because pointer lock does not work on Linux Aura. 550 // Disabled on Linux Aura because pointer lock does not work on Linux Aura.
547 // crbug.com/341876 551 // crbug.com/341876
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 SendKeyPressToPlatformApp(ui::VKEY_ESCAPE); 645 SendKeyPressToPlatformApp(ui::VKEY_ESCAPE);
642 646
643 // Wait for page to receive (successful) mouse unlock response. 647 // Wait for page to receive (successful) mouse unlock response.
644 ASSERT_TRUE(unlocked_listener.WaitUntilSatisfied()); 648 ASSERT_TRUE(unlocked_listener.WaitUntilSatisfied());
645 } 649 }
646 650
647 #endif // defined(OS_LINUX) 651 #endif // defined(OS_LINUX)
648 652
649 // Tests that if a <webview> is focused before navigation then the guest starts 653 // Tests that if a <webview> is focused before navigation then the guest starts
650 // off focused. 654 // off focused.
651 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, 655 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest,
652 Focus_FocusBeforeNavigation) { 656 Focus_FocusBeforeNavigation) {
657 // TODO(avallee): Determine if test is relevant with OOPIF or fix the bug.
658 // http://crbug.com/672947
659 if (GetParam())
660 return;
653 TestHelper("testFocusBeforeNavigation", "web_view/focus", NO_TEST_SERVER); 661 TestHelper("testFocusBeforeNavigation", "web_view/focus", NO_TEST_SERVER);
654 } 662 }
655 663
656 // Tests that setting focus on the <webview> sets focus on the guest. 664 // Tests that setting focus on the <webview> sets focus on the guest.
657 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusEvent) { 665 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_FocusEvent) {
658 TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER); 666 TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER);
659 } 667 }
660 668
661 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusTracksEmbedder) { 669 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_FocusTracksEmbedder) {
662 content::WebContents* embedder_web_contents = NULL; 670 content::WebContents* embedder_web_contents = NULL;
663 671
664 std::unique_ptr<ExtensionTestMessageListener> done_listener( 672 std::unique_ptr<ExtensionTestMessageListener> done_listener(
665 RunAppHelper("testFocusTracksEmbedder", "web_view/focus", NO_TEST_SERVER, 673 RunAppHelper("testFocusTracksEmbedder", "web_view/focus", NO_TEST_SERVER,
666 &embedder_web_contents)); 674 &embedder_web_contents));
667 done_listener->WaitUntilSatisfied(); 675 done_listener->WaitUntilSatisfied();
668 676
669 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); 677 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
670 next_step_listener.set_failure_message("TEST_STEP_FAILED"); 678 next_step_listener.set_failure_message("TEST_STEP_FAILED");
671 EXPECT_TRUE(content::ExecuteScript( 679 EXPECT_TRUE(content::ExecuteScript(
672 embedder_web_contents, 680 embedder_web_contents,
673 "window.runCommand('testFocusTracksEmbedderRunNextStep');")); 681 "window.runCommand('testFocusTracksEmbedderRunNextStep');"));
674 682
675 // Blur the embedder. 683 // Blur the embedder.
676 embedder_web_contents->GetRenderViewHost()->GetWidget()->Blur(); 684 embedder_web_contents->GetRenderViewHost()->GetWidget()->Blur();
677 // Ensure that the guest is also blurred. 685 // Ensure that the guest is also blurred.
678 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 686 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
679 } 687 }
680 688
681 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_AdvanceFocus) { 689 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
682 content::WebContents* embedder_web_contents = NULL; 690 content::WebContents* embedder_web_contents = NULL;
683 691
684 { 692 {
685 std::unique_ptr<ExtensionTestMessageListener> done_listener( 693 std::unique_ptr<ExtensionTestMessageListener> done_listener(
686 RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER, 694 RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER,
687 &embedder_web_contents)); 695 &embedder_web_contents));
688 done_listener->WaitUntilSatisfied(); 696 done_listener->WaitUntilSatisfied();
689 } 697 }
690 698
691 { 699 {
692 ExtensionTestMessageListener listener("button1-focused", false); 700 ExtensionTestMessageListener listener("button1-focused", false);
693 listener.set_failure_message("TEST_FAILED"); 701 listener.set_failure_message("TEST_FAILED");
694 SimulateRWHMouseClick( 702
695 embedder_web_contents->GetRenderViewHost()->GetWidget(), 703 // In oopif-webview, the click it directly routed to the guest.
696 blink::WebMouseEvent::Button::Left, 200, 20); 704 content::WebContents* guest =
705 GetParam() ? GetGuestViewManager()->WaitForSingleGuestCreated()
706 : nullptr;
707
708 SimulateRWHMouseClick((guest ? guest : embedder_web_contents)
709 ->GetRenderViewHost()
710 ->GetWidget(),
711 blink::WebMouseEvent::Button::Left, 200, 20);
697 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, 712 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB,
698 ui::DomCode::TAB, ui::VKEY_TAB, false, false, 713 ui::DomCode::TAB, ui::VKEY_TAB, false, false,
699 false, false); 714 false, false);
700 ASSERT_TRUE(listener.WaitUntilSatisfied()); 715 ASSERT_TRUE(listener.WaitUntilSatisfied());
701 } 716 }
702 717
703 { 718 {
704 // Wait for button1 to be focused again, this means we were asked to 719 // Wait for button1 to be focused again, this means we were asked to
705 // move the focus to the next focusable element. 720 // move the focus to the next focusable element.
706 ExtensionTestMessageListener listener("button1-advance-focus", false); 721 ExtensionTestMessageListener listener("button1-advance-focus", false);
(...skipping 10 matching lines...) Expand all
717 ui::DomCode::TAB, ui::VKEY_TAB, false, false, 732 ui::DomCode::TAB, ui::VKEY_TAB, false, false,
718 false, false); 733 false, false);
719 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB, 734 content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB,
720 ui::DomCode::TAB, ui::VKEY_TAB, false, false, 735 ui::DomCode::TAB, ui::VKEY_TAB, false, false,
721 false, false); 736 false, false);
722 ASSERT_TRUE(listener.WaitUntilSatisfied()); 737 ASSERT_TRUE(listener.WaitUntilSatisfied());
723 } 738 }
724 } 739 }
725 740
726 // Tests that blurring <webview> also blurs the guest. 741 // Tests that blurring <webview> also blurs the guest.
727 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_BlurEvent) { 742 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_BlurEvent) {
728 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); 743 TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER);
729 } 744 }
730 745
731 // Tests that guests receive edit commands and respond appropriately. 746 // Tests that guests receive edit commands and respond appropriately.
732 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, EditCommands) { 747 IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, EditCommands) {
733 #if defined(OS_MACOSX) 748 #if defined(OS_MACOSX)
734 // TODO(ekaramad): This test is failing under OOPIF in MAC. 749 // TODO(ekaramad): This test is failing under OOPIF in MAC.
735 if (GetParam()) 750 if (GetParam())
736 return; 751 return;
737 #endif 752 #endif
(...skipping 414 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 } 1167 }
1153 1168
1154 // This test exercies the following scenario: 1169 // This test exercies the following scenario:
1155 // 1. An <input> in guest has focus. 1170 // 1. An <input> in guest has focus.
1156 // 2. User takes focus to embedder by clicking e.g. an <input> in embedder. 1171 // 2. User takes focus to embedder by clicking e.g. an <input> in embedder.
1157 // 3. User brings back the focus directly to the <input> in #1. 1172 // 3. User brings back the focus directly to the <input> in #1.
1158 // 1173 //
1159 // Now we need to make sure TextInputTypeChanged fires properly for the guest's 1174 // Now we need to make sure TextInputTypeChanged fires properly for the guest's
1160 // view upon step #3. We simply read the input type's state after #3 to 1175 // view upon step #3. We simply read the input type's state after #3 to
1161 // make sure it's not TEXT_INPUT_TYPE_NONE. 1176 // make sure it's not TEXT_INPUT_TYPE_NONE.
1162 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusRestored) { 1177 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_FocusRestored) {
1163 TestHelper("testFocusRestored", "web_view/focus", NO_TEST_SERVER); 1178 TestHelper("testFocusRestored", "web_view/focus", NO_TEST_SERVER);
1164 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents(); 1179 content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
1165 ASSERT_TRUE(embedder_web_contents); 1180 ASSERT_TRUE(embedder_web_contents);
1166 ASSERT_TRUE(guest_web_contents()); 1181 ASSERT_TRUE(guest_web_contents());
1167 1182
1168 // 1) We click on the guest so that we get a focus event. 1183 // 1) We click on the guest so that we get a focus event.
1169 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false); 1184 ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
1170 next_step_listener.set_failure_message("TEST_STEP_FAILED"); 1185 next_step_listener.set_failure_message("TEST_STEP_FAILED");
1171 { 1186 {
1172 content::SimulateMouseClickAt(guest_web_contents(), 1187 content::SimulateMouseClickAt(guest_web_contents(),
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 } 1344 }
1330 #endif 1345 #endif
1331 1346
1332 // Flaky on MacOS builders. https://crbug.com/670008 1347 // Flaky on MacOS builders. https://crbug.com/670008
1333 #if defined(OS_MACOSX) 1348 #if defined(OS_MACOSX)
1334 #define MAYBE_FocusAndVisibility DISABLED_FocusAndVisibility 1349 #define MAYBE_FocusAndVisibility DISABLED_FocusAndVisibility
1335 #else 1350 #else
1336 #define MAYBE_FocusAndVisibility FocusAndVisibility 1351 #define MAYBE_FocusAndVisibility FocusAndVisibility
1337 #endif 1352 #endif
1338 1353
1339 IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) { 1354 IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
1340 ASSERT_TRUE(StartEmbeddedTestServer()); 1355 ASSERT_TRUE(StartEmbeddedTestServer());
1341 LoadAndLaunchPlatformApp("web_view/focus_visibility", 1356 LoadAndLaunchPlatformApp("web_view/focus_visibility",
1342 "WebViewInteractiveTest.LOADED"); 1357 "WebViewInteractiveTest.LOADED");
1343 ExtensionTestMessageListener test_init_listener( 1358 ExtensionTestMessageListener test_init_listener(
1344 "WebViewInteractiveTest.WebViewInitialized", false); 1359 "WebViewInteractiveTest.WebViewInitialized", false);
1345 SendMessageToEmbedder("init"); 1360 SendMessageToEmbedder("init");
1346 test_init_listener.WaitUntilSatisfied(); 1361 test_init_listener.WaitUntilSatisfied();
1362
1363 // In oopif-webview, wait until the tab key triggers a focus change.
1364 std::unique_ptr<content::FrameFocusedObserver> frame_focus_observer =
1365 GetParam() ? base::MakeUnique<content::FrameFocusedObserver>(
1366 GetGuestViewManager()
1367 ->WaitForSingleGuestCreated()
1368 ->GetMainFrame())
1369 : nullptr;
1370
1347 // Send several tab-keys. The button inside webview should receive focus at 1371 // Send several tab-keys. The button inside webview should receive focus at
1348 // least once. 1372 // least once.
1349 for (size_t i = 0; i < 4; ++i) 1373 for (size_t i = 0; i < 2; ++i)
1374 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1375 if (frame_focus_observer) {
1376 frame_focus_observer->Wait();
1377 frame_focus_observer.reset();
1378 }
1379 for (size_t i = 0; i < 2; ++i)
1350 SendKeyPressToPlatformApp(ui::VKEY_TAB); 1380 SendKeyPressToPlatformApp(ui::VKEY_TAB);
1351 ExtensionTestMessageListener webview_button_focused_listener( 1381 ExtensionTestMessageListener webview_button_focused_listener(
1352 "WebViewInteractiveTest.WebViewButtonWasFocused", false); 1382 "WebViewInteractiveTest.WebViewButtonWasFocused", false);
1353 webview_button_focused_listener.set_failure_message( 1383 webview_button_focused_listener.set_failure_message(
1354 "WebViewInteractiveTest.WebViewButtonWasNotFocused"); 1384 "WebViewInteractiveTest.WebViewButtonWasNotFocused");
1355 SendMessageToEmbedder("verify"); 1385 SendMessageToEmbedder("verify");
1356 EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied()); 1386 EXPECT_TRUE(webview_button_focused_listener.WaitUntilSatisfied());
1357 // Now make the <webview> invisible. 1387 // Now make the <webview> invisible.
1358 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset", 1388 ExtensionTestMessageListener reset_listener("WebViewInteractiveTest.DidReset",
1359 false); 1389 false);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1468 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync( 1498 ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
1469 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false)); 1499 GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false));
1470 1500
1471 next_step_listener.Reset(); 1501 next_step_listener.Reset();
1472 EXPECT_TRUE(content::ExecuteScript( 1502 EXPECT_TRUE(content::ExecuteScript(
1473 embedder_web_contents(), 1503 embedder_web_contents(),
1474 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');")); 1504 "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');"));
1475 1505
1476 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied()); 1506 ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
1477 } 1507 }
OLDNEW
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.h » ('j') | content/common/view_messages.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698