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

Side by Side Diff: content/browser/frame_host/navigation_handle_impl_browsertest.cc

Issue 2132603002: [page_load_metrics] Add a NavigationThrottle for richer abort metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nasko@ nits Created 4 years, 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/frame_host/navigation_handle_impl.h" 5 #include "content/browser/frame_host/navigation_handle_impl.h"
6 #include "content/browser/web_contents/web_contents_impl.h" 6 #include "content/browser/web_contents/web_contents_impl.h"
7 #include "content/public/browser/web_contents.h" 7 #include "content/public/browser/web_contents.h"
8 #include "content/public/browser/web_contents_observer.h" 8 #include "content/public/browser/web_contents_observer.h"
9 #include "content/public/common/request_context_type.h" 9 #include "content/public/common/request_context_type.h"
10 #include "content/public/test/browser_test_utils.h" 10 #include "content/public/test/browser_test_utils.h"
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after
688 shell()->web_contents(), NavigationThrottle::PROCEED, 688 shell()->web_contents(), NavigationThrottle::PROCEED,
689 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); 689 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
690 TestNavigationManager main_manager(shell()->web_contents(), main_url); 690 TestNavigationManager main_manager(shell()->web_contents(), main_url);
691 TestNavigationManager b_manager(shell()->web_contents(), b_url); 691 TestNavigationManager b_manager(shell()->web_contents(), b_url);
692 TestNavigationManager c_manager(shell()->web_contents(), c_url); 692 TestNavigationManager c_manager(shell()->web_contents(), c_url);
693 NavigationStartUrlRecorder url_recorder(shell()->web_contents()); 693 NavigationStartUrlRecorder url_recorder(shell()->web_contents());
694 TestNavigationThrottle* previous_throttle = nullptr; 694 TestNavigationThrottle* previous_throttle = nullptr;
695 695
696 // Starts and verifies the main frame navigation. 696 // Starts and verifies the main frame navigation.
697 shell()->LoadURL(main_url); 697 shell()->LoadURL(main_url);
698 main_manager.WaitForWillStartRequest(); 698 EXPECT_TRUE(main_manager.WaitForWillStartRequest());
699 // The throttle should not be null. 699 // The throttle should not be null.
700 EXPECT_NE(previous_throttle, installer.navigation_throttle()); 700 EXPECT_NE(previous_throttle, installer.navigation_throttle());
701 // Checks the only URL recorded so far is the one expected for the main frame. 701 // Checks the only URL recorded so far is the one expected for the main frame.
702 EXPECT_EQ(main_url, url_recorder.urls().back()); 702 EXPECT_EQ(main_url, url_recorder.urls().back());
703 EXPECT_EQ(1ul, url_recorder.urls().size()); 703 EXPECT_EQ(1ul, url_recorder.urls().size());
704 // Checks the main frame RequestContextType. 704 // Checks the main frame RequestContextType.
705 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION, 705 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION,
706 installer.navigation_throttle()->request_context_type()); 706 installer.navigation_throttle()->request_context_type());
707 // For each navigations the throttle should be a different instance. 707 // For each navigations the throttle should be a different instance.
708 previous_throttle = installer.navigation_throttle(); 708 previous_throttle = installer.navigation_throttle();
709 709
710 // Ditto for frame b navigation. 710 // Ditto for frame b navigation.
711 main_manager.WaitForNavigationFinished(); 711 main_manager.WaitForNavigationFinished();
712 b_manager.WaitForWillStartRequest(); 712 EXPECT_TRUE(b_manager.WaitForWillStartRequest());
713 EXPECT_NE(previous_throttle, installer.navigation_throttle()); 713 EXPECT_NE(previous_throttle, installer.navigation_throttle());
714 EXPECT_EQ(b_url, url_recorder.urls().back()); 714 EXPECT_EQ(b_url, url_recorder.urls().back());
715 EXPECT_EQ(2ul, url_recorder.urls().size()); 715 EXPECT_EQ(2ul, url_recorder.urls().size());
716 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION, 716 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION,
717 installer.navigation_throttle()->request_context_type()); 717 installer.navigation_throttle()->request_context_type());
718 previous_throttle = installer.navigation_throttle(); 718 previous_throttle = installer.navigation_throttle();
719 719
720 // Ditto for frame c navigation. 720 // Ditto for frame c navigation.
721 b_manager.WaitForNavigationFinished(); 721 b_manager.WaitForNavigationFinished();
722 c_manager.WaitForWillStartRequest(); 722 EXPECT_TRUE(c_manager.WaitForWillStartRequest());
723 EXPECT_NE(previous_throttle, installer.navigation_throttle()); 723 EXPECT_NE(previous_throttle, installer.navigation_throttle());
724 EXPECT_EQ(c_url, url_recorder.urls().back()); 724 EXPECT_EQ(c_url, url_recorder.urls().back());
725 EXPECT_EQ(3ul, url_recorder.urls().size()); 725 EXPECT_EQ(3ul, url_recorder.urls().size());
726 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION, 726 EXPECT_EQ(REQUEST_CONTEXT_TYPE_LOCATION,
727 installer.navigation_throttle()->request_context_type()); 727 installer.navigation_throttle()->request_context_type());
728 728
729 // Lets the final navigation finish so that we conclude running the 729 // Lets the final navigation finish so that we conclude running the
730 // RequestContextType checks that happen in TestNavigationThrottle. 730 // RequestContextType checks that happen in TestNavigationThrottle.
731 c_manager.WaitForNavigationFinished(); 731 c_manager.WaitForNavigationFinished();
732 // Confirms the last navigation did finish. 732 // Confirms the last navigation did finish.
(...skipping 17 matching lines...) Expand all
750 EXPECT_EQ(document_url, url_recorder.urls().back()); 750 EXPECT_EQ(document_url, url_recorder.urls().back());
751 EXPECT_EQ(1ul, url_recorder.urls().size()); 751 EXPECT_EQ(1ul, url_recorder.urls().size());
752 752
753 // Starts the navigation from a link click and then check it. 753 // Starts the navigation from a link click and then check it.
754 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 754 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
755 bool success = false; 755 bool success = false;
756 EXPECT_TRUE(ExecuteScriptAndExtractBool( 756 EXPECT_TRUE(ExecuteScriptAndExtractBool(
757 shell(), "window.domAutomationController.send(clickSameSiteLink());", 757 shell(), "window.domAutomationController.send(clickSameSiteLink());",
758 &success)); 758 &success));
759 EXPECT_TRUE(success); 759 EXPECT_TRUE(success);
760 link_manager.WaitForWillStartRequest(); 760 EXPECT_TRUE(link_manager.WaitForWillStartRequest());
761 EXPECT_EQ(link_url, url_recorder.urls().back()); 761 EXPECT_EQ(link_url, url_recorder.urls().back());
762 EXPECT_EQ(2ul, url_recorder.urls().size()); 762 EXPECT_EQ(2ul, url_recorder.urls().size());
763 EXPECT_EQ(REQUEST_CONTEXT_TYPE_HYPERLINK, 763 EXPECT_EQ(REQUEST_CONTEXT_TYPE_HYPERLINK,
764 installer.navigation_throttle()->request_context_type()); 764 installer.navigation_throttle()->request_context_type());
765 765
766 // Finishes the last navigation. 766 // Finishes the last navigation.
767 link_manager.WaitForNavigationFinished(); 767 link_manager.WaitForNavigationFinished();
768 EXPECT_FALSE(installer.navigation_throttle()); 768 EXPECT_FALSE(installer.navigation_throttle());
769 } 769 }
770 770
(...skipping 12 matching lines...) Expand all
783 783
784 // Navigate to a page with a form. 784 // Navigate to a page with a form.
785 EXPECT_TRUE(NavigateToURL(shell(), document_url)); 785 EXPECT_TRUE(NavigateToURL(shell(), document_url));
786 EXPECT_EQ(document_url, url_recorder.urls().back()); 786 EXPECT_EQ(document_url, url_recorder.urls().back());
787 EXPECT_EQ(1ul, url_recorder.urls().size()); 787 EXPECT_EQ(1ul, url_recorder.urls().size());
788 788
789 // Executes the form POST navigation and then check it. 789 // Executes the form POST navigation and then check it.
790 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); 790 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents()));
791 GURL submit_url("javascript:submitForm('isubmit')"); 791 GURL submit_url("javascript:submitForm('isubmit')");
792 shell()->LoadURL(submit_url); 792 shell()->LoadURL(submit_url);
793 post_manager.WaitForWillStartRequest(); 793 EXPECT_TRUE(post_manager.WaitForWillStartRequest());
794 EXPECT_EQ(post_url, url_recorder.urls().back()); 794 EXPECT_EQ(post_url, url_recorder.urls().back());
795 EXPECT_EQ(2ul, url_recorder.urls().size()); 795 EXPECT_EQ(2ul, url_recorder.urls().size());
796 EXPECT_EQ(REQUEST_CONTEXT_TYPE_FORM, 796 EXPECT_EQ(REQUEST_CONTEXT_TYPE_FORM,
797 installer.navigation_throttle()->request_context_type()); 797 installer.navigation_throttle()->request_context_type());
798 798
799 // Finishes the last navigation. 799 // Finishes the last navigation.
800 post_manager.WaitForNavigationFinished(); 800 post_manager.WaitForNavigationFinished();
801 EXPECT_FALSE(installer.navigation_throttle()); 801 EXPECT_FALSE(installer.navigation_throttle());
802 } 802 }
803 803
(...skipping 12 matching lines...) Expand all
816 shell()->web_contents(), NavigationThrottle::PROCEED, 816 shell()->web_contents(), NavigationThrottle::PROCEED,
817 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED); 817 NavigationThrottle::PROCEED, NavigationThrottle::PROCEED);
818 TestNavigationManager navigation_manager(shell()->web_contents(), 818 TestNavigationManager navigation_manager(shell()->web_contents(),
819 iframe_secure_url); 819 iframe_secure_url);
820 820
821 // Load the page and wait for the frame load with the expected URL. 821 // Load the page and wait for the frame load with the expected URL.
822 // Note: if the test times out while waiting then a navigation to 822 // Note: if the test times out while waiting then a navigation to
823 // iframe_secure_url never happened and the expected upgrade may not be 823 // iframe_secure_url never happened and the expected upgrade may not be
824 // working. 824 // working.
825 shell()->LoadURL(start_url); 825 shell()->LoadURL(start_url);
826 navigation_manager.WaitForWillStartRequest(); 826 EXPECT_TRUE(navigation_manager.WaitForWillStartRequest());
827 827
828 // The main frame should have finished navigating while the iframe should 828 // The main frame should have finished navigating while the iframe should
829 // have just started. 829 // have just started.
830 EXPECT_EQ(2, installer.will_start_called()); 830 EXPECT_EQ(2, installer.will_start_called());
831 EXPECT_EQ(0, installer.will_redirect_called()); 831 EXPECT_EQ(0, installer.will_redirect_called());
832 EXPECT_EQ(1, installer.will_process_called()); 832 EXPECT_EQ(1, installer.will_process_called());
833 833
834 // Check the correct start URLs have been registered. 834 // Check the correct start URLs have been registered.
835 EXPECT_EQ(iframe_secure_url, url_recorder.urls().back()); 835 EXPECT_EQ(iframe_secure_url, url_recorder.urls().back());
836 EXPECT_EQ(start_url, url_recorder.urls().front()); 836 EXPECT_EQ(start_url, url_recorder.urls().front());
(...skipping 21 matching lines...) Expand all
858 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest, 858 IN_PROC_BROWSER_TEST_F(NavigationHandleImplHttpsUpgradeBrowserTest,
859 StartUrlIsHttpsUpgradedCrossSite) { 859 StartUrlIsHttpsUpgradedCrossSite) {
860 GURL start_url( 860 GURL start_url(
861 embedded_test_server()->GetURL("/https_upgrade_cross_site.html")); 861 embedded_test_server()->GetURL("/https_upgrade_cross_site.html"));
862 GURL cross_site_iframe_secure_url("https://other.com/title1.html"); 862 GURL cross_site_iframe_secure_url("https://other.com/title1.html");
863 863
864 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url); 864 CheckHttpsUpgradedIframeNavigation(start_url, cross_site_iframe_secure_url);
865 } 865 }
866 866
867 } // namespace content 867 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/frame_host/navigation_handle_impl.cc ('k') | content/browser/web_contents/web_contents_impl_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698