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

Side by Side Diff: content/browser/site_per_process_browsertest.cc

Issue 1729373003: Implement touch events for site-isolation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use positioned iframe in test to simplify event targeting. Created 4 years, 9 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 unified diff | Download patch
OLDNEW
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
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 4431 matching lines...) Expand 10 before | Expand all | Expand 10 after
4495 EXPECT_EQ(popup->web_contents()->GetLastCommittedURL(), cross_url); 4502 EXPECT_EQ(popup->web_contents()->GetLastCommittedURL(), cross_url);
4496 4503
4497 // Use new window to navigate main window. 4504 // Use new window to navigate main window.
4498 std::string script = 4505 std::string script =
4499 "window.opener.location.href = '" + cross_url.spec() + "'"; 4506 "window.opener.location.href = '" + cross_url.spec() + "'";
4500 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); 4507 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script));
4501 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 4508 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4502 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); 4509 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url);
4503 } 4510 }
4504 4511
4512 // Ensure that a cross-process subframe with a touch-handler can receive touch
4513 // events.
4514 #if defined(USE_AURA)
4515 // Browser process hit testing is not implemented on Android, and this test
4516 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent().
4517 // https://crbug.com/491334
4518 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4519 SubframeTouchEventRouting) {
4520 GURL main_url(embedded_test_server()->GetURL(
4521 "/frame_tree/page_with_positioned_nested_frames.html"));
4522 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4523
4524 WebContentsImpl* web_contents =
4525 static_cast<WebContentsImpl*>(shell()->web_contents());
4526 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4527 ASSERT_EQ(1U, root->child_count());
4528
4529 GURL frame_url(
4530 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html"));
4531 NavigateFrameToURL(root->child_at(0), frame_url);
4532 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host()));
4533
4534 // Synchronize with the child and parent renderers to guarantee that the
4535 // surface information required for event hit testing is ready.
4536 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
4537 root->child_at(0)->current_frame_host()->GetView());
4538 SurfaceHitTestReadyNotifier notifier(
4539 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv));
4540 notifier.WaitForSurfaceReady();
4541
4542 // Simulate touch event to sub-frame.
4543 gfx::Point child_center(150, 150);
4544 auto rwhv = static_cast<RenderWidgetHostViewAura*>(
4545 web_contents->GetRenderWidgetHostView());
4546 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
4547 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
4548 rwhv->OnTouchEvent(&touch_event);
4549
4550 // Verify touch handler in subframe was invoked
4551 std::string result;
4552 EXPECT_TRUE(ExecuteScriptAndExtractString(
4553 root->child_at(0)->current_frame_host(),
4554 "window.domAutomationController.send(getLastTouchEvent());", &result));
4555 EXPECT_EQ("touchstart", result);
4556 }
4557 #endif // defined(USE_AURA)
4558
4505 // Ensure that a cross-process subframe can receive keyboard events when in 4559 // Ensure that a cross-process subframe can receive keyboard events when in
4506 // focus. 4560 // focus.
4507 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4561 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4508 SubframeKeyboardEventRouting) { 4562 SubframeKeyboardEventRouting) {
4509 GURL main_url(embedded_test_server()->GetURL( 4563 GURL main_url(embedded_test_server()->GetURL(
4510 "a.com", "/frame_tree/page_with_one_frame.html")); 4564 "a.com", "/frame_tree/page_with_one_frame.html"));
4511 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4565 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4512 4566
4513 WebContentsImpl* web_contents = 4567 WebContentsImpl* web_contents =
4514 static_cast<WebContentsImpl*>(shell()->web_contents()); 4568 static_cast<WebContentsImpl*>(shell()->web_contents());
(...skipping 905 matching lines...) Expand 10 before | Expand all | Expand 10 after
5420 5474
5421 // Force the renderer to generate a new frame. 5475 // Force the renderer to generate a new frame.
5422 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5476 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5423 "document.body.style.background = 'black'")); 5477 "document.body.style.background = 'black'"));
5424 5478
5425 // Waits for the next frame. 5479 // Waits for the next frame.
5426 observer->Wait(); 5480 observer->Wait();
5427 } 5481 }
5428 5482
5429 } // namespace content 5483 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | content/browser/web_contents/web_contents_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698