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