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

Unified Diff: chrome/browser/site_per_process_interactive_browsertest.cc

Issue 1869853002: Move the SubframeKeyboardEventRouting test to interactive_ui_tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@interactive-tests
Patch Set: Fix EXPECT_EQ Created 4 years, 8 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/site_per_process_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/site_per_process_interactive_browsertest.cc
diff --git a/chrome/browser/site_per_process_interactive_browsertest.cc b/chrome/browser/site_per_process_interactive_browsertest.cc
index 03a7c300106a14a505c0d3fe7079c78985154ed4..9bf141f092075bc5ea36f75f8a4db77d6153e8c2 100644
--- a/chrome/browser/site_per_process_interactive_browsertest.cc
+++ b/chrome/browser/site_per_process_interactive_browsertest.cc
@@ -106,3 +106,41 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest, DocumentHasFocus) {
EXPECT_TRUE(document_has_focus(child2));
}
+// Ensure that a cross-process subframe can receive keyboard events when in
+// focus.
+IN_PROC_BROWSER_TEST_F(SitePerProcessInteractiveBrowserTest,
+ SubframeKeyboardEventRouting) {
+ GURL main_url(embedded_test_server()->GetURL(
+ "a.com", "/frame_tree/page_with_one_frame.html"));
+ ui_test_utils::NavigateToURL(browser(), main_url);
+ content::WebContents* web_contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+ GURL frame_url(
+ embedded_test_server()->GetURL("b.com", "/page_with_input_field.html"));
+ EXPECT_TRUE(NavigateIframeToURL(web_contents, "child0", frame_url));
+
+ // Focus the subframe and then its input field. The return value
+ // "input-focus" will be sent once the input field's focus event fires.
+ content::RenderFrameHost* child =
+ ChildFrameAt(web_contents->GetMainFrame(), 0);
+ std::string result;
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child, "window.focus(); focusInputField();", &result));
+ EXPECT_EQ("input-focus", result);
+
+ // The subframe should now be focused.
+ EXPECT_EQ(child, web_contents->GetFocusedFrame());
+
+ // Generate a few keyboard events and route them to currently focused frame.
+ SimulateKeyPress(web_contents, ui::VKEY_F, false, false, false, false);
+ SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false);
+ SimulateKeyPress(web_contents, ui::VKEY_O, false, false, false, false);
+
+ // Verify that the input field in the subframe received the keystrokes.
+ EXPECT_TRUE(ExecuteScriptAndExtractString(
+ child,
+ "window.domAutomationController.send(getInputFieldText());", &result));
+ EXPECT_EQ("FOO", result);
+}
+
« no previous file with comments | « no previous file | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698