 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| OLD | NEW | 
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be | 
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. | 
| 4 | 4 | 
| 5 #include "content/browser/site_per_process_browsertest.h" | 5 #include "content/browser/site_per_process_browsertest.h" | 
| 6 | 6 | 
| 7 #include <stddef.h> | 7 #include <stddef.h> | 
| 8 #include <stdint.h> | 8 #include <stdint.h> | 
| 9 | 9 | 
| 10 #include <algorithm> | 10 #include <algorithm> | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 42 #include "content/public/test/test_navigation_observer.h" | 42 #include "content/public/test/test_navigation_observer.h" | 
| 43 #include "content/public/test/test_utils.h" | 43 #include "content/public/test/test_utils.h" | 
| 44 #include "content/shell/browser/shell.h" | 44 #include "content/shell/browser/shell.h" | 
| 45 #include "content/test/content_browser_test_utils_internal.h" | 45 #include "content/test/content_browser_test_utils_internal.h" | 
| 46 #include "content/test/test_frame_navigation_observer.h" | 46 #include "content/test/test_frame_navigation_observer.h" | 
| 47 #include "ipc/ipc_security_test_util.h" | 47 #include "ipc/ipc_security_test_util.h" | 
| 48 #include "net/dns/mock_host_resolver.h" | 48 #include "net/dns/mock_host_resolver.h" | 
| 49 #include "net/test/embedded_test_server/embedded_test_server.h" | 49 #include "net/test/embedded_test_server/embedded_test_server.h" | 
| 50 #include "third_party/WebKit/public/web/WebInputEvent.h" | 50 #include "third_party/WebKit/public/web/WebInputEvent.h" | 
| 51 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 51 #include "third_party/WebKit/public/web/WebSandboxFlags.h" | 
| 52 #include "ui/events/event.h" | |
| 53 #include "ui/events/event_utils.h" | |
| 54 #include "ui/gfx/geometry/point.h" | |
| 52 #include "ui/gfx/switches.h" | 55 #include "ui/gfx/switches.h" | 
| 53 | 56 | 
| 57 #if defined(USE_AURA) | |
| 58 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | |
| 59 #endif | |
| 60 | |
| 54 #if defined(OS_MACOSX) | 61 #if defined(OS_MACOSX) | 
| 55 #include "ui/base/test/scoped_preferred_scroller_style_mac.h" | 62 #include "ui/base/test/scoped_preferred_scroller_style_mac.h" | 
| 56 #endif | 63 #endif | 
| 57 | 64 | 
| 58 namespace content { | 65 namespace content { | 
| 59 | 66 | 
| 60 namespace { | 67 namespace { | 
| 61 | 68 | 
| 62 // Helper function to send a postMessage and wait for a reply message. The | 69 // Helper function to send a postMessage and wait for a reply message. The | 
| 63 // |post_message_script| is executed on the |sender_ftn| frame, and the sender | 70 // |post_message_script| is executed on the |sender_ftn| frame, and the sender | 
| (...skipping 4355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4419 EXPECT_EQ(popup->web_contents()->GetLastCommittedURL(), cross_url); | 4426 EXPECT_EQ(popup->web_contents()->GetLastCommittedURL(), cross_url); | 
| 4420 | 4427 | 
| 4421 // Use new window to navigate main window. | 4428 // Use new window to navigate main window. | 
| 4422 std::string script = | 4429 std::string script = | 
| 4423 "window.opener.location.href = '" + cross_url.spec() + "'"; | 4430 "window.opener.location.href = '" + cross_url.spec() + "'"; | 
| 4424 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); | 4431 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); | 
| 4425 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 4432 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 
| 4426 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); | 4433 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); | 
| 4427 } | 4434 } | 
| 4428 | 4435 | 
| 4436 // Ensure that a cross-process subframe with a touch-handler can receive touch | |
| 4437 // events. | |
| 4438 #if defined(AURA) | |
| 4439 // Browser process hit testing is not implemented on Android, and this test | |
| 4440 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent(). | |
| 4441 // https://crbug.com/491334 | |
| 4442 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
| 4443 SubframeTouchEventRouting) { | |
| 4444 GURL main_url(embedded_test_server()->GetURL( | |
| 4445 "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.
 | |
| 4446 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
| 4447 | |
| 4448 WebContentsImpl* web_contents = | |
| 4449 static_cast<WebContentsImpl*>(shell()->web_contents()); | |
| 4450 FrameTreeNode* root = web_contents->GetFrameTree()->root(); | |
| 4451 | |
| 4452 GURL frame_url( | |
| 4453 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.
 | |
| 4454 NavigateFrameToURL(root->child_at(0), frame_url); | |
| 4455 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host())); | |
| 4456 | |
| 4457 // Synchronize with the child and parent renderers to guarantee that the | |
| 4458 // surface information required for event hit testing is ready. | |
| 4459 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | |
| 4460 root->child_at(0)->current_frame_host()->GetView()); | |
| 4461 MainThreadFrameObserver child_observer(child_rwhv->GetRenderWidgetHost()); | |
| 4462 child_observer.Wait(); | |
| 4463 | |
| 4464 MainThreadFrameObserver parent_observer( | |
| 4465 web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost()); | |
| 4466 parent_observer.Wait(); | |
| 4467 | |
| 
nasko
2016/02/29 22:10:26
nit: no need for extra empty line
 
wjmaclean
2016/02/29 23:33:56
Done.
 | |
| 4468 | |
| 4469 // Simulate touch event to sub-frame. | |
| 4470 gfx::Point child_center = child_rwhv->GetBoundsInRootWindow().CenterPoint(); | |
| 4471 auto rwhv = static_cast<RenderWidgetHostViewAura*>( | |
| 4472 web_contents->GetRenderWidgetHostView()); | |
| 4473 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, | |
| 4474 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | |
| 4475 rwhv->OnTouchEvent(&touch_event); | |
| 4476 | |
| 4477 // Verify touch handler in subframe was invoked | |
| 4478 std::string result; | |
| 4479 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
| 4480 root->child_at(0)->current_frame_host(), | |
| 4481 "window.domAutomationController.send(getLastTouchEvent());", &result)); | |
| 4482 EXPECT_EQ("touchstart", result); | |
| 4483 } | |
| 4484 #endif // defined(USE_AURA) | |
| 4485 | |
| 4429 // Ensure that a cross-process subframe can receive keyboard events when in | 4486 // Ensure that a cross-process subframe can receive keyboard events when in | 
| 4430 // focus. | 4487 // focus. | 
| 4431 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 4488 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | 
| 4432 SubframeKeyboardEventRouting) { | 4489 SubframeKeyboardEventRouting) { | 
| 4433 GURL main_url(embedded_test_server()->GetURL( | 4490 GURL main_url(embedded_test_server()->GetURL( | 
| 4434 "a.com", "/frame_tree/page_with_one_frame.html")); | 4491 "a.com", "/frame_tree/page_with_one_frame.html")); | 
| 4435 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 4492 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | 
| 4436 | 4493 | 
| 4437 WebContentsImpl* web_contents = | 4494 WebContentsImpl* web_contents = | 
| 4438 static_cast<WebContentsImpl*>(shell()->web_contents()); | 4495 static_cast<WebContentsImpl*>(shell()->web_contents()); | 
| (...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5344 | 5401 | 
| 5345 // Force the renderer to generate a new frame. | 5402 // Force the renderer to generate a new frame. | 
| 5346 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 5403 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), | 
| 5347 "document.body.style.background = 'black'")); | 5404 "document.body.style.background = 'black'")); | 
| 5348 | 5405 | 
| 5349 // Waits for the next frame. | 5406 // Waits for the next frame. | 
| 5350 observer->Wait(); | 5407 observer->Wait(); | 
| 5351 } | 5408 } | 
| 5352 | 5409 | 
| 5353 } // namespace content | 5410 } // namespace content | 
| OLD | NEW |