| 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 #include "content/common/view_messages.h" | 57 #include "content/common/view_messages.h" |
| 58 #include "content/public/browser/browser_context.h" | 58 #include "content/public/browser/browser_context.h" |
| 59 #include "content/public/browser/browser_thread.h" | 59 #include "content/public/browser/browser_thread.h" |
| 60 #include "content/public/browser/interstitial_page_delegate.h" | 60 #include "content/public/browser/interstitial_page_delegate.h" |
| 61 #include "content/public/browser/navigation_handle.h" | 61 #include "content/public/browser/navigation_handle.h" |
| 62 #include "content/public/browser/notification_observer.h" | 62 #include "content/public/browser/notification_observer.h" |
| 63 #include "content/public/browser/notification_service.h" | 63 #include "content/public/browser/notification_service.h" |
| 64 #include "content/public/browser/notification_types.h" | 64 #include "content/public/browser/notification_types.h" |
| 65 #include "content/public/browser/resource_dispatcher_host.h" | 65 #include "content/public/browser/resource_dispatcher_host.h" |
| 66 #include "content/public/common/browser_side_navigation_policy.h" | 66 #include "content/public/common/browser_side_navigation_policy.h" |
| 67 #include "content/public/common/content_features.h" |
| 67 #include "content/public/common/content_switches.h" | 68 #include "content/public/common/content_switches.h" |
| 68 #include "content/public/common/url_constants.h" | 69 #include "content/public/common/url_constants.h" |
| 69 #include "content/public/test/browser_test_utils.h" | 70 #include "content/public/test/browser_test_utils.h" |
| 70 #include "content/public/test/content_browser_test_utils.h" | 71 #include "content/public/test/content_browser_test_utils.h" |
| 71 #include "content/public/test/navigation_handle_observer.h" | 72 #include "content/public/test/navigation_handle_observer.h" |
| 72 #include "content/public/test/test_frame_navigation_observer.h" | 73 #include "content/public/test/test_frame_navigation_observer.h" |
| 73 #include "content/public/test/test_navigation_observer.h" | 74 #include "content/public/test/test_navigation_observer.h" |
| 74 #include "content/public/test/test_utils.h" | 75 #include "content/public/test/test_utils.h" |
| 75 #include "content/shell/browser/shell.h" | 76 #include "content/shell/browser/shell.h" |
| 76 #include "content/test/content_browser_test_utils_internal.h" | 77 #include "content/test/content_browser_test_utils_internal.h" |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // This helper accounts for Android devices which use page scale factor | 261 // This helper accounts for Android devices which use page scale factor |
| 261 // different from 1.0. Coordinate targeting needs to be adjusted before | 262 // different from 1.0. Coordinate targeting needs to be adjusted before |
| 262 // hit testing. | 263 // hit testing. |
| 263 double GetPageScaleFactor(Shell* shell) { | 264 double GetPageScaleFactor(Shell* shell) { |
| 264 return RenderWidgetHostImpl::From( | 265 return RenderWidgetHostImpl::From( |
| 265 shell->web_contents()->GetRenderViewHost()->GetWidget()) | 266 shell->web_contents()->GetRenderViewHost()->GetWidget()) |
| 266 ->last_frame_metadata() | 267 ->last_frame_metadata() |
| 267 .page_scale_factor; | 268 .page_scale_factor; |
| 268 } | 269 } |
| 269 | 270 |
| 271 bool callback_received = false; |
| 272 int received_frame_id = -2; |
| 273 |
| 274 void callback(int frame_id) { |
| 275 received_frame_id = frame_id; |
| 276 callback_received = true; |
| 277 } |
| 278 |
| 270 // Helper function that performs a surface hittest. | 279 // Helper function that performs a surface hittest. |
| 271 void SurfaceHitTestTestHelper( | 280 void SurfaceHitTestTestHelper( |
| 272 Shell* shell, | 281 Shell* shell, |
| 273 net::test_server::EmbeddedTestServer* embedded_test_server) { | 282 net::test_server::EmbeddedTestServer* embedded_test_server) { |
| 274 GURL main_url(embedded_test_server->GetURL( | 283 GURL main_url(embedded_test_server->GetURL( |
| 275 "/frame_tree/page_with_positioned_frame.html")); | 284 "/frame_tree/page_with_positioned_frame.html")); |
| 276 EXPECT_TRUE(NavigateToURL(shell, main_url)); | 285 EXPECT_TRUE(NavigateToURL(shell, main_url)); |
| 277 | 286 |
| 278 // It is safe to obtain the root frame tree node here, as it doesn't change. | 287 // It is safe to obtain the root frame tree node here, as it doesn't change. |
| 279 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) | 288 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell->web_contents()) |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 blink::WebInputEvent::kTimeStampForTesting); | 326 blink::WebInputEvent::kTimeStampForTesting); |
| 318 child_event.button = blink::WebPointerProperties::Button::kLeft; | 327 child_event.button = blink::WebPointerProperties::Button::kLeft; |
| 319 child_event.SetPositionInWidget( | 328 child_event.SetPositionInWidget( |
| 320 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x() + 5) * | 329 gfx::ToCeiledInt((bounds.x() - root_view->GetViewBounds().x() + 5) * |
| 321 scale_factor), | 330 scale_factor), |
| 322 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y() + 5) * | 331 gfx::ToCeiledInt((bounds.y() - root_view->GetViewBounds().y() + 5) * |
| 323 scale_factor)); | 332 scale_factor)); |
| 324 child_event.click_count = 1; | 333 child_event.click_count = 1; |
| 325 main_frame_monitor.ResetEventReceived(); | 334 main_frame_monitor.ResetEventReceived(); |
| 326 child_frame_monitor.ResetEventReceived(); | 335 child_frame_monitor.ResetEventReceived(); |
| 336 |
| 337 callback_received = false; |
| 338 root->current_frame_host()->GetFrameInputHandler()->HitTestFrameAt( |
| 339 (gfx::PointF)child_event.PositionInWidget(), base::Bind(&callback)); |
| 340 while (!callback_received) { |
| 341 base::RunLoop run_loop; |
| 342 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 343 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout()); |
| 344 run_loop.Run(); |
| 345 } |
| 346 ASSERT_EQ(4, received_frame_id); |
| 347 |
| 327 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); | 348 router->RouteMouseEvent(root_view, &child_event, ui::LatencyInfo()); |
| 328 | 349 |
| 329 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); | 350 EXPECT_TRUE(child_frame_monitor.EventWasReceived()); |
| 330 // The expected result coordinates are (5, 5), but can get slightly | 351 // The expected result coordinates are (5, 5), but can get slightly |
| 331 // different results due to rounding error with some page scale factors. | 352 // different results due to rounding error with some page scale factors. |
| 332 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().x, 2); | 353 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().x, 2); |
| 333 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().y, 2); | 354 EXPECT_NEAR(5, child_frame_monitor.event().PositionInWidget().y, 2); |
| 334 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); | 355 EXPECT_FALSE(main_frame_monitor.EventWasReceived()); |
| 335 | 356 |
| 336 child_frame_monitor.ResetEventReceived(); | 357 child_frame_monitor.ResetEventReceived(); |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { | 633 SitePerProcessBrowserTest::SitePerProcessBrowserTest() { |
| 613 }; | 634 }; |
| 614 | 635 |
| 615 std::string SitePerProcessBrowserTest::DepictFrameTree(FrameTreeNode* node) { | 636 std::string SitePerProcessBrowserTest::DepictFrameTree(FrameTreeNode* node) { |
| 616 return visualizer_.DepictFrameTree(node); | 637 return visualizer_.DepictFrameTree(node); |
| 617 } | 638 } |
| 618 | 639 |
| 619 void SitePerProcessBrowserTest::SetUpCommandLine( | 640 void SitePerProcessBrowserTest::SetUpCommandLine( |
| 620 base::CommandLine* command_line) { | 641 base::CommandLine* command_line) { |
| 621 IsolateAllSitesForTesting(command_line); | 642 IsolateAllSitesForTesting(command_line); |
| 643 std::vector<base::StringPiece> enabled_features; |
| 644 std::vector<base::StringPiece> disabled_features; |
| 645 enabled_features.push_back(features::kMojoInputMessages.name); |
| 622 #if !defined(OS_ANDROID) | 646 #if !defined(OS_ANDROID) |
| 623 // TODO(bokan): Needed for scrollability check in | 647 // TODO(bokan): Needed for scrollability check in |
| 624 // FrameOwnerPropertiesPropagationScrolling. crbug.com/662196. | 648 // FrameOwnerPropertiesPropagationScrolling. crbug.com/662196. |
| 625 feature_list_.InitAndDisableFeature(features::kOverlayScrollbar); | 649 disabled_features.push_back(features::kOverlayScrollbar.name); |
| 626 #endif | 650 #endif |
| 651 feature_list_.InitFromCommandLine(base::JoinString(enabled_features, ","), |
| 652 base::JoinString(disabled_features, ",")); |
| 627 } | 653 } |
| 628 | 654 |
| 629 void SitePerProcessBrowserTest::SetUpOnMainThread() { | 655 void SitePerProcessBrowserTest::SetUpOnMainThread() { |
| 630 host_resolver()->AddRule("*", "127.0.0.1"); | 656 host_resolver()->AddRule("*", "127.0.0.1"); |
| 631 SetupCrossSiteRedirector(embedded_test_server()); | 657 SetupCrossSiteRedirector(embedded_test_server()); |
| 632 ASSERT_TRUE(embedded_test_server()->Start()); | 658 ASSERT_TRUE(embedded_test_server()->Start()); |
| 633 } | 659 } |
| 634 | 660 |
| 635 // | 661 // |
| 636 // SitePerProcessHighDPIBrowserTest | 662 // SitePerProcessHighDPIBrowserTest |
| (...skipping 9554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10191 // Go back again. This should go to foo.com. | 10217 // Go back again. This should go to foo.com. |
| 10192 { | 10218 { |
| 10193 TestNavigationObserver back_observer(web_contents()); | 10219 TestNavigationObserver back_observer(web_contents()); |
| 10194 web_contents()->GetController().GoBack(); | 10220 web_contents()->GetController().GoBack(); |
| 10195 back_observer.Wait(); | 10221 back_observer.Wait(); |
| 10196 } | 10222 } |
| 10197 EXPECT_EQ(foo_url, web_contents()->GetMainFrame()->GetLastCommittedURL()); | 10223 EXPECT_EQ(foo_url, web_contents()->GetMainFrame()->GetLastCommittedURL()); |
| 10198 } | 10224 } |
| 10199 | 10225 |
| 10200 } // namespace content | 10226 } // namespace content |
| OLD | NEW |