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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/frame_host/render_frame_host_impl.h » ('j') | content/common/view_messages.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
diff --git a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
index 332add5cdfe42624c708009139875da972af4b99..ce963806468ee9c95460eb531fcb704ae336f0aa 100644
--- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
@@ -514,6 +514,7 @@ class WebViewInteractiveTest : public WebViewInteractiveTestBase,
};
class WebViewNewWindowInteractiveTest : public WebViewInteractiveTest {};
+class WebViewFocusInteractiveTest : public WebViewInteractiveTest {};
class WebViewPointerLockInteractiveTest : public WebViewInteractiveTest {};
// The tests below aren't needed in --use-cross-process-frames-for-guests.
@@ -522,7 +523,6 @@ class WebViewContextMenuInteractiveTest : public WebViewInteractiveTestBase {};
// The following class of tests do not work for OOPIF <webview>.
// TODO(ekaramad): Make this tests work with OOPIF and replace the test classes
// with WebViewInteractiveTest (see crbug.com/582562).
-class WebViewFocusInteractiveTest : public WebViewInteractiveTestBase {};
class WebViewPopupInteractiveTest : public WebViewInteractiveTestBase {};
class WebViewDragDropInteractiveTest : public WebViewInteractiveTestBase {};
@@ -535,6 +535,10 @@ INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
testing::Bool());
INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
+ WebViewFocusInteractiveTest,
+ testing::Bool());
+
+INSTANTIATE_TEST_CASE_P(WebViewInteractiveTests,
WebViewPointerLockInteractiveTest,
testing::Bool());
@@ -648,17 +652,21 @@ IN_PROC_BROWSER_TEST_P(WebViewPointerLockInteractiveTest,
// Tests that if a <webview> is focused before navigation then the guest starts
// off focused.
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest,
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest,
Focus_FocusBeforeNavigation) {
+ // TODO(avallee): Determine if test is relevant with OOPIF or fix the bug.
+ // http://crbug.com/672947
+ if (GetParam())
+ return;
TestHelper("testFocusBeforeNavigation", "web_view/focus", NO_TEST_SERVER);
}
// Tests that setting focus on the <webview> sets focus on the guest.
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusEvent) {
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_FocusEvent) {
TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER);
}
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusTracksEmbedder) {
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_FocusTracksEmbedder) {
content::WebContents* embedder_web_contents = NULL;
std::unique_ptr<ExtensionTestMessageListener> done_listener(
@@ -678,7 +686,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusTracksEmbedder) {
ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
}
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
content::WebContents* embedder_web_contents = NULL;
{
@@ -691,9 +699,16 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
{
ExtensionTestMessageListener listener("button1-focused", false);
listener.set_failure_message("TEST_FAILED");
- SimulateRWHMouseClick(
- embedder_web_contents->GetRenderViewHost()->GetWidget(),
- blink::WebMouseEvent::Button::Left, 200, 20);
+
+ // In oopif-webview, the click it directly routed to the guest.
+ content::WebContents* guest =
+ GetParam() ? GetGuestViewManager()->WaitForSingleGuestCreated()
+ : nullptr;
+
+ SimulateRWHMouseClick((guest ? guest : embedder_web_contents)
+ ->GetRenderViewHost()
+ ->GetWidget(),
+ blink::WebMouseEvent::Button::Left, 200, 20);
content::SimulateKeyPress(embedder_web_contents, ui::DomKey::TAB,
ui::DomCode::TAB, ui::VKEY_TAB, false, false,
false, false);
@@ -724,7 +739,7 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_AdvanceFocus) {
}
// Tests that blurring <webview> also blurs the guest.
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_BlurEvent) {
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_BlurEvent) {
TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER);
}
@@ -1159,7 +1174,7 @@ IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest,
// Now we need to make sure TextInputTypeChanged fires properly for the guest's
// view upon step #3. We simply read the input type's state after #3 to
// make sure it's not TEXT_INPUT_TYPE_NONE.
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, Focus_FocusRestored) {
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, Focus_FocusRestored) {
TestHelper("testFocusRestored", "web_view/focus", NO_TEST_SERVER);
content::WebContents* embedder_web_contents = GetFirstAppWindowWebContents();
ASSERT_TRUE(embedder_web_contents);
@@ -1336,7 +1351,7 @@ IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, TextSelection) {
#define MAYBE_FocusAndVisibility FocusAndVisibility
#endif
-IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
+IN_PROC_BROWSER_TEST_P(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
ASSERT_TRUE(StartEmbeddedTestServer());
LoadAndLaunchPlatformApp("web_view/focus_visibility",
"WebViewInteractiveTest.LOADED");
@@ -1344,9 +1359,24 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, MAYBE_FocusAndVisibility) {
"WebViewInteractiveTest.WebViewInitialized", false);
SendMessageToEmbedder("init");
test_init_listener.WaitUntilSatisfied();
+
+ // In oopif-webview, wait until the tab key triggers a focus change.
+ std::unique_ptr<content::FrameFocusedObserver> frame_focus_observer =
+ GetParam() ? base::MakeUnique<content::FrameFocusedObserver>(
+ GetGuestViewManager()
+ ->WaitForSingleGuestCreated()
+ ->GetMainFrame())
+ : nullptr;
+
// Send several tab-keys. The button inside webview should receive focus at
// least once.
- for (size_t i = 0; i < 4; ++i)
+ for (size_t i = 0; i < 2; ++i)
+ SendKeyPressToPlatformApp(ui::VKEY_TAB);
+ if (frame_focus_observer) {
+ frame_focus_observer->Wait();
+ frame_focus_observer.reset();
+ }
+ for (size_t i = 0; i < 2; ++i)
SendKeyPressToPlatformApp(ui::VKEY_TAB);
ExtensionTestMessageListener webview_button_focused_listener(
"WebViewInteractiveTest.WebViewButtonWasFocused", false);
« 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