OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_controller_impl.h" | 5 #include "content/browser/frame_host/navigation_controller_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 646 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
647 NavigationEntry* entry = controller.GetLastCommittedEntry(); | 647 NavigationEntry* entry = controller.GetLastCommittedEntry(); |
648 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); | 648 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); |
649 EXPECT_EQ(2, controller.GetEntryCount()); | 649 EXPECT_EQ(2, controller.GetEntryCount()); |
650 } | 650 } |
651 | 651 |
652 // Make a new entry ... | 652 // Make a new entry ... |
653 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); | 653 NavigateToURL(shell(), GURL(url::kAboutBlankURL)); |
654 EXPECT_EQ(3, controller.GetEntryCount()); | 654 EXPECT_EQ(3, controller.GetEntryCount()); |
655 | 655 |
656 // ... and replace it with a failed load. | 656 // ... and replace it with a failed load. (Note that when you set the |
657 // TODO(creis): Make this be NEW_PAGE along with the other location.replace | 657 // should_replace_current_entry flag, the navigation is classified as NEW_PAGE |
658 // cases. There isn't much impact to having this be EXISTING_PAGE for now. | 658 // because that is a classification of the renderer's behavior, and the flag |
659 // See https://crbug.com/317872. | 659 // is a browser-side flag.) |
660 { | 660 { |
661 FrameNavigateParamsCapturer capturer(root); | 661 FrameNavigateParamsCapturer capturer(root); |
662 NavigateToURLAndReplace(shell(), error_url); | 662 NavigateToURLAndReplace(shell(), error_url); |
663 capturer.Wait(); | 663 capturer.Wait(); |
664 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 664 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
665 NavigationEntry* entry = controller.GetLastCommittedEntry(); | 665 NavigationEntry* entry = controller.GetLastCommittedEntry(); |
666 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); | 666 EXPECT_EQ(PAGE_TYPE_ERROR, entry->GetPageType()); |
667 EXPECT_EQ(3, controller.GetEntryCount()); | 667 EXPECT_EQ(3, controller.GetEntryCount()); |
668 } | 668 } |
669 | 669 |
670 // Make a new web ui page to force a process swap ... | 670 // Make a new web ui page to force a process swap ... |
671 GURL web_ui_page(std::string(kChromeUIScheme) + "://" + | 671 GURL web_ui_page(std::string(kChromeUIScheme) + "://" + |
672 std::string(kChromeUIGpuHost)); | 672 std::string(kChromeUIGpuHost)); |
673 NavigateToURL(shell(), web_ui_page); | 673 NavigateToURL(shell(), web_ui_page); |
674 EXPECT_EQ(4, controller.GetEntryCount()); | 674 EXPECT_EQ(4, controller.GetEntryCount()); |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
754 FrameNavigateParamsCapturer capturer(root); | 754 FrameNavigateParamsCapturer capturer(root); |
755 std::string script = | 755 std::string script = |
756 "history.pushState({}, 'page 1', 'simple_page_1.html')"; | 756 "history.pushState({}, 'page 1', 'simple_page_1.html')"; |
757 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 757 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
758 capturer.Wait(); | 758 capturer.Wait(); |
759 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 759 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
760 capturer.params().transition); | 760 capturer.params().transition); |
761 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | 761 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); |
762 EXPECT_TRUE(capturer.details().is_in_page); | 762 EXPECT_TRUE(capturer.details().is_in_page); |
763 } | 763 } |
764 | |
765 if (AreAllSitesIsolatedForTesting()) { | |
766 // Cross-process location.replace(). | |
767 FrameNavigateParamsCapturer capturer(root); | |
768 GURL frame_url(embedded_test_server()->GetURL( | |
769 "foo.com", "/navigation_controller/simple_page_1.html")); | |
770 std::string script = "location.replace('" + frame_url.spec() + "')"; | |
771 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | |
772 capturer.Wait(); | |
773 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | |
774 capturer.params().transition); | |
775 EXPECT_EQ(NAVIGATION_TYPE_NEW_PAGE, capturer.details().type); | |
776 EXPECT_FALSE(capturer.details().is_in_page); | |
777 } | |
778 } | 764 } |
779 | 765 |
780 // Verify that navigations for NAVIGATION_TYPE_EXISTING_PAGE are correctly | 766 // Verify that navigations for NAVIGATION_TYPE_EXISTING_PAGE are correctly |
781 // classified. | 767 // classified. |
782 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 768 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
783 NavigationTypeClassification_ExistingPage) { | 769 NavigationTypeClassification_ExistingPage) { |
784 GURL url1(embedded_test_server()->GetURL( | 770 GURL url1(embedded_test_server()->GetURL( |
785 "/navigation_controller/simple_page_1.html")); | 771 "/navigation_controller/simple_page_1.html")); |
786 NavigateToURL(shell(), url1); | 772 NavigateToURL(shell(), url1); |
787 GURL url2(embedded_test_server()->GetURL( | 773 GURL url2(embedded_test_server()->GetURL( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 "location.reload()")); | 877 "location.reload()")); |
892 capturer.Wait(); | 878 capturer.Wait(); |
893 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 879 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
894 capturer.params().transition); | 880 capturer.params().transition); |
895 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 881 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
896 EXPECT_FALSE(capturer.details().is_in_page); | 882 EXPECT_FALSE(capturer.details().is_in_page); |
897 } | 883 } |
898 | 884 |
899 { | 885 { |
900 // location.replace(). | 886 // location.replace(). |
901 // TODO(creis): Change this to be NEW_PAGE with replacement in | |
902 // https://crbug.com/317872. | |
903 FrameNavigateParamsCapturer capturer(root); | 887 FrameNavigateParamsCapturer capturer(root); |
904 GURL frame_url(embedded_test_server()->GetURL( | 888 GURL frame_url(embedded_test_server()->GetURL( |
905 "/navigation_controller/simple_page_1.html")); | 889 "/navigation_controller/simple_page_1.html")); |
906 std::string script = "location.replace('" + frame_url.spec() + "')"; | 890 std::string script = "location.replace('" + frame_url.spec() + "')"; |
907 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 891 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
908 capturer.Wait(); | 892 capturer.Wait(); |
909 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 893 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
910 capturer.params().transition); | 894 capturer.params().transition); |
911 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 895 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
912 EXPECT_FALSE(capturer.details().is_in_page); | 896 EXPECT_FALSE(capturer.details().is_in_page); |
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3374 observer.Wait(); | 3358 observer.Wait(); |
3375 | 3359 |
3376 EXPECT_EQ(3, controller.GetEntryCount()); | 3360 EXPECT_EQ(3, controller.GetEntryCount()); |
3377 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3361 EXPECT_EQ(3, RendererHistoryLength(shell())); |
3378 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3362 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3379 | 3363 |
3380 EXPECT_EQ(frame_url_1, frame->current_url()); | 3364 EXPECT_EQ(frame_url_1, frame->current_url()); |
3381 } | 3365 } |
3382 | 3366 |
3383 } // namespace content | 3367 } // namespace content |
OLD | NEW |