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

Unified Diff: content/browser/site_per_process_browsertest.cc

Issue 1407173005: Revert of OOPIF: Route keyboard events to focused frame in the browser process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@focus-page
Patch Set: Created 5 years, 2 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
Index: content/browser/site_per_process_browsertest.cc
diff --git a/content/browser/site_per_process_browsertest.cc b/content/browser/site_per_process_browsertest.cc
index f4beb0be6c0c55ecd92f0f9652b636c36e9c8c27..6bb654a15b58f2bf84fac0ded993a0b6cd45f212 100644
--- a/content/browser/site_per_process_browsertest.cc
+++ b/content/browser/site_per_process_browsertest.cc
@@ -97,18 +97,6 @@
EXPECT_TRUE(success);
}
-// Helper function to generate a click on the given RenderWidgetHost. The
-// mouse event is forwarded directly to the RenderWidgetHost without any
-// hit-testing.
-void SimulateMouseClick(RenderWidgetHost* rwh, int x, int y) {
- blink::WebMouseEvent mouse_event;
- mouse_event.type = blink::WebInputEvent::MouseDown;
- mouse_event.button = blink::WebPointerProperties::ButtonLeft;
- mouse_event.x = x;
- mouse_event.y = y;
- rwh->ForwardMouseEvent(mouse_event);
-}
-
class RedirectNotificationObserver : public NotificationObserver {
public:
// Register to listen for notifications of the given type from either a
@@ -3500,8 +3488,14 @@
DOMMessageQueue msg_queue;
// Click on the cross-process subframe.
- SimulateMouseClick(
- root->child_at(0)->current_frame_host()->GetRenderWidgetHost(), 1, 1);
+ blink::WebMouseEvent mouse_event;
+ mouse_event.type = blink::WebInputEvent::MouseDown;
+ mouse_event.button = blink::WebPointerProperties::ButtonLeft;
+ mouse_event.x = 1;
+ mouse_event.y = 1;
+ RenderWidgetHost* rwh_child =
+ root->child_at(0)->current_frame_host()->GetRenderWidgetHost();
+ rwh_child->ForwardMouseEvent(mouse_event);
// Check that the main frame lost focus and fired blur event on the input
// text field.
@@ -3515,8 +3509,8 @@
EXPECT_EQ(root->child_at(0), root->frame_tree()->GetFocusedFrame());
// Click on the root frame.
- SimulateMouseClick(
- shell()->web_contents()->GetRenderViewHost()->GetWidget(), 1, 1);
+ shell()->web_contents()->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(
+ mouse_event);
// Check that the subframe lost focus and fired blur event on its
// document's body.
@@ -3632,47 +3626,4 @@
EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url);
}
-// Ensure that a cross-process subframe can receive keyboard events when in
-// focus.
-IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
- SubframeKeyboardEventRouting) {
- GURL main_url(embedded_test_server()->GetURL(
- "a.com", "/frame_tree/page_with_one_frame.html"));
- EXPECT_TRUE(NavigateToURL(shell(), main_url));
-
- WebContentsImpl* web_contents =
- static_cast<WebContentsImpl*>(shell()->web_contents());
- FrameTreeNode* root = web_contents->GetFrameTree()->root();
-
- GURL frame_url(
- embedded_test_server()->GetURL("b.com", "/page_with_input_field.html"));
- NavigateFrameToURL(root->child_at(0), frame_url);
- EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host()));
-
- // Click on the subframe to focus it.
- SimulateMouseClick(
- root->child_at(0)->current_frame_host()->GetRenderWidgetHost(), 1, 1);
-
- // Focus the input field in the subframe. The return value "input-focus"
- // will be sent once the input field's focus event fires.
- std::string result;
- EXPECT_TRUE(ExecuteScriptAndExtractString(
- root->child_at(0)->current_frame_host(), "focusInputField()", &result));
- EXPECT_EQ(result, "input-focus");
-
- // The subframe should now be focused.
- EXPECT_EQ(root->child_at(0), root->frame_tree()->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(
- root->child_at(0)->current_frame_host(),
- "window.domAutomationController.send(getInputFieldText());", &result));
- EXPECT_EQ("FOO", result);
-}
-
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698