 Chromium Code Reviews
 Chromium Code Reviews Issue 1729373003:
  Implement touch events for site-isolation.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1729373003:
  Implement touch events for site-isolation.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| 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 c91e6b1592c5ed9150be7eb3b562882b55a28d60..f640836de824ac7cbc08a578b41bbfcda4c59b6f 100644 | 
| --- a/content/browser/site_per_process_browsertest.cc | 
| +++ b/content/browser/site_per_process_browsertest.cc | 
| @@ -49,8 +49,15 @@ | 
| #include "net/test/embedded_test_server/embedded_test_server.h" | 
| #include "third_party/WebKit/public/web/WebInputEvent.h" | 
| #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 
| +#include "ui/events/event.h" | 
| +#include "ui/events/event_utils.h" | 
| +#include "ui/gfx/geometry/point.h" | 
| #include "ui/gfx/switches.h" | 
| +#if defined(USE_AURA) | 
| +#include "content/browser/renderer_host/render_widget_host_view_aura.h" | 
| +#endif | 
| + | 
| #if defined(OS_MACOSX) | 
| #include "ui/base/test/scoped_preferred_scroller_style_mac.h" | 
| #endif | 
| @@ -4426,6 +4433,56 @@ IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, OpenerSetLocation) { | 
| EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); | 
| } | 
| +// Ensure that a cross-process subframe with a touch-handler can receive touch | 
| +// events. | 
| +#if defined(AURA) | 
| +// Browser process hit testing is not implemented on Android, and this test | 
| +// requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). | 
| +// https://crbug.com/491334 | 
| +IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 
| + SubframeTouchEventRouting) { | 
| + GURL main_url(embedded_test_server()->GetURL( | 
| + "a.com", "/frame_tree/page_with_one_frame.html")); | 
| 
nasko
2016/02/29 22:10:26
You can navigate to "/cross_site_iframe_factory.ht
 
wjmaclean
2016/02/29 23:33:56
Acknowledged.
 | 
| + 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_touch_handler.html")); | 
| 
nasko
2016/02/29 22:10:26
Ah, you need a specific page in the iframe. Feel f
 
wjmaclean
2016/02/29 23:33:55
Done.
 | 
| + NavigateFrameToURL(root->child_at(0), frame_url); | 
| + EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host())); | 
| + | 
| + // Synchronize with the child and parent renderers to guarantee that the | 
| + // surface information required for event hit testing is ready. | 
| + RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | 
| + root->child_at(0)->current_frame_host()->GetView()); | 
| + MainThreadFrameObserver child_observer(child_rwhv->GetRenderWidgetHost()); | 
| + child_observer.Wait(); | 
| + | 
| + MainThreadFrameObserver parent_observer( | 
| + web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost()); | 
| + parent_observer.Wait(); | 
| + | 
| 
nasko
2016/02/29 22:10:26
nit: no need for extra empty line
 
wjmaclean
2016/02/29 23:33:56
Done.
 | 
| + | 
| + // Simulate touch event to sub-frame. | 
| + gfx::Point child_center = child_rwhv->GetBoundsInRootWindow().CenterPoint(); | 
| + auto rwhv = static_cast<RenderWidgetHostViewAura*>( | 
| + web_contents->GetRenderWidgetHostView()); | 
| + 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); | 
| + | 
| + // Verify touch handler in subframe was invoked | 
| + std::string result; | 
| + EXPECT_TRUE(ExecuteScriptAndExtractString( | 
| + root->child_at(0)->current_frame_host(), | 
| + "window.domAutomationController.send(getLastTouchEvent());", &result)); | 
| + EXPECT_EQ("touchstart", result); | 
| +} | 
| +#endif // defined(USE_AURA) | 
| + | 
| // Ensure that a cross-process subframe can receive keyboard events when in | 
| // focus. | 
| IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, |