Index: chrome/browser/apps/web_view_interactive_browsertest.cc |
diff --git a/chrome/browser/apps/web_view_interactive_browsertest.cc b/chrome/browser/apps/web_view_interactive_browsertest.cc |
index e2fec4b26f936ed87d135798c30e6ae353ee709a..1fc55f9303db5fad0d0d1f9a025a0e4117180098 100644 |
--- a/chrome/browser/apps/web_view_interactive_browsertest.cc |
+++ b/chrome/browser/apps/web_view_interactive_browsertest.cc |
@@ -502,12 +502,78 @@ IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, PointerLock) { |
#endif // defined(OS_LINUX) && !defined(USE_AURA) |
+// Tests that if a <webview> is focused before navigation then the guest starts |
+// off focused. |
+IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusBeforeNavigation) { |
+ 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(WebViewInteractiveTest, Focus_FocusEvent) { |
TestHelper("testFocusEvent", "web_view/focus", NO_TEST_SERVER); |
} |
-// Tests that setting focus on the <webview> sets focus on the guest. |
+IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_FocusTracksEmbedder) { |
+ content::WebContents* embedder_web_contents = NULL; |
+ |
+ scoped_ptr<ExtensionTestMessageListener> done_listener( |
+ RunAppHelper("testFocusTracksEmbedder", "web_view/focus", NO_TEST_SERVER, |
+ &embedder_web_contents)); |
+ done_listener->WaitUntilSatisfied(); |
+ |
+ ExtensionTestMessageListener post_test_listener("POST_TEST_PASSED", false); |
+ post_test_listener.set_failure_message("POST_TEST_FAILED"); |
+ EXPECT_TRUE(content::ExecuteScript( |
+ embedder_web_contents, |
+ "window.runCommand('POST_testFocusTracksEmbedder');")); |
+ |
+ // Blur the embedder. |
+ embedder_web_contents->GetRenderViewHost()->Blur(); |
+ // Ensure that the guest is also blurred. |
+ ASSERT_TRUE(post_test_listener.WaitUntilSatisfied()); |
+} |
+ |
+IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_AdvanceFocus) { |
+ content::WebContents* embedder_web_contents = NULL; |
+ |
+ { |
+ scoped_ptr<ExtensionTestMessageListener> done_listener( |
+ RunAppHelper("testAdvanceFocus", "web_view/focus", NO_TEST_SERVER, |
+ &embedder_web_contents)); |
+ done_listener->WaitUntilSatisfied(); |
+ } |
+ |
+ { |
+ ExtensionTestMessageListener listener("button1-focused", false); |
+ listener.set_failure_message("TEST_FAILED"); |
+ SimulateRWHMouseClick(embedder_web_contents->GetRenderViewHost(), |
+ blink::WebMouseEvent::ButtonLeft, 200, 20); |
+ content::SimulateKeyPress(embedder_web_contents, ui::VKEY_TAB, |
+ false, false, false, false); |
+ EXPECT_TRUE(content::ExecuteScript( |
Fady Samuel
2014/05/21 18:02:37
Why do we need this?
lazyboy
2014/05/21 19:19:07
Not needed, removed.
|
+ embedder_web_contents, |
+ "window.runCommand('POST_testAdvanceFocus');")); |
+ ASSERT_TRUE(listener.WaitUntilSatisfied()); |
+ } |
+ |
+ { |
+ // Wait for button1 to be focused again, this means we have seen |
+ // BrowserPluginGuest::OnTakeFocus. |
Fady Samuel
2014/05/21 18:02:37
Let's not mention BrowserPlugin details in this pa
lazyboy
2014/05/21 19:19:07
Done.
|
+ ExtensionTestMessageListener listener("button1-advance-focus", false); |
+ listener.set_failure_message("TEST_FAILED"); |
+ // TODO(fsamuel): A third Tab key press should not be necessary. |
+ // The browser plugin will take keyboard focus but it will not |
Fady Samuel
2014/05/21 18:02:37
Let's not mention BrowserPlugin in this patch.
lazyboy
2014/05/21 19:19:07
Done.
|
+ // focus an initial element. The initial element is dependent |
+ // upon tab direction which WebKit does not propagate to the plugin. |
+ // See http://crbug.com/147644. |
+ SendKeyPressToPlatformApp(ui::VKEY_TAB); |
+ SendKeyPressToPlatformApp(ui::VKEY_TAB); |
+ SendKeyPressToPlatformApp(ui::VKEY_TAB); |
+ ASSERT_TRUE(listener.WaitUntilSatisfied()); |
+ } |
+} |
+ |
+// Tests that blurring <webview> also blurs the guest. |
IN_PROC_BROWSER_TEST_F(WebViewInteractiveTest, Focus_BlurEvent) { |
TestHelper("testBlurEvent", "web_view/focus", NO_TEST_SERVER); |
} |