| 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 e25a322b3b25e03d4ec16ab89b16c4c44d7c413f..acdfdf56a9cc5444b8b6a2774057f3a3bffadb0f 100644
|
| --- a/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
|
| +++ b/chrome/browser/apps/guest_view/web_view_interactive_browsertest.cc
|
| @@ -26,6 +26,7 @@
|
| #include "components/guest_view/browser/guest_view_manager_factory.h"
|
| #include "components/guest_view/browser/test_guest_view_manager.h"
|
| #include "content/public/browser/notification_service.h"
|
| +#include "content/public/browser/render_frame_host.h"
|
| #include "content/public/browser/render_process_host.h"
|
| #include "content/public/browser/render_view_host.h"
|
| #include "content/public/browser/render_widget_host.h"
|
| @@ -227,6 +228,7 @@ class WebViewInteractiveTestBase : public extensions::PlatformAppBrowserTest {
|
| ASSERT_TRUE(done_listener);
|
| ASSERT_TRUE(done_listener->WaitUntilSatisfied());
|
|
|
| + embedder_web_contents_ = embedder_web_contents;
|
| guest_web_contents_ = GetGuestViewManager()->WaitForSingleGuestCreated();
|
| }
|
|
|
| @@ -1353,3 +1355,42 @@ IN_PROC_BROWSER_TEST_F(WebViewFocusInteractiveTest, FocusAndVisibility) {
|
| SendMessageToEmbedder("verify");
|
| EXPECT_TRUE(webview_button_not_focused_listener.WaitUntilSatisfied());
|
| }
|
| +
|
| +IN_PROC_BROWSER_TEST_P(WebViewInteractiveTest, KeyboardFocus) {
|
| + TestHelper("testKeyboardFocus", "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");
|
| + {
|
| + 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());
|
| + // 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));
|
| + 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));
|
| +
|
| + next_step_listener.Reset();
|
| + EXPECT_TRUE(content::ExecuteScript(
|
| + embedder_web_contents(),
|
| + "window.runCommand('testKeyboardFocusRunNextStep', 'aBc');"));
|
| +
|
| + ASSERT_TRUE(next_step_listener.WaitUntilSatisfied());
|
| +}
|
|
|