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. See https://crbug.com/723796. |
| 6833 IN_PROC_BROWSER_TEST_F(NavigationControllerBrowserTest, |
| 6834 VerifyBlockedErrorPageURL_SessionHistory) { |
| 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 // TODO(nasko): Find a different way to cause a blocked navigation, so |
| 6845 // we test a bit more generic case. |
| 6846 GURL redirect_to_blank_url( |
| 6847 embedded_test_server()->GetURL("/server-redirect?data:text/html,Hello!")); |
| 6848 EXPECT_FALSE(NavigateToURL(shell(), redirect_to_blank_url)); |
| 6849 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 6850 EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType()); |
| 6851 |
| 6852 // Navigate to a new document, then go back in history trying to load the |
| 6853 // blocked URL. |
| 6854 EXPECT_TRUE( |
| 6855 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); |
| 6856 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); |
| 6857 |
| 6858 TestNavigationObserver back_load_observer(shell()->web_contents()); |
| 6859 controller.GoBack(); |
| 6860 back_load_observer.Wait(); |
| 6861 |
| 6862 // The expectation is that about:blank was loaded and the virtual URL is set |
| 6863 // to the URL that was blocked. |
| 6864 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); |
| 6865 EXPECT_FALSE( |
| 6866 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme)); |
| 6867 EXPECT_TRUE(controller.GetLastCommittedEntry()->GetVirtualURL().SchemeIs( |
| 6868 url::kDataScheme)); |
| 6869 EXPECT_EQ(url::kAboutBlankURL, |
| 6870 controller.GetLastCommittedEntry()->GetURL().spec()); |
| 6871 } |
| 6872 |
6830 } // namespace content | 6873 } // namespace content |
OLD | NEW |