Chromium Code Reviews| 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 55a2ab9ccfdf381c510fc51fe2d1ba762dbe1398..350a40ca0e00201d99ffb463a3a92f6082adce9f 100644 |
| --- a/content/browser/site_per_process_browsertest.cc |
| +++ b/content/browser/site_per_process_browsertest.cc |
| @@ -5242,9 +5242,24 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| gfx::Point child_center(150, 150); |
| auto* rwhv = static_cast<RenderWidgetHostViewAura*>( |
| contents->GetRenderWidgetHostView()); |
| + |
| + // Wait until renderer's compositor thread is synced. |
| + RenderWidgetHost* child_render_widget_host = |
| + root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); |
| + { |
| + auto observer = |
| + base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host); |
| + observer->Wait(); |
| + } |
| + |
| ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, |
| ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); |
| rwhv->OnTouchEvent(&touch_event); |
| + { |
| + auto observer = |
| + base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host); |
| + observer->Wait(); |
| + } |
| // Verify touch handler in subframe was invoked |
| std::string result; |
| @@ -5254,6 +5269,54 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| EXPECT_EQ("touchstart", result); |
| } |
| +// This test verifies that the test in |
| +// SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for |
| +// the main frame. Prior to the CL in which this test is introduced, use of |
| +// MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since |
| +// the touch events were handled on the main thread. Now they are handled on the |
| +// compositor thread, hence the need to synchronize. |
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |
| + MainframeTouchEventRouting) { |
| + GURL main_url(embedded_test_server()->GetURL( |
| + "/page_with_touch_handler.html")); |
| + EXPECT_TRUE(NavigateToURL(shell(), main_url)); |
| + |
| + WebContentsImpl* contents = web_contents(); |
| + FrameTreeNode* root = contents->GetFrameTree()->root(); |
| + |
| + // Synchronize with the renderers to guarantee that the |
| + // surface information required for event hit testing is ready. |
| + auto* rwhv = static_cast<RenderWidgetHostViewAura*>( |
| + contents->GetRenderWidgetHostView()); |
| + |
| + // Simulate touch event to sub-frame. |
| + gfx::Point frame_center(150, 150); |
| + |
| + // Wait until renderer's compositor thread is synced. |
| + RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost(); |
| + { |
| + auto observer = |
| + base::MakeUnique<MainThreadFrameObserver>(render_widget_host); |
| + observer->Wait(); |
| + } |
| + |
| + ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, frame_center, 0, 0, |
| + ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); |
| + rwhv->OnTouchEvent(&touch_event); |
| + { |
| + auto observer = |
| + base::MakeUnique<MainThreadFrameObserver>(render_widget_host); |
| + observer->Wait(); |
| + } |
| + |
| + // Verify touch handler in subframe was invoked |
|
Avi (use Gerrit)
2016/11/07 16:15:55
nit: period at end of sentence
wjmaclean
2016/11/07 17:43:17
Done.
|
| + std::string result; |
| + EXPECT_TRUE(ExecuteScriptAndExtractString( |
| + root, "window.domAutomationController.send(getLastTouchEvent());", |
| + &result)); |
| + EXPECT_EQ("touchstart", result); |
| +} |
| + |
| namespace { |
| // Declared here to be close to the SubframeGestureEventRouting test. |