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

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: Address comments. 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 4310 matching lines...) Expand 10 before | Expand all | Expand 10 after
4374 EXPECT_EQ(popup->web_contents()->GetLastCommittedURL(), cross_url); 4381 EXPECT_EQ(popup->web_contents()->GetLastCommittedURL(), cross_url);
4375 4382
4376 // Use new window to navigate main window. 4383 // Use new window to navigate main window.
4377 std::string script = 4384 std::string script =
4378 "window.opener.location.href = '" + cross_url.spec() + "'"; 4385 "window.opener.location.href = '" + cross_url.spec() + "'";
4379 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script)); 4386 EXPECT_TRUE(ExecuteScript(popup->web_contents(), script));
4380 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 4387 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
4381 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url); 4388 EXPECT_EQ(shell()->web_contents()->GetLastCommittedURL(), cross_url);
4382 } 4389 }
4383 4390
4391 // Ensure that a cross-process subframe with a touch-handler can receive touch
4392 // events.
4393 #if defined(AURA)
4394 // Browser process hit testing is not implemented on Android, and this test
4395 // requires Aura for RenderWidgetHostViewAura::OnTouchEvent().
4396 // https://crbug.com/491334
4397 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4398 SubframeTouchEventRouting) {
4399 GURL main_url(embedded_test_server()->GetURL(
4400 "a.com", "/frame_tree/page_with_one_frame.html"));
4401 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4402
4403 WebContentsImpl* web_contents =
4404 static_cast<WebContentsImpl*>(shell()->web_contents());
4405 FrameTreeNode* root = web_contents->GetFrameTree()->root();
4406
4407 GURL frame_url(
4408 embedded_test_server()->GetURL("b.com", "/page_with_touch_handler.html"));
4409 NavigateFrameToURL(root->child_at(0), frame_url);
4410 EXPECT_TRUE(WaitForRenderFrameReady(root->child_at(0)->current_frame_host()));
4411
4412 // Synchronize with the child and parent renderers to guarantee that the
4413 // surface information required for event hit testing is ready.
4414 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>(
4415 root->child_at(0)->current_frame_host()->GetView());
4416 MainThreadFrameObserver child_observer(child_rwhv->GetRenderWidgetHost());
4417 child_observer.Wait();
4418
4419 MainThreadFrameObserver parent_observer(
4420 web_contents->GetRenderWidgetHostView()->GetRenderWidgetHost());
4421 parent_observer.Wait();
4422
4423
4424 // Simulate touch event to sub-frame.
4425 gfx::Point child_center = child_rwhv->GetBoundsInRootWindow().CenterPoint();
4426 auto rwhv = static_cast<RenderWidgetHostViewAura*>(
4427 web_contents->GetRenderWidgetHostView());
4428 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0,
4429 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f);
4430 rwhv->OnTouchEvent(&touch_event);
4431
4432 // Verify touch handler in subframe was invoked
4433 std::string result;
4434 EXPECT_TRUE(ExecuteScriptAndExtractString(
4435 root->child_at(0)->current_frame_host(),
4436 "window.domAutomationController.send(getLastTouchEvent());", &result));
4437 EXPECT_EQ("touchstart", result);
4438 }
4439 #endif // defined(USE_AURA)
4440
4384 // Ensure that a cross-process subframe can receive keyboard events when in 4441 // Ensure that a cross-process subframe can receive keyboard events when in
4385 // focus. 4442 // focus.
4386 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, 4443 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest,
4387 SubframeKeyboardEventRouting) { 4444 SubframeKeyboardEventRouting) {
4388 GURL main_url(embedded_test_server()->GetURL( 4445 GURL main_url(embedded_test_server()->GetURL(
4389 "a.com", "/frame_tree/page_with_one_frame.html")); 4446 "a.com", "/frame_tree/page_with_one_frame.html"));
4390 EXPECT_TRUE(NavigateToURL(shell(), main_url)); 4447 EXPECT_TRUE(NavigateToURL(shell(), main_url));
4391 4448
4392 WebContentsImpl* web_contents = 4449 WebContentsImpl* web_contents =
4393 static_cast<WebContentsImpl*>(shell()->web_contents()); 4450 static_cast<WebContentsImpl*>(shell()->web_contents());
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
5295 5352
5296 // Force the renderer to generate a new frame. 5353 // Force the renderer to generate a new frame.
5297 EXPECT_TRUE(ExecuteScript(shell()->web_contents(), 5354 EXPECT_TRUE(ExecuteScript(shell()->web_contents(),
5298 "document.body.style.background = 'black'")); 5355 "document.body.style.background = 'black'"));
5299 5356
5300 // Waits for the next frame. 5357 // Waits for the next frame.
5301 observer->Wait(); 5358 observer->Wait();
5302 } 5359 }
5303 5360
5304 } // namespace content 5361 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698