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

Unified Diff: content/browser/frame_host/navigation_controller_impl_unittest.cc

Issue 304763002: Trust the renderer's same-document navigation flag if it is a same-origin nav. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/frame_host/navigation_controller_impl_unittest.cc
diff --git a/content/browser/frame_host/navigation_controller_impl_unittest.cc b/content/browser/frame_host/navigation_controller_impl_unittest.cc
index 1a8c8a9b0de32ff3710d9bbb2c43c6b8b08a1c47..34f8970e20ae29b57b811f7e040c434f9e89a0e9 100644
--- a/content/browser/frame_host/navigation_controller_impl_unittest.cc
+++ b/content/browser/frame_host/navigation_controller_impl_unittest.cc
@@ -2151,6 +2151,7 @@ TEST_F(NavigationControllerTest, InPage_Replace) {
params.gesture = NavigationGestureUser;
params.is_post = false;
params.page_state = PageState::CreateFromURL(url2);
+ params.was_within_same_page = true;
// This should NOT generate a new entry, nor prune the list.
LoadCommittedDetails details;
@@ -2202,6 +2203,7 @@ TEST_F(NavigationControllerTest, ClientRedirectAfterInPageNavigation) {
params.gesture = NavigationGestureUnknown;
params.is_post = false;
params.page_state = PageState::CreateFromURL(url);
+ params.was_within_same_page = true;
// This should NOT generate a new entry, nor prune the list.
LoadCommittedDetails details;
@@ -3052,21 +3054,28 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
main_test_rfh()->SendNavigate(0, url);
// Reloading the page is not an in-page navigation.
- EXPECT_FALSE(controller.IsURLInPageNavigation(url));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(url, false,
+ NAVIGATION_TYPE_UNKNOWN));
const GURL other_url("http://www.google.com/add.html");
- EXPECT_FALSE(controller.IsURLInPageNavigation(other_url));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(other_url, false,
+ NAVIGATION_TYPE_UNKNOWN));
const GURL url_with_ref("http://www.google.com/home.html#my_ref");
- EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref));
+ EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref, true,
+ NAVIGATION_TYPE_UNKNOWN));
// Navigate to URL with refs.
main_test_rfh()->SendNavigate(1, url_with_ref);
// Reloading the page is not an in-page navigation.
- EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref));
- EXPECT_FALSE(controller.IsURLInPageNavigation(url));
- EXPECT_FALSE(controller.IsURLInPageNavigation(other_url));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(url_with_ref, false,
+ NAVIGATION_TYPE_UNKNOWN));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(url, false,
+ NAVIGATION_TYPE_UNKNOWN));
+ EXPECT_FALSE(controller.IsURLInPageNavigation(other_url, false,
+ NAVIGATION_TYPE_UNKNOWN));
const GURL other_url_with_ref("http://www.google.com/home.html#my_other_ref");
- EXPECT_TRUE(controller.IsURLInPageNavigation(other_url_with_ref));
+ EXPECT_TRUE(controller.IsURLInPageNavigation(other_url_with_ref, true,
+ NAVIGATION_TYPE_UNKNOWN));
// Going to the same url again will be considered in-page
// if the renderer says it is even if the navigation type isn't IN_PAGE.
@@ -3077,6 +3086,17 @@ TEST_F(NavigationControllerTest, IsInPageNavigation) {
// type is IN_PAGE.
EXPECT_TRUE(controller.IsURLInPageNavigation(url, true,
NAVIGATION_TYPE_IN_PAGE));
+
+ // If the renderer says this is a same-origin in-page navigation, believe it.
+ // This is the pushState/replaceState case.
+ EXPECT_TRUE(controller.IsURLInPageNavigation(other_url, true,
+ NAVIGATION_TYPE_UNKNOWN));
+
+ // Don't believe the renderer if it claims a cross-origin navigation is
+ // in-page.
+ const GURL different_origin_url("http://www.example.com");
+ EXPECT_FALSE(controller.IsURLInPageNavigation(different_origin_url, true,
+ NAVIGATION_TYPE_UNKNOWN));
}
// Some pages can have subframes with the same base URL (minus the reference) as

Powered by Google App Engine
This is Rietveld 408576698