OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/macros.h" | 5 #include "base/macros.h" |
6 #include "base/strings/utf_string_conversions.h" | 6 #include "base/strings/utf_string_conversions.h" |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "content/browser/frame_host/navigation_entry_impl.h" | 9 #include "content/browser/frame_host/navigation_entry_impl.h" |
10 #include "content/browser/renderer_host/render_widget_host_impl.h" | 10 #include "content/browser/renderer_host/render_widget_host_impl.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 // Test that RenderViewHost is created and updated at the size specified by | 276 // Test that RenderViewHost is created and updated at the size specified by |
277 // WebContentsDelegate::GetSizeForNewRenderView(). | 277 // WebContentsDelegate::GetSizeForNewRenderView(). |
278 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 278 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
279 MAYBE_GetSizeForNewRenderView) { | 279 MAYBE_GetSizeForNewRenderView) { |
280 ASSERT_TRUE(embedded_test_server()->Start()); | 280 ASSERT_TRUE(embedded_test_server()->Start()); |
281 // Create a new server with a different site. | 281 // Create a new server with a different site. |
282 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); | 282 net::EmbeddedTestServer https_server(net::EmbeddedTestServer::TYPE_HTTPS); |
283 https_server.ServeFilesFromSourceDirectory("content/test/data"); | 283 https_server.ServeFilesFromSourceDirectory("content/test/data"); |
284 ASSERT_TRUE(https_server.Start()); | 284 ASSERT_TRUE(https_server.Start()); |
285 | 285 |
286 scoped_ptr<RenderViewSizeDelegate> delegate(new RenderViewSizeDelegate()); | 286 std::unique_ptr<RenderViewSizeDelegate> delegate( |
| 287 new RenderViewSizeDelegate()); |
287 shell()->web_contents()->SetDelegate(delegate.get()); | 288 shell()->web_contents()->SetDelegate(delegate.get()); |
288 ASSERT_TRUE(shell()->web_contents()->GetDelegate() == delegate.get()); | 289 ASSERT_TRUE(shell()->web_contents()->GetDelegate() == delegate.get()); |
289 | 290 |
290 // When no size is set, RenderWidgetHostView adopts the size of | 291 // When no size is set, RenderWidgetHostView adopts the size of |
291 // WebContentsView. | 292 // WebContentsView. |
292 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")); | 293 NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")); |
293 EXPECT_EQ(shell()->web_contents()->GetContainerBounds().size(), | 294 EXPECT_EQ(shell()->web_contents()->GetContainerBounds().size(), |
294 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). | 295 shell()->web_contents()->GetRenderWidgetHostView()->GetViewBounds(). |
295 size()); | 296 size()); |
296 | 297 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 | 462 |
462 // The observer should've seen a RenderFrameCreated call for the new frame | 463 // The observer should've seen a RenderFrameCreated call for the new frame |
463 // and not the old one. | 464 // and not the old one. |
464 EXPECT_NE(observer.last_rfh(), orig_rfh); | 465 EXPECT_NE(observer.last_rfh(), orig_rfh); |
465 EXPECT_EQ(observer.last_rfh(), shell()->web_contents()->GetMainFrame()); | 466 EXPECT_EQ(observer.last_rfh(), shell()->web_contents()->GetMainFrame()); |
466 } | 467 } |
467 | 468 |
468 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 469 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
469 LoadingStateChangedForSameDocumentNavigation) { | 470 LoadingStateChangedForSameDocumentNavigation) { |
470 ASSERT_TRUE(embedded_test_server()->Start()); | 471 ASSERT_TRUE(embedded_test_server()->Start()); |
471 scoped_ptr<LoadingStateChangedDelegate> delegate( | 472 std::unique_ptr<LoadingStateChangedDelegate> delegate( |
472 new LoadingStateChangedDelegate()); | 473 new LoadingStateChangedDelegate()); |
473 shell()->web_contents()->SetDelegate(delegate.get()); | 474 shell()->web_contents()->SetDelegate(delegate.get()); |
474 | 475 |
475 LoadStopNotificationObserver load_observer( | 476 LoadStopNotificationObserver load_observer( |
476 &shell()->web_contents()->GetController()); | 477 &shell()->web_contents()->GetController()); |
477 TitleWatcher title_watcher(shell()->web_contents(), | 478 TitleWatcher title_watcher(shell()->web_contents(), |
478 base::ASCIIToUTF16("pushState")); | 479 base::ASCIIToUTF16("pushState")); |
479 NavigateToURL(shell(), embedded_test_server()->GetURL("/push_state.html")); | 480 NavigateToURL(shell(), embedded_test_server()->GetURL("/push_state.html")); |
480 load_observer.Wait(); | 481 load_observer.Wait(); |
481 base::string16 title = title_watcher.WaitAndGetTitle(); | 482 base::string16 title = title_watcher.WaitAndGetTitle(); |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 did_stop_loading = true; | 541 did_stop_loading = true; |
541 } | 542 } |
542 | 543 |
543 bool did_start_loading; | 544 bool did_start_loading; |
544 std::vector<double> progresses; | 545 std::vector<double> progresses; |
545 bool did_stop_loading; | 546 bool did_stop_loading; |
546 }; | 547 }; |
547 | 548 |
548 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) { | 549 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgress) { |
549 ASSERT_TRUE(embedded_test_server()->Start()); | 550 ASSERT_TRUE(embedded_test_server()->Start()); |
550 scoped_ptr<LoadProgressDelegateAndObserver> delegate( | 551 std::unique_ptr<LoadProgressDelegateAndObserver> delegate( |
551 new LoadProgressDelegateAndObserver(shell())); | 552 new LoadProgressDelegateAndObserver(shell())); |
552 | 553 |
553 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 554 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
554 | 555 |
555 const std::vector<double>& progresses = delegate->progresses; | 556 const std::vector<double>& progresses = delegate->progresses; |
556 // All updates should be in order ... | 557 // All updates should be in order ... |
557 if (std::adjacent_find(progresses.begin(), | 558 if (std::adjacent_find(progresses.begin(), |
558 progresses.end(), | 559 progresses.end(), |
559 std::greater<double>()) != progresses.end()) { | 560 std::greater<double>()) != progresses.end()) { |
560 ADD_FAILURE() << "Progress values should be in order: " | 561 ADD_FAILURE() << "Progress values should be in order: " |
561 << ::testing::PrintToString(progresses); | 562 << ::testing::PrintToString(progresses); |
562 } | 563 } |
563 | 564 |
564 // ... and the last one should be 1.0, meaning complete. | 565 // ... and the last one should be 1.0, meaning complete. |
565 ASSERT_GE(progresses.size(), 1U) | 566 ASSERT_GE(progresses.size(), 1U) |
566 << "There should be at least one progress update"; | 567 << "There should be at least one progress update"; |
567 EXPECT_EQ(1.0, *progresses.rbegin()); | 568 EXPECT_EQ(1.0, *progresses.rbegin()); |
568 } | 569 } |
569 | 570 |
570 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgressWithFrames) { | 571 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, LoadProgressWithFrames) { |
571 ASSERT_TRUE(embedded_test_server()->Start()); | 572 ASSERT_TRUE(embedded_test_server()->Start()); |
572 scoped_ptr<LoadProgressDelegateAndObserver> delegate( | 573 std::unique_ptr<LoadProgressDelegateAndObserver> delegate( |
573 new LoadProgressDelegateAndObserver(shell())); | 574 new LoadProgressDelegateAndObserver(shell())); |
574 | 575 |
575 NavigateToURL(shell(), | 576 NavigateToURL(shell(), |
576 embedded_test_server()->GetURL("/frame_tree/top.html")); | 577 embedded_test_server()->GetURL("/frame_tree/top.html")); |
577 | 578 |
578 const std::vector<double>& progresses = delegate->progresses; | 579 const std::vector<double>& progresses = delegate->progresses; |
579 // All updates should be in order ... | 580 // All updates should be in order ... |
580 if (std::adjacent_find(progresses.begin(), | 581 if (std::adjacent_find(progresses.begin(), |
581 progresses.end(), | 582 progresses.end(), |
582 std::greater<double>()) != progresses.end()) { | 583 std::greater<double>()) != progresses.end()) { |
(...skipping 14 matching lines...) Expand all Loading... |
597 host_resolver()->AddRule("*", "127.0.0.1"); | 598 host_resolver()->AddRule("*", "127.0.0.1"); |
598 ASSERT_TRUE(embedded_test_server()->Start()); | 599 ASSERT_TRUE(embedded_test_server()->Start()); |
599 | 600 |
600 // Start at a real page. | 601 // Start at a real page. |
601 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 602 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
602 | 603 |
603 // Simulate a navigation that has not completed. | 604 // Simulate a navigation that has not completed. |
604 const GURL kURL2 = embedded_test_server()->GetURL("/title2.html"); | 605 const GURL kURL2 = embedded_test_server()->GetURL("/title2.html"); |
605 NavigationStallDelegate stall_delegate(kURL2); | 606 NavigationStallDelegate stall_delegate(kURL2); |
606 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); | 607 ResourceDispatcherHost::Get()->SetDelegate(&stall_delegate); |
607 scoped_ptr<LoadProgressDelegateAndObserver> delegate( | 608 std::unique_ptr<LoadProgressDelegateAndObserver> delegate( |
608 new LoadProgressDelegateAndObserver(shell())); | 609 new LoadProgressDelegateAndObserver(shell())); |
609 shell()->LoadURL(kURL2); | 610 shell()->LoadURL(kURL2); |
610 EXPECT_TRUE(delegate->did_start_loading); | 611 EXPECT_TRUE(delegate->did_start_loading); |
611 EXPECT_FALSE(delegate->did_stop_loading); | 612 EXPECT_FALSE(delegate->did_stop_loading); |
612 | 613 |
613 // Also simulate a DidChangeLoadProgress, but not a DidStopLoading. | 614 // Also simulate a DidChangeLoadProgress, but not a DidStopLoading. |
614 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( | 615 RenderFrameHostImpl* main_frame = static_cast<RenderFrameHostImpl*>( |
615 shell()->web_contents()->GetMainFrame()); | 616 shell()->web_contents()->GetMainFrame()); |
616 FrameHostMsg_DidChangeLoadProgress progress_msg(main_frame->GetRoutingID(), | 617 FrameHostMsg_DidChangeLoadProgress progress_msg(main_frame->GetRoutingID(), |
617 1.0); | 618 1.0); |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
657 // See: http://crbug.com/395664 | 658 // See: http://crbug.com/395664 |
658 #if defined(OS_ANDROID) | 659 #if defined(OS_ANDROID) |
659 #define MAYBE_FirstVisuallyNonEmptyPaint DISABLED_FirstVisuallyNonEmptyPaint | 660 #define MAYBE_FirstVisuallyNonEmptyPaint DISABLED_FirstVisuallyNonEmptyPaint |
660 #else | 661 #else |
661 // http://crbug.com/398471 | 662 // http://crbug.com/398471 |
662 #define MAYBE_FirstVisuallyNonEmptyPaint DISABLED_FirstVisuallyNonEmptyPaint | 663 #define MAYBE_FirstVisuallyNonEmptyPaint DISABLED_FirstVisuallyNonEmptyPaint |
663 #endif | 664 #endif |
664 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, | 665 IN_PROC_BROWSER_TEST_F(WebContentsImplBrowserTest, |
665 MAYBE_FirstVisuallyNonEmptyPaint) { | 666 MAYBE_FirstVisuallyNonEmptyPaint) { |
666 ASSERT_TRUE(embedded_test_server()->Start()); | 667 ASSERT_TRUE(embedded_test_server()->Start()); |
667 scoped_ptr<FirstVisuallyNonEmptyPaintObserver> observer( | 668 std::unique_ptr<FirstVisuallyNonEmptyPaintObserver> observer( |
668 new FirstVisuallyNonEmptyPaintObserver(shell())); | 669 new FirstVisuallyNonEmptyPaintObserver(shell())); |
669 | 670 |
670 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); | 671 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")); |
671 | 672 |
672 observer->WaitForDidFirstVisuallyNonEmptyPaint(); | 673 observer->WaitForDidFirstVisuallyNonEmptyPaint(); |
673 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_); | 674 ASSERT_TRUE(observer->did_fist_visually_non_empty_paint_); |
674 } | 675 } |
675 | 676 |
676 namespace { | 677 namespace { |
677 | 678 |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 content::ExecuteScript(root->current_frame_host(), alert_location)); | 1005 content::ExecuteScript(root->current_frame_host(), alert_location)); |
1005 dialog_manager.Wait(); | 1006 dialog_manager.Wait(); |
1006 EXPECT_EQ(GURL("http://a.com/title1.html"), | 1007 EXPECT_EQ(GURL("http://a.com/title1.html"), |
1007 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); | 1008 GURL(dialog_manager.last_message()).ReplaceComponents(clear_port)); |
1008 | 1009 |
1009 wc->SetDelegate(nullptr); | 1010 wc->SetDelegate(nullptr); |
1010 wc->SetJavaScriptDialogManagerForTesting(nullptr); | 1011 wc->SetJavaScriptDialogManagerForTesting(nullptr); |
1011 } | 1012 } |
1012 | 1013 |
1013 } // namespace content | 1014 } // namespace content |
OLD | NEW |