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 3764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3775 EXPECT_EQ(modified_url, capturer.all_params()[0].url); | 3775 EXPECT_EQ(modified_url, capturer.all_params()[0].url); |
3776 EXPECT_EQ(original_url, capturer.all_params()[1].url); | 3776 EXPECT_EQ(original_url, capturer.all_params()[1].url); |
3777 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); | 3777 EXPECT_EQ(original_url, shell()->web_contents()->GetLastCommittedURL()); |
3778 } | 3778 } |
3779 | 3779 |
3780 // Make sure the renderer is still alive. | 3780 // Make sure the renderer is still alive. |
3781 EXPECT_TRUE( | 3781 EXPECT_TRUE( |
3782 ExecuteScript(shell()->web_contents(), "console.log('Success');")); | 3782 ExecuteScript(shell()->web_contents(), "console.log('Success');")); |
3783 } | 3783 } |
3784 | 3784 |
3785 // This tests that 1) the initial "about:blank" URL is elided from the | 3785 // This test shows that the initial "about:blank" URL is elided from the |
3786 // navigation history of a subframe when it is loaded, and 2) that that initial | 3786 // navigation history of a subframe when it is loaded. |
3787 // "about:blank" returns if it is navigated to as part of a history navigation. | 3787 // |
3788 // See http://crbug.com/542299 and https://github.com/whatwg/html/issues/546 . | 3788 // It also prevents regression for an in-page navigation renderer kill when |
3789 // TODO(avi, creis): This test is partially neutered; fix it. | 3789 // going back after an in-page navigation in the main frame is followed by an |
| 3790 // auto subframe navigation, due to a bug in HistoryEntry::CloneAndReplace. |
| 3791 // See https://crbug.com/612713. |
3790 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3792 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3791 BackToAboutBlankIframe) { | 3793 BackToAboutBlankIframe) { |
3792 GURL original_url(embedded_test_server()->GetURL( | 3794 GURL original_url(embedded_test_server()->GetURL( |
3793 "/navigation_controller/simple_page_1.html")); | 3795 "/navigation_controller/simple_page_1.html")); |
3794 NavigateToURL(shell(), original_url); | 3796 NavigateToURL(shell(), original_url); |
3795 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3797 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
3796 | 3798 |
3797 NavigationController& controller = shell()->web_contents()->GetController(); | 3799 NavigationController& controller = shell()->web_contents()->GetController(); |
3798 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3800 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
3799 ->GetFrameTree() | 3801 ->GetFrameTree() |
(...skipping 12 matching lines...) Expand all Loading... |
3812 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3814 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
3813 | 3815 |
3814 EXPECT_EQ(1, controller.GetEntryCount()); | 3816 EXPECT_EQ(1, controller.GetEntryCount()); |
3815 EXPECT_EQ(1, RendererHistoryLength(shell())); | 3817 EXPECT_EQ(1, RendererHistoryLength(shell())); |
3816 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3818 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3817 | 3819 |
3818 ASSERT_EQ(1U, root->child_count()); | 3820 ASSERT_EQ(1U, root->child_count()); |
3819 FrameTreeNode* frame = root->child_at(0); | 3821 FrameTreeNode* frame = root->child_at(0); |
3820 ASSERT_NE(nullptr, frame); | 3822 ASSERT_NE(nullptr, frame); |
3821 | 3823 |
3822 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); | 3824 GURL blank_url(url::kAboutBlankURL); |
| 3825 EXPECT_EQ(blank_url, frame->current_url()); |
3823 | 3826 |
3824 // Now create a new navigation entry. Note that the old navigation entry has | 3827 // Now create a new navigation entry. Note that the old navigation entry has |
3825 // "about:blank" as the URL in the iframe. | 3828 // "about:blank" as the URL in the iframe. |
3826 | 3829 |
3827 script = "history.pushState({}, '', 'notarealurl.html')"; | 3830 script = "history.pushState({}, '', 'notarealurl.html')"; |
3828 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); | 3831 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); |
3829 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3832 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
3830 | 3833 |
3831 EXPECT_EQ(2, controller.GetEntryCount()); | 3834 EXPECT_EQ(2, controller.GetEntryCount()); |
3832 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3835 EXPECT_EQ(2, RendererHistoryLength(shell())); |
3833 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3836 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3834 | 3837 |
3835 // Load the iframe; the initial "about:blank" URL should be elided and thus we | 3838 // Load the iframe; the initial "about:blank" URL should be elided and thus we |
3836 // shouldn't get a new navigation entry. | 3839 // shouldn't get a new navigation entry. |
3837 | 3840 |
3838 GURL frame_url = embedded_test_server()->GetURL( | 3841 GURL frame_url = embedded_test_server()->GetURL( |
3839 "/navigation_controller/simple_page_2.html"); | 3842 "foo.com", "/navigation_controller/simple_page_2.html"); |
3840 NavigateFrameToURL(frame, frame_url); | 3843 NavigateFrameToURL(frame, frame_url); |
3841 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3844 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
3842 | 3845 |
3843 EXPECT_EQ(2, controller.GetEntryCount()); | 3846 EXPECT_EQ(2, controller.GetEntryCount()); |
3844 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3847 EXPECT_EQ(2, RendererHistoryLength(shell())); |
3845 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3848 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3846 | 3849 |
3847 EXPECT_EQ(frame_url, frame->current_url()); | 3850 EXPECT_EQ(frame_url, frame->current_url()); |
3848 | 3851 |
3849 // At this point the rest of the test is inapplicable. The bug that it tests | 3852 // Go back. |
3850 // to be gone had to be reintroduced. | 3853 { |
3851 // | 3854 TestNavigationObserver observer(shell()->web_contents(), 1); |
3852 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for | 3855 ASSERT_TRUE(controller.CanGoBack()); |
3853 // more information. | 3856 controller.GoBack(); |
3854 | 3857 observer.Wait(); |
3855 #if 0 | 3858 } |
3856 // Go back. Because the old state had an empty frame, that should be restored | |
3857 // even though it was replaced in the second navigation entry. | |
3858 | |
3859 TestFrameNavigationObserver observer(frame); | |
3860 ASSERT_TRUE(controller.CanGoBack()); | |
3861 controller.GoBack(); | |
3862 observer.Wait(); | |
3863 | 3859 |
3864 EXPECT_EQ(2, controller.GetEntryCount()); | 3860 EXPECT_EQ(2, controller.GetEntryCount()); |
3865 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3861 EXPECT_EQ(2, RendererHistoryLength(shell())); |
3866 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3862 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3867 | 3863 |
3868 EXPECT_EQ(GURL(url::kAboutBlankURL), frame->current_url()); | 3864 // There is some open discussion over whether this should send the iframe |
3869 #endif | 3865 // back to the blank page, but for now it stays in place to preserve |
| 3866 // compatibility with existing sites. See |
| 3867 // NavigationControllerImpl::FindFramesToNavigate for more information, as |
| 3868 // well as http://crbug.com/542299, https://crbug.com/598043 (for the |
| 3869 // regressions caused by going back), and |
| 3870 // https://github.com/whatwg/html/issues/546. |
| 3871 // TODO(avi, creis): Figure out the correct behavior to use here. |
| 3872 EXPECT_EQ(frame_url, frame->current_url()); |
| 3873 |
| 3874 // Now test for https://crbug.com/612713 to prevent an NC_IN_PAGE_NAVIGATION |
| 3875 // renderer kill. |
| 3876 |
| 3877 // Do an in-page navigation in the subframe. |
| 3878 std::string fragment_script = "location.href = \"#foo\";"; |
| 3879 EXPECT_TRUE(ExecuteScript(frame->current_frame_host(), fragment_script)); |
| 3880 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 3881 |
| 3882 EXPECT_EQ(2, controller.GetEntryCount()); |
| 3883 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 3884 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 3885 |
| 3886 GURL frame_url_2 = embedded_test_server()->GetURL( |
| 3887 "foo.com", "/navigation_controller/simple_page_2.html#foo"); |
| 3888 EXPECT_EQ(frame_url_2, frame->current_url()); |
| 3889 |
| 3890 // Go back. |
| 3891 { |
| 3892 TestNavigationObserver observer(shell()->web_contents(), 1); |
| 3893 controller.GoBack(); |
| 3894 observer.Wait(); |
| 3895 } |
| 3896 |
| 3897 // Verify the process is still alive by running script. We can't just call |
| 3898 // IsRenderFrameLive after the navigation since it might not have disconnected |
| 3899 // yet. |
| 3900 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "true;")); |
| 3901 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
| 3902 |
| 3903 // TODO(creis): We should probably go back to frame_url here instead of the |
| 3904 // initial blank page. That might require updating all relevant NavEntries to |
| 3905 // know what the first committed URL is, so that we really elide the initial |
| 3906 // blank page from history. |
| 3907 // |
| 3908 // TODO(creis): This actually goes to frame_url in some cases when subframe |
| 3909 // FrameNavigationEntries are enabled, due to a mismatch between PageState and |
| 3910 // the entry's URL. That should be fixed in https://crbug.com/617239. |
| 3911 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 3912 EXPECT_EQ(blank_url, frame->current_url()); |
3870 } | 3913 } |
3871 | 3914 |
3872 // This test is similar to "BackToAboutBlankIframe" above, except that a | 3915 // This test is similar to "BackToAboutBlankIframe" above, except that a |
3873 // fragment navigation is used rather than pushState (both create an in-page | 3916 // fragment navigation is used rather than pushState (both create an in-page |
3874 // navigation, so we need to test both), and an initial 'src' is given to the | 3917 // navigation, so we need to test both), and an initial 'src' is given to the |
3875 // iframe to test proper restoration in that case. | 3918 // iframe to test proper restoration in that case. |
3876 // TODO(avi, creis): This test is partially neutered; fix it. | |
3877 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 3919 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3878 BackToIframeWithContent) { | 3920 BackToIframeWithContent) { |
3879 GURL links_url(embedded_test_server()->GetURL( | 3921 GURL links_url(embedded_test_server()->GetURL( |
3880 "/navigation_controller/page_with_links.html")); | 3922 "/navigation_controller/page_with_links.html")); |
3881 NavigateToURL(shell(), links_url); | 3923 NavigateToURL(shell(), links_url); |
3882 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3924 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
3883 | 3925 |
3884 NavigationController& controller = shell()->web_contents()->GetController(); | 3926 NavigationController& controller = shell()->web_contents()->GetController(); |
3885 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) | 3927 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
3886 ->GetFrameTree() | 3928 ->GetFrameTree() |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3921 EXPECT_EQ(2, controller.GetEntryCount()); | 3963 EXPECT_EQ(2, controller.GetEntryCount()); |
3922 EXPECT_EQ(2, RendererHistoryLength(shell())); | 3964 EXPECT_EQ(2, RendererHistoryLength(shell())); |
3923 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | 3965 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
3924 | 3966 |
3925 EXPECT_EQ(frame_url_1, frame->current_url()); | 3967 EXPECT_EQ(frame_url_1, frame->current_url()); |
3926 | 3968 |
3927 // Navigate the iframe; unlike the test "BackToAboutBlankIframe" above, this | 3969 // Navigate the iframe; unlike the test "BackToAboutBlankIframe" above, this |
3928 // _will_ create a new navigation entry. | 3970 // _will_ create a new navigation entry. |
3929 | 3971 |
3930 GURL frame_url_2 = embedded_test_server()->GetURL( | 3972 GURL frame_url_2 = embedded_test_server()->GetURL( |
3931 "/navigation_controller/simple_page_2.html"); | 3973 "foo.com", "/navigation_controller/simple_page_2.html"); |
3932 NavigateFrameToURL(frame, frame_url_2); | 3974 NavigateFrameToURL(frame, frame_url_2); |
3933 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); | 3975 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
3934 | 3976 |
3935 EXPECT_EQ(3, controller.GetEntryCount()); | 3977 EXPECT_EQ(3, controller.GetEntryCount()); |
3936 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3978 // TODO(creis): Replicate history length for OOPIFs: https://crbug.com/501116. |
| 3979 if (!AreAllSitesIsolatedForTesting()) |
| 3980 EXPECT_EQ(3, RendererHistoryLength(shell())); |
3937 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | 3981 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
3938 | 3982 |
3939 EXPECT_EQ(frame_url_2, frame->current_url()); | 3983 EXPECT_EQ(frame_url_2, frame->current_url()); |
3940 | 3984 |
3941 // At this point the rest of the test is inapplicable. The bug that it tests | 3985 // Go back two entries. |
3942 // to be gone had to be reintroduced. | 3986 { |
3943 // | 3987 TestNavigationObserver observer(shell()->web_contents(), 1); |
3944 // See the discussion in NavigationControllerImpl::FindFramesToNavigate for | 3988 ASSERT_TRUE(controller.CanGoToOffset(-2)); |
3945 // more information. | 3989 controller.GoToOffset(-2); |
3946 | 3990 observer.Wait(); |
3947 #if 0 | 3991 } |
3948 // Go back two entries. The original frame URL should be back. | |
3949 | |
3950 TestFrameNavigationObserver observer(frame); | |
3951 ASSERT_TRUE(controller.CanGoToOffset(-2)); | |
3952 controller.GoToOffset(-2); | |
3953 observer.Wait(); | |
3954 | 3992 |
3955 EXPECT_EQ(3, controller.GetEntryCount()); | 3993 EXPECT_EQ(3, controller.GetEntryCount()); |
3956 EXPECT_EQ(3, RendererHistoryLength(shell())); | 3994 EXPECT_EQ(3, RendererHistoryLength(shell())); |
3957 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | 3995 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
3958 | 3996 |
| 3997 // There is some open discussion over whether this should send the iframe back |
| 3998 // to the original page, but for now it stays in place to preserve |
| 3999 // compatibility with existing sites. See |
| 4000 // NavigationControllerImpl::FindFramesToNavigate for more information, as |
| 4001 // well as http://crbug.com/542299, https://crbug.com/598043 (for the |
| 4002 // regressions caused by going back), and |
| 4003 // https://github.com/whatwg/html/issues/546. |
| 4004 // TODO(avi, creis): Figure out the correct behavior to use here. |
| 4005 EXPECT_EQ(frame_url_2, frame->current_url()); |
| 4006 |
| 4007 // Now test for https://crbug.com/612713 to prevent an NC_IN_PAGE_NAVIGATION |
| 4008 // renderer kill. |
| 4009 |
| 4010 // Do an in-page navigation in the subframe. |
| 4011 std::string fragment_script = "location.href = \"#foo\";"; |
| 4012 EXPECT_TRUE(ExecuteScript(frame->current_frame_host(), fragment_script)); |
| 4013 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4014 |
| 4015 EXPECT_EQ(2, controller.GetEntryCount()); |
| 4016 // TODO(creis): Replicate history length for OOPIFs: https://crbug.com/501116. |
| 4017 if (!AreAllSitesIsolatedForTesting()) |
| 4018 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 4019 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4020 |
| 4021 // Go back. |
| 4022 { |
| 4023 TestNavigationObserver observer(shell()->web_contents(), 1); |
| 4024 controller.GoBack(); |
| 4025 observer.Wait(); |
| 4026 } |
| 4027 |
| 4028 // Verify the process is still alive by running script. We can't just call |
| 4029 // IsRenderFrameLive after the navigation since it might not have disconnected |
| 4030 // yet. |
| 4031 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "true;")); |
| 4032 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
| 4033 |
| 4034 // TODO(creis): It's a bit surprising to go to frame_url_1 here instead of |
| 4035 // frame_url_2. Perhaps we should be going back to frame_url_1 when going |
| 4036 // back two entries above, since it's different than the initial blank case. |
| 4037 // |
| 4038 // TODO(creis): This actually goes to frame_url_2 in some cases when subframe |
| 4039 // FrameNavigationEntries are enabled, due to a mismatch between PageState and |
| 4040 // the entry's URL. That should be fixed in https://crbug.com/617239. |
| 4041 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 4042 EXPECT_EQ(frame_url_1, frame->current_url()); |
| 4043 } |
| 4044 |
| 4045 // Test for in-page navigation kills due to using the wrong history item in |
| 4046 // HistoryController::RecursiveGoToEntry and NavigationControllerImpl:: |
| 4047 // FindFramesToNavigate. See https://crbug.com/612713. |
| 4048 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 4049 BackTwiceToIframeWithContent) { |
| 4050 GURL links_url(embedded_test_server()->GetURL( |
| 4051 "/navigation_controller/page_with_links.html")); |
| 4052 NavigateToURL(shell(), links_url); |
| 4053 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4054 |
| 4055 NavigationController& controller = shell()->web_contents()->GetController(); |
| 4056 FrameTreeNode* root = static_cast<WebContentsImpl*>(shell()->web_contents()) |
| 4057 ->GetFrameTree() |
| 4058 ->root(); |
| 4059 |
| 4060 EXPECT_EQ(1, controller.GetEntryCount()); |
| 4061 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 4062 |
| 4063 // Add an iframe with a 'src'. |
| 4064 |
| 4065 GURL frame_url_1 = embedded_test_server()->GetURL( |
| 4066 "/navigation_controller/simple_page_1.html"); |
| 4067 std::string script = |
| 4068 "var iframe = document.createElement('iframe');" |
| 4069 "iframe.src = '" + frame_url_1.spec() + "';" |
| 4070 "iframe.id = 'frame';" |
| 4071 "document.body.appendChild(iframe);"; |
| 4072 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), script)); |
| 4073 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4074 |
| 4075 EXPECT_EQ(1, controller.GetEntryCount()); |
| 4076 EXPECT_EQ(1, RendererHistoryLength(shell())); |
| 4077 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); |
| 4078 |
| 4079 ASSERT_EQ(1U, root->child_count()); |
| 4080 FrameTreeNode* frame = root->child_at(0); |
| 4081 ASSERT_NE(nullptr, frame); |
| 4082 |
3959 EXPECT_EQ(frame_url_1, frame->current_url()); | 4083 EXPECT_EQ(frame_url_1, frame->current_url()); |
3960 #endif | 4084 |
| 4085 // Do an in-page navigation in the subframe. |
| 4086 GURL frame_url_2 = embedded_test_server()->GetURL( |
| 4087 "/navigation_controller/simple_page_1.html#foo"); |
| 4088 std::string fragment_script = "location.href = \"#foo\";"; |
| 4089 EXPECT_TRUE(ExecuteScript(frame->current_frame_host(), fragment_script)); |
| 4090 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4091 EXPECT_EQ(2, controller.GetEntryCount()); |
| 4092 EXPECT_EQ(2, RendererHistoryLength(shell())); |
| 4093 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4094 EXPECT_EQ(frame_url_2, frame->current_url()); |
| 4095 |
| 4096 // Do a fragment navigation at the top level. |
| 4097 std::string link_script = "document.getElementById('fraglink').click()"; |
| 4098 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), link_script)); |
| 4099 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4100 EXPECT_EQ(3, controller.GetEntryCount()); |
| 4101 EXPECT_EQ(3, RendererHistoryLength(shell())); |
| 4102 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 4103 EXPECT_EQ(frame_url_2, frame->current_url()); |
| 4104 |
| 4105 // Go cross-site in the iframe. |
| 4106 GURL frame_url_3 = embedded_test_server()->GetURL( |
| 4107 "foo.com", "/navigation_controller/simple_page_2.html"); |
| 4108 NavigateFrameToURL(frame, frame_url_3); |
| 4109 EXPECT_TRUE(WaitForLoadStop(shell()->web_contents())); |
| 4110 EXPECT_EQ(4, controller.GetEntryCount()); |
| 4111 // TODO(creis): Replicate history length for OOPIFs: https://crbug.com/501116. |
| 4112 if (!AreAllSitesIsolatedForTesting()) |
| 4113 EXPECT_EQ(4, RendererHistoryLength(shell())); |
| 4114 EXPECT_EQ(3, controller.GetLastCommittedEntryIndex()); |
| 4115 EXPECT_EQ(frame_url_3, frame->current_url()); |
| 4116 |
| 4117 // Go back two entries. |
| 4118 { |
| 4119 TestNavigationObserver observer(shell()->web_contents(), 1); |
| 4120 ASSERT_TRUE(controller.CanGoToOffset(-2)); |
| 4121 controller.GoToOffset(-2); |
| 4122 observer.Wait(); |
| 4123 } |
| 4124 EXPECT_EQ(4, controller.GetEntryCount()); |
| 4125 // TODO(creis): Replicate history length for OOPIFs: https://crbug.com/501116. |
| 4126 if (!AreAllSitesIsolatedForTesting()) |
| 4127 EXPECT_EQ(4, RendererHistoryLength(shell())); |
| 4128 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 4129 EXPECT_EQ(links_url, root->current_url()); |
| 4130 |
| 4131 // There is some open discussion over whether this should send the iframe back |
| 4132 // to the original page, but for now it stays in place to preserve |
| 4133 // compatibility with existing sites. See |
| 4134 // NavigationControllerImpl::FindFramesToNavigate for more information, as |
| 4135 // well as http://crbug.com/542299, https://crbug.com/598043 (for the |
| 4136 // regressions caused by going back), and |
| 4137 // https://github.com/whatwg/html/issues/546. |
| 4138 // TODO(avi, creis): Figure out the correct behavior to use here. |
| 4139 EXPECT_EQ(frame_url_3, frame->current_url()); |
| 4140 |
| 4141 // Now test for https://crbug.com/612713 to prevent an NC_IN_PAGE_NAVIGATION |
| 4142 // renderer kill. |
| 4143 |
| 4144 // Go back. |
| 4145 { |
| 4146 TestNavigationObserver observer(shell()->web_contents(), 1); |
| 4147 controller.GoBack(); |
| 4148 observer.Wait(); |
| 4149 } |
| 4150 |
| 4151 // Verify the process is still alive by running script. We can't just call |
| 4152 // IsRenderFrameLive after the navigation since it might not have disconnected |
| 4153 // yet. |
| 4154 EXPECT_TRUE(ExecuteScript(root->current_frame_host(), "true;")); |
| 4155 EXPECT_TRUE(root->current_frame_host()->IsRenderFrameLive()); |
| 4156 |
| 4157 // TODO(creis): It's a bit surprising to go to frame_url_1 here instead of |
| 4158 // frame_url_2. Perhaps we should be going back to frame_url_1 when going |
| 4159 // back two entries above, since it's different than the initial blank case. |
| 4160 // |
| 4161 // TODO(creis): This actually goes to frame_url_2 in some cases when subframe |
| 4162 // FrameNavigationEntries are enabled, due to a mismatch between PageState and |
| 4163 // the entry's URL. That should be fixed in https://crbug.com/617239. |
| 4164 if (!SiteIsolationPolicy::AreCrossProcessFramesPossible()) |
| 4165 EXPECT_EQ(frame_url_1, frame->current_url()); |
3961 } | 4166 } |
3962 | 4167 |
3963 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe | 4168 // Ensure that we do not corrupt a NavigationEntry's PageState if a subframe |
3964 // forward navigation commits after we've already started another forward | 4169 // forward navigation commits after we've already started another forward |
3965 // navigation in the main frame. See https://crbug.com/597322. | 4170 // navigation in the main frame. See https://crbug.com/597322. |
3966 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | 4171 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
3967 ForwardInSubframeWithPendingForward) { | 4172 ForwardInSubframeWithPendingForward) { |
3968 // Navigate to a page with an iframe. | 4173 // Navigate to a page with an iframe. |
3969 GURL url_a(embedded_test_server()->GetURL( | 4174 GURL url_a(embedded_test_server()->GetURL( |
3970 "/navigation_controller/page_with_data_iframe.html")); | 4175 "/navigation_controller/page_with_data_iframe.html")); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4158 // TODO(clamy): Check the post id as well when PlzNavigate handles it | 4363 // TODO(clamy): Check the post id as well when PlzNavigate handles it |
4159 // properly. | 4364 // properly. |
4160 if (!IsBrowserSideNavigationEnabled()) | 4365 if (!IsBrowserSideNavigationEnabled()) |
4161 EXPECT_NE(-1, frame_entry->post_id()); | 4366 EXPECT_NE(-1, frame_entry->post_id()); |
4162 EXPECT_FALSE(entry->GetHasPostData()); | 4367 EXPECT_FALSE(entry->GetHasPostData()); |
4163 EXPECT_EQ(-1, entry->GetPostID()); | 4368 EXPECT_EQ(-1, entry->GetPostID()); |
4164 } | 4369 } |
4165 } | 4370 } |
4166 | 4371 |
4167 } // namespace content | 4372 } // namespace content |
OLD | NEW |