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 5364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5375 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( | 5375 RenderWidgetHostViewBase* child_rwhv = static_cast<RenderWidgetHostViewBase*>( |
5376 root->child_at(0)->current_frame_host()->GetView()); | 5376 root->child_at(0)->current_frame_host()->GetView()); |
5377 SurfaceHitTestReadyNotifier notifier( | 5377 SurfaceHitTestReadyNotifier notifier( |
5378 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); | 5378 static_cast<RenderWidgetHostViewChildFrame*>(child_rwhv)); |
5379 notifier.WaitForSurfaceReady(); | 5379 notifier.WaitForSurfaceReady(); |
5380 | 5380 |
5381 // Simulate touch event to sub-frame. | 5381 // Simulate touch event to sub-frame. |
5382 gfx::Point child_center(150, 150); | 5382 gfx::Point child_center(150, 150); |
5383 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( | 5383 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( |
5384 contents->GetRenderWidgetHostView()); | 5384 contents->GetRenderWidgetHostView()); |
5385 | |
5386 // Wait until renderer's compositor thread is synced. | |
5387 RenderWidgetHost* child_render_widget_host = | |
5388 root->child_at(0)->current_frame_host()->GetRenderWidgetHost(); | |
5389 { | |
5390 auto observer = | |
5391 base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host); | |
5392 observer->Wait(); | |
5393 } | |
5394 | |
5385 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, | 5395 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, child_center, 0, 0, |
5386 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | 5396 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); |
5387 rwhv->OnTouchEvent(&touch_event); | 5397 rwhv->OnTouchEvent(&touch_event); |
5398 { | |
5399 auto observer = | |
5400 base::MakeUnique<MainThreadFrameObserver>(child_render_widget_host); | |
5401 observer->Wait(); | |
5402 } | |
5388 | 5403 |
5389 // Verify touch handler in subframe was invoked | 5404 // Verify touch handler in subframe was invoked. |
5390 std::string result; | 5405 std::string result; |
5391 EXPECT_TRUE(ExecuteScriptAndExtractString( | 5406 EXPECT_TRUE(ExecuteScriptAndExtractString( |
5392 root->child_at(0), | 5407 root->child_at(0), |
5393 "window.domAutomationController.send(getLastTouchEvent());", &result)); | 5408 "window.domAutomationController.send(getLastTouchEvent());", &result)); |
5394 EXPECT_EQ("touchstart", result); | 5409 EXPECT_EQ("touchstart", result); |
5395 } | 5410 } |
5396 | 5411 |
5412 // This test verifies that the test in | |
5413 // SitePerProcessBrowserTest.SubframeTouchEventRouting also works properly for | |
5414 // the main frame. Prior to the CL in which this test is introduced, use of | |
5415 // MainThreadFrameObserver in SubframeTouchEventRouting was not necessary since | |
5416 // the touch events were handled on the main thread. Now they are handled on the | |
5417 // compositor thread, hence the need to synchronize. | |
5418 IN_PROC_BROWSER_TEST_F(SitePerProcessBrowserTest, | |
5419 MainframeTouchEventRouting) { | |
5420 GURL main_url(embedded_test_server()->GetURL( | |
5421 "/page_with_touch_handler.html")); | |
5422 EXPECT_TRUE(NavigateToURL(shell(), main_url)); | |
5423 | |
5424 WebContentsImpl* contents = web_contents(); | |
5425 FrameTreeNode* root = contents->GetFrameTree()->root(); | |
5426 | |
5427 // Synchronize with the renderers to guarantee that the | |
5428 // surface information required for event hit testing is ready. | |
5429 auto* rwhv = static_cast<RenderWidgetHostViewAura*>( | |
5430 contents->GetRenderWidgetHostView()); | |
5431 | |
5432 // Simulate touch event to sub-frame. | |
5433 gfx::Point frame_center(150, 150); | |
5434 | |
5435 // Wait until renderer's compositor thread is synced. | |
5436 RenderWidgetHost* render_widget_host = rwhv->GetRenderWidgetHost(); | |
5437 { | |
5438 auto observer = | |
5439 base::MakeUnique<MainThreadFrameObserver>(render_widget_host); | |
5440 observer->Wait(); | |
5441 } | |
5442 | |
5443 ui::TouchEvent touch_event(ui::ET_TOUCH_PRESSED, frame_center, 0, 0, | |
5444 ui::EventTimeForNow(), 30.f, 30.f, 0.f, 0.f); | |
5445 rwhv->OnTouchEvent(&touch_event); | |
5446 { | |
5447 auto observer = | |
5448 base::MakeUnique<MainThreadFrameObserver>(render_widget_host); | |
dcheng
2017/01/16 11:05:40
Nit: this can just be directly on the stack:
Main
wjmaclean
2017/01/17 18:23:27
Done.
| |
5449 observer->Wait(); | |
5450 } | |
5451 | |
5452 // Verify touch handler in subframe was invoked. | |
5453 std::string result; | |
5454 EXPECT_TRUE(ExecuteScriptAndExtractString( | |
5455 root, "window.domAutomationController.send(getLastTouchEvent());", | |
5456 &result)); | |
5457 EXPECT_EQ("touchstart", result); | |
5458 } | |
5459 | |
5397 namespace { | 5460 namespace { |
5398 | 5461 |
5399 // Declared here to be close to the SubframeGestureEventRouting test. | 5462 // Declared here to be close to the SubframeGestureEventRouting test. |
5400 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, | 5463 void OnSyntheticGestureCompleted(scoped_refptr<MessageLoopRunner> runner, |
5401 SyntheticGesture::Result result) { | 5464 SyntheticGesture::Result result) { |
5402 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); | 5465 EXPECT_EQ(SyntheticGesture::GESTURE_FINISHED, result); |
5403 runner->Quit(); | 5466 runner->Quit(); |
5404 } | 5467 } |
5405 | 5468 |
5406 } // namespace anonymous | 5469 } // namespace anonymous |
(...skipping 3584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8991 rfh->OnSwappedOut(); | 9054 rfh->OnSwappedOut(); |
8992 | 9055 |
8993 // Wait for the new a.com navigation to finish. | 9056 // Wait for the new a.com navigation to finish. |
8994 back_observer.Wait(); | 9057 back_observer.Wait(); |
8995 | 9058 |
8996 // The RVH for a.com should've been reused, and it should be active. | 9059 // The RVH for a.com should've been reused, and it should be active. |
8997 EXPECT_TRUE(rvh->is_active()); | 9060 EXPECT_TRUE(rvh->is_active()); |
8998 } | 9061 } |
8999 | 9062 |
9000 } // namespace content | 9063 } // namespace content |
OLD | NEW |