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. (Note that when you set the | 656 // ... and replace it with a failed load. |
657 // should_replace_current_entry flag, the navigation is classified as NEW_PAGE | 657 // TODO(creis): Make this be NEW_PAGE along with the other location.replace |
658 // because that is a classification of the renderer's behavior, and the flag | 658 // cases. There isn't much impact to having this be EXISTING_PAGE for now. |
659 // is a browser-side flag.) | 659 // See https://crbug.com/317872. |
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_NEW_PAGE, capturer.details().type); | 664 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_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 } |
764 } | 778 } |
765 | 779 |
766 // Verify that navigations for NAVIGATION_TYPE_EXISTING_PAGE are correctly | 780 // Verify that navigations for NAVIGATION_TYPE_EXISTING_PAGE are correctly |
767 // classified. | 781 // classified. |
768 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 782 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
769 NavigationTypeClassification_ExistingPage) { | 783 NavigationTypeClassification_ExistingPage) { |
770 GURL url1(embedded_test_server()->GetURL( | 784 GURL url1(embedded_test_server()->GetURL( |
771 "/navigation_controller/simple_page_1.html")); | 785 "/navigation_controller/simple_page_1.html")); |
772 NavigateToURL(shell(), url1); | 786 NavigateToURL(shell(), url1); |
773 GURL url2(embedded_test_server()->GetURL( | 787 GURL url2(embedded_test_server()->GetURL( |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 "location.reload()")); | 891 "location.reload()")); |
878 capturer.Wait(); | 892 capturer.Wait(); |
879 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 893 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
880 capturer.params().transition); | 894 capturer.params().transition); |
881 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 895 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
882 EXPECT_FALSE(capturer.details().is_in_page); | 896 EXPECT_FALSE(capturer.details().is_in_page); |
883 } | 897 } |
884 | 898 |
885 { | 899 { |
886 // location.replace(). | 900 // location.replace(). |
| 901 // TODO(creis): Change this to be NEW_PAGE with replacement in |
| 902 // https://crbug.com/317872. |
887 FrameNavigateParamsCapturer capturer(root); | 903 FrameNavigateParamsCapturer capturer(root); |
888 GURL frame_url(embedded_test_server()->GetURL( | 904 GURL frame_url(embedded_test_server()->GetURL( |
889 "/navigation_controller/simple_page_1.html")); | 905 "/navigation_controller/simple_page_1.html")); |
890 std::string script = "location.replace('" + frame_url.spec() + "')"; | 906 std::string script = "location.replace('" + frame_url.spec() + "')"; |
891 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); | 907 EXPECT_TRUE(content::ExecuteScript(root->current_frame_host(), script)); |
892 capturer.Wait(); | 908 capturer.Wait(); |
893 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, | 909 EXPECT_EQ(ui::PAGE_TRANSITION_LINK | ui::PAGE_TRANSITION_CLIENT_REDIRECT, |
894 capturer.params().transition); | 910 capturer.params().transition); |
895 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); | 911 EXPECT_EQ(NAVIGATION_TYPE_EXISTING_PAGE, capturer.details().type); |
896 EXPECT_FALSE(capturer.details().is_in_page); | 912 EXPECT_FALSE(capturer.details().is_in_page); |
(...skipping 2461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3358 observer.Wait(); | 3374 observer.Wait(); |
3359 | 3375 |
3360 EXPECT_EQ(3, controller.GetEntryCount()); | 3376 EXPECT_EQ(3, controller.GetEntryCount()); |
3361 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3377 EXPECT_EQ(3, RendererHistoryLength(shell())); |
3362 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3378 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3363 | 3379 |
3364 EXPECT_EQ(frame_url_1, frame->current_url()); | 3380 EXPECT_EQ(frame_url_1, frame->current_url()); |
3365 } | 3381 } |
3366 | 3382 |
3367 } // namespace content | 3383 } // namespace content |
OLD | NEW |