Chromium Code Reviews| 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 <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 6809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6820 | 6820 |
| 6821 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); | 6821 EXPECT_TRUE(embedded_test_server()->ShutdownAndWaitUntilComplete()); |
| 6822 | 6822 |
| 6823 TestNavigationObserver back_observer(shell()->web_contents()); | 6823 TestNavigationObserver back_observer(shell()->web_contents()); |
| 6824 controller.GoBack(); | 6824 controller.GoBack(); |
| 6825 back_observer.Wait(); | 6825 back_observer.Wait(); |
| 6826 | 6826 |
| 6827 EXPECT_TRUE(back_observer.last_navigation_succeeded()); | 6827 EXPECT_TRUE(back_observer.last_navigation_succeeded()); |
| 6828 } | 6828 } |
| 6829 | 6829 |
| 6830 // Test to verify that navigating to a blocked URL does not result in a | |
| 6831 // NavigationEntry that allows the navigation to succeed when using a history | |
| 6832 // navigation or a reload. See https://crbug.com/723796. | |
| 6833 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | |
| 6834 VerifyBlockedErrorPageURL_History) { | |
|
Charlie Reis
2017/05/18 22:41:46
Just curious, how is this different from the earli
nasko
2017/05/18 22:55:11
The goal is to use a navigation different than the
Charlie Reis
2017/05/18 23:15:51
Acknowledged.
| |
| 6835 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | |
| 6836 shell()->web_contents()->GetController()); | |
| 6837 | |
| 6838 GURL start_url(embedded_test_server()->GetURL("/title1.html")); | |
| 6839 EXPECT_TRUE(NavigateToURL(shell(), start_url)); | |
| 6840 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | |
| 6841 | |
| 6842 // Navigate to an URL, which redirects to a data: URL, since it is an | |
| 6843 // unsafe redirect and will result in a blocked navigation and error page. | |
| 6844 GURL redirect_to_blank_url( | |
| 6845 embedded_test_server()->GetURL("/server-redirect?data:foo")); | |
| 6846 EXPECT_FALSE(NavigateToURL(shell(), redirect_to_blank_url)); | |
| 6847 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | |
| 6848 EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType()); | |
| 6849 | |
| 6850 // Navigate to a new document, then go back in history trying to load the | |
| 6851 // blocked URL. | |
| 6852 EXPECT_TRUE( | |
| 6853 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); | |
| 6854 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); | |
| 6855 | |
| 6856 TestNavigationObserver back_load_observer(shell()->web_contents()); | |
| 6857 controller.GoBack(); | |
| 6858 back_load_observer.Wait(); | |
| 6859 | |
| 6860 // The expectation is that about:blank was loaded and the virtual URL is set | |
| 6861 // to the URL that was blocked. | |
| 6862 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | |
| 6863 EXPECT_FALSE( | |
| 6864 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme)); | |
| 6865 EXPECT_TRUE(controller.GetLastCommittedEntry()->GetVirtualURL().SchemeIs( | |
| 6866 url::kDataScheme)); | |
| 6867 EXPECT_EQ(url::kAboutBlankURL, | |
| 6868 controller.GetLastCommittedEntry()->GetURL().spec()); | |
| 6869 } | |
| 6870 | |
| 6871 // The same as the test above, but uses reload instead of history navigation. | |
| 6872 // See https://crbug.com/723796. | |
| 6873 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, | |
| 6874 VerifyBlockedErrorPageURL_Reload) { | |
| 6875 NavigationControllerImpl& controller = static_cast<NavigationControllerImpl&>( | |
| 6876 shell()->web_contents()->GetController()); | |
| 6877 | |
| 6878 GURL start_url(embedded_test_server()->GetURL("/title1.html")); | |
| 6879 EXPECT_TRUE(NavigateToURL(shell(), start_url)); | |
| 6880 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); | |
| 6881 | |
| 6882 // Navigate to an URL, which redirects to a data: URL, since it is an | |
| 6883 // unsafe redirect and will result in a blocked navigation and error page. | |
| 6884 GURL redirect_to_blank_url( | |
| 6885 embedded_test_server()->GetURL("/server-redirect?data:foo")); | |
| 6886 EXPECT_FALSE(NavigateToURL(shell(), redirect_to_blank_url)); | |
| 6887 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | |
| 6888 EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType()); | |
| 6889 | |
| 6890 TestNavigationObserver reload_observer(shell()->web_contents()); | |
| 6891 controller.Reload(ReloadType::NORMAL, false); | |
| 6892 reload_observer.Wait(); | |
| 6893 | |
| 6894 // The expectation is that about:blank was loaded and the virtual URL is set | |
| 6895 // to the URL that was blocked. | |
| 6896 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); | |
| 6897 EXPECT_FALSE( | |
| 6898 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme)); | |
| 6899 EXPECT_TRUE(controller.GetLastCommittedEntry()->GetVirtualURL().SchemeIs( | |
| 6900 url::kDataScheme)); | |
| 6901 EXPECT_EQ(url::kAboutBlankURL, | |
| 6902 controller.GetLastCommittedEntry()->GetURL().spec()); | |
| 6903 } | |
| 6904 | |
| 6830 } // namespace content | 6905 } // namespace content |
| OLD | NEW |