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

Unified Diff: chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc

Issue 2451143003: <webview>: Correctly shift focus between WebContents. (Closed)
Patch Set: Add fix for MacOS hang. Created 4 years, 1 month 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
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 261c611166ba21d405db8fb662a296ed792d056c..cf84fb94d4402e9996e43d7a745322f987ca457b 100644
--- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
+++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
@@ -1364,13 +1364,11 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, FocusAndVisibility) {
EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied());
}
-IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) {
- TestHelper("testKeyboardFocus", "web_view/focus", NO_TEST_SERVER);
+IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusSimple) {
+ TestHelper("testKeyboardFocusSimple", "web_view/focus", NO_TEST_SERVER);
EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(),
embedder_web_contents()->GetMainFrame());
- content::FrameFocusedObserver focus_observer(
- guest_web_contents()->GetMainFrame());
ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
next_step_listener.set_failure_message("TEST_STEP_FAILED");
{
@@ -1383,10 +1381,6 @@ IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) {
// Waits for the renderer to know the input has focus.
ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
- // Wait for the browser to know which frame has focus.
- focus_observer.Wait();
- if (GetParam())
- EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(), nullptr);
ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
GetPlatformAppWindow(), ui::VKEY_A, false, false, false, false));
@@ -1402,3 +1396,71 @@ IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) {
ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
}
+
+// Ensures that input is not routed to the webview when the container is blurred
+// and restored on focus
Charlie Reis 2016/11/16 20:28:23 nit: End with period.
avallee 2016/11/16 21:18:10 Done.
+IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocusWindowCycle) {
+ TestHelper("testKeyboardFocusWindowFocusCycle", "web_view/focus",
+ NO_TEST_SERVER);
+
+ EXPECT_EQ(embedder_web_contents()->GetFocusedFrame(),
+ embedder_web_contents()->GetMainFrame());
+ ExtensionTestMessageListener next_step_listener("TEST_STEP_PASSED", false);
+ next_step_listener.set_failure_message("TEST_STEP_FAILED");
+ {
+ gfx::Rect offset = embedder_web_contents()->GetContainerBounds();
+ // Click the <input> element inside the <webview>.
+ // If we wanted, we could ask the embedder to compute an appropriate point.
+ MoveMouseInsideWindow(gfx::Point(offset.x() + 40, offset.y() + 40));
+ SendMouseClick(ui_controls::LEFT);
+ }
+
+ // Waits for the renderer to know the input has focus.
+ ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
+
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_A, false, false, false, false));
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_B, false, true, false, false));
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_C, false, false, false, false));
+
+ const extensions::Extension* extension =
+ LoadAndLaunchPlatformApp("minimal", "Launched");
+ extensions::AppWindow* window = GetFirstAppWindowForApp(extension->id());
+ EXPECT_TRUE(content::ExecuteScript(
+ embedder_web_contents(),
+ "window.runCommand('monitorGuestEvent', 'focus');"));
+
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_F, false, false, false, false));
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_O, false, true, false, false));
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_O, false, true, false, false));
+
+ // Close the other window and wait for the webview to regain focus.
+ CloseAppWindow(window);
+#if defined(OS_MACOSX)
+ ASSERT_TRUE(ui_test_utils::ShowAndFocusNativeWindow(GetPlatformAppWindow()));
+#endif
+ next_step_listener.Reset();
+ EXPECT_TRUE(
+ content::ExecuteScript(embedder_web_contents(),
+ "window.runCommand('waitGuestEvent', 'focus');"));
+ ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
+
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_X, false, false, false, false));
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_Y, false, true, false, false));
+ ASSERT_TRUE(ui_test_utils::SendKeyPressToWindowSync(
+ GetPlatformAppWindow(), ui::VKEY_Z, false, false, false, false));
+
+ next_step_listener.Reset();
+ EXPECT_TRUE(content::ExecuteScript(
+ embedder_web_contents(),
+ "window.runCommand('testKeyboardFocusRunNextStep', 'aBcxYz');"));
+
+ ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
+}

Powered by Google App Engine
This is Rietveld 408576698