Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl_browsertest.cc

Issue 2917133002: Perform redirect checks before OnReceivedRedirect in //net. (Closed)
Patch Set: nasko comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 6825 matching lines...) Expand 10 before | Expand all | Expand 10 after
6836 shell()->web_contents()->GetController()); 6836 shell()->web_contents()->GetController());
6837 6837
6838 GURL start_url(embedded_test_server()->GetURL("/title1.html")); 6838 GURL start_url(embedded_test_server()->GetURL("/title1.html"));
6839 EXPECT_TRUE(NavigateToURL(shell(), start_url)); 6839 EXPECT_TRUE(NavigateToURL(shell(), start_url));
6840 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex()); 6840 EXPECT_EQ(0, controller.GetLastCommittedEntryIndex());
6841 6841
6842 // Navigate to an URL, which redirects to a data: URL, since it is an 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. 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 6844 // TODO(nasko): Find a different way to cause a blocked navigation, so
6845 // we test a bit more generic case. 6845 // we test a bit more generic case.
6846 GURL redirect_to_blank_url( 6846 GURL redirect_to_unsafe_url(
6847 embedded_test_server()->GetURL("/server-redirect?data:text/html,Hello!")); 6847 embedded_test_server()->GetURL("/server-redirect?data:text/html,Hello!"));
6848 EXPECT_FALSE(NavigateToURL(shell(), redirect_to_blank_url)); 6848 EXPECT_FALSE(NavigateToURL(shell(), redirect_to_unsafe_url));
6849 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 6849 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
6850 EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType()); 6850 EXPECT_EQ(PAGE_TYPE_ERROR, controller.GetLastCommittedEntry()->GetPageType());
6851 6851
6852 // Navigate to a new document, then go back in history trying to load the 6852 // Navigate to a new document, then go back in history trying to load the
6853 // blocked URL. 6853 // blocked URL.
6854 EXPECT_TRUE( 6854 EXPECT_TRUE(
6855 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html"))); 6855 NavigateToURL(shell(), embedded_test_server()->GetURL("/title1.html")));
6856 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex()); 6856 EXPECT_EQ(2, controller.GetLastCommittedEntryIndex());
6857 6857
6858 TestNavigationObserver back_load_observer(shell()->web_contents()); 6858 TestNavigationObserver back_load_observer(shell()->web_contents());
6859 controller.GoBack(); 6859 controller.GoBack();
6860 back_load_observer.Wait(); 6860 back_load_observer.Wait();
6861 6861
6862 // The expectation is that about:blank was loaded and the virtual URL is set 6862 // The expectation is that about:blank was loaded and the virtual URL is set
6863 // to the URL that was blocked. 6863 // to the URL that was blocked.
6864 //
6865 // TODO(nasko): Now that the error commits on the previous URL, the blocked
6866 // navigation logic is no longer needed. https://crbug.com/723796
6864 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex()); 6867 EXPECT_EQ(1, controller.GetLastCommittedEntryIndex());
6865 EXPECT_FALSE( 6868 EXPECT_FALSE(
6866 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme)); 6869 controller.GetLastCommittedEntry()->GetURL().SchemeIs(url::kDataScheme));
6867 EXPECT_TRUE(controller.GetLastCommittedEntry()->GetVirtualURL().SchemeIs( 6870 EXPECT_EQ(redirect_to_unsafe_url,
6868 url::kDataScheme)); 6871 controller.GetLastCommittedEntry()->GetVirtualURL());
6869 EXPECT_EQ(url::kAboutBlankURL, 6872 EXPECT_EQ(url::kAboutBlankURL,
6870 controller.GetLastCommittedEntry()->GetURL().spec()); 6873 controller.GetLastCommittedEntry()->GetURL().spec());
6871 } 6874 }
6872 6875
6873 } // namespace content 6876 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698