| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/bind.h" | 6 #include "base/bind.h" |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3065 EXPECT_TRUE(controller.GetVisibleEntry()); | 3065 EXPECT_TRUE(controller.GetVisibleEntry()); |
| 3066 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); | 3066 EXPECT_EQ(url1, controller.GetVisibleEntry()->GetURL()); |
| 3067 | 3067 |
| 3068 notifications.Reset(); | 3068 notifications.Reset(); |
| 3069 } | 3069 } |
| 3070 | 3070 |
| 3071 // Tests that IsInPageNavigation returns appropriate results. Prevents | 3071 // Tests that IsInPageNavigation returns appropriate results. Prevents |
| 3072 // regression for bug 1126349. | 3072 // regression for bug 1126349. |
| 3073 TEST_F(NavigationControllerTest, IsInPageNavigation) { | 3073 TEST_F(NavigationControllerTest, IsInPageNavigation) { |
| 3074 NavigationControllerImpl& controller = controller_impl(); | 3074 NavigationControllerImpl& controller = controller_impl(); |
| 3075 const GURL url("http://www.google.com/home.html"); |
| 3076 |
| 3077 // If the renderer claims it performed an in-page navigation from |
| 3078 // about:blank, trust the renderer. |
| 3079 // This can happen when an iframe is created and populated via |
| 3080 // document.write(), then tries to perform a fragment navigation. |
| 3081 // TODO(japhet): We should only trust the renderer if the about:blank |
| 3082 // was the first document in the given frame, but we don't have enough |
| 3083 // information to identify that case currently. |
| 3084 const GURL blank_url(url::kAboutBlankURL); |
| 3085 main_test_rfh()->SendNavigate(0, blank_url); |
| 3086 EXPECT_TRUE(controller.IsURLInPageNavigation(url, true, |
| 3087 main_test_rfh())); |
| 3088 |
| 3075 // Navigate to URL with no refs. | 3089 // Navigate to URL with no refs. |
| 3076 const GURL url("http://www.google.com/home.html"); | |
| 3077 main_test_rfh()->SendNavigate(0, url); | 3090 main_test_rfh()->SendNavigate(0, url); |
| 3078 | 3091 |
| 3079 // Reloading the page is not an in-page navigation. | 3092 // Reloading the page is not an in-page navigation. |
| 3080 EXPECT_FALSE(controller.IsURLInPageNavigation(url, false, | 3093 EXPECT_FALSE(controller.IsURLInPageNavigation(url, false, |
| 3081 main_test_rfh())); | 3094 main_test_rfh())); |
| 3082 const GURL other_url("http://www.google.com/add.html"); | 3095 const GURL other_url("http://www.google.com/add.html"); |
| 3083 EXPECT_FALSE(controller.IsURLInPageNavigation(other_url, false, | 3096 EXPECT_FALSE(controller.IsURLInPageNavigation(other_url, false, |
| 3084 main_test_rfh())); | 3097 main_test_rfh())); |
| 3085 const GURL url_with_ref("http://www.google.com/home.html#my_ref"); | 3098 const GURL url_with_ref("http://www.google.com/home.html#my_ref"); |
| 3086 EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref, true, | 3099 EXPECT_TRUE(controller.IsURLInPageNavigation(url_with_ref, true, |
| (...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4325 params.post_id = -1; | 4338 params.post_id = -1; |
| 4326 test_rvh()->SendNavigateWithParams(¶ms); | 4339 test_rvh()->SendNavigateWithParams(¶ms); |
| 4327 | 4340 |
| 4328 // Now reload. replaceState overrides the POST, so we should not show a | 4341 // Now reload. replaceState overrides the POST, so we should not show a |
| 4329 // repost warning dialog. | 4342 // repost warning dialog. |
| 4330 controller_impl().Reload(true); | 4343 controller_impl().Reload(true); |
| 4331 EXPECT_EQ(0, delegate->repost_form_warning_count()); | 4344 EXPECT_EQ(0, delegate->repost_form_warning_count()); |
| 4332 } | 4345 } |
| 4333 | 4346 |
| 4334 } // namespace content | 4347 } // namespace content |
| OLD | NEW |