OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
293 EXPECT_EQ(controller.GetEntryCount(), 1); | 293 EXPECT_EQ(controller.GetEntryCount(), 1); |
294 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 294 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
295 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); | 295 EXPECT_EQ(controller.GetPendingEntryIndex(), -1); |
296 EXPECT_TRUE(controller.GetLastCommittedEntry()); | 296 EXPECT_TRUE(controller.GetLastCommittedEntry()); |
297 EXPECT_FALSE(controller.GetPendingEntry()); | 297 EXPECT_FALSE(controller.GetPendingEntry()); |
298 ASSERT_TRUE(controller.GetActiveEntry()); | 298 ASSERT_TRUE(controller.GetActiveEntry()); |
299 EXPECT_EQ(controller.GetActiveEntry(), controller.GetVisibleEntry()); | 299 EXPECT_EQ(controller.GetActiveEntry(), controller.GetVisibleEntry()); |
300 EXPECT_FALSE(controller.CanGoBack()); | 300 EXPECT_FALSE(controller.CanGoBack()); |
301 EXPECT_FALSE(controller.CanGoForward()); | 301 EXPECT_FALSE(controller.CanGoForward()); |
302 EXPECT_EQ(contents()->GetMaxPageID(), 0); | 302 EXPECT_EQ(contents()->GetMaxPageID(), 0); |
303 EXPECT_EQ(0, NavigationEntryImpl::FromNavigationEntry( | |
304 controller.GetLastCommittedEntry())->bindings()); | |
303 | 305 |
304 // The timestamp should have been set. | 306 // The timestamp should have been set. |
305 EXPECT_FALSE(controller.GetActiveEntry()->GetTimestamp().is_null()); | 307 EXPECT_FALSE(controller.GetActiveEntry()->GetTimestamp().is_null()); |
306 | 308 |
307 // Load another... | 309 // Load another... |
308 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 310 controller.LoadURL(url2, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
309 | 311 |
310 // The load should now be pending. | 312 // The load should now be pending. |
311 EXPECT_EQ(controller.GetEntryCount(), 1); | 313 EXPECT_EQ(controller.GetEntryCount(), 1); |
312 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); | 314 EXPECT_EQ(controller.GetLastCommittedEntryIndex(), 0); |
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
858 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); | 860 EXPECT_EQ(-1, controller.GetLastCommittedEntryIndex()); |
859 EXPECT_EQ(1, delegate->navigation_state_change_count()); | 861 EXPECT_EQ(1, delegate->navigation_state_change_count()); |
860 | 862 |
861 // There should be no visible entry (resulting in about:blank in the | 863 // There should be no visible entry (resulting in about:blank in the |
862 // omnibox), ensuring no spoof is possible. | 864 // omnibox), ensuring no spoof is possible. |
863 EXPECT_FALSE(controller.GetVisibleEntry()); | 865 EXPECT_FALSE(controller.GetVisibleEntry()); |
864 | 866 |
865 contents()->SetDelegate(NULL); | 867 contents()->SetDelegate(NULL); |
866 } | 868 } |
867 | 869 |
870 // Ensure that NavigationEntries track which bindings their RenderViewHost had | |
871 // at the time they committed. http://crbug.com/173672. | |
872 TEST_F(NavigationControllerTest, LoadURL_WithBindings) { | |
873 NavigationControllerImpl& controller = controller_impl(); | |
874 TestNotificationTracker notifications; | |
875 RegisterForAllNavNotifications(¬ifications, &controller); | |
876 | |
877 const GURL url1("http://foo1"); | |
878 | |
879 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | |
880 | |
881 // Set bindings on the underlying RenderViewHost to simulate a privileged url. | |
882 test_rvh()->AllowBindings(1); | |
883 | |
884 test_rvh()->SendNavigate(0, url1); | |
885 EXPECT_TRUE(notifications.Check1AndReset(NOTIFICATION_NAV_ENTRY_COMMITTED)); | |
886 | |
887 // The load should now be committed, and bindings should be remembered. | |
888 EXPECT_EQ(controller.GetEntryCount(), 1); | |
889 EXPECT_TRUE(controller.GetLastCommittedEntry()); | |
890 EXPECT_EQ(1, NavigationEntryImpl::FromNavigationEntry( | |
891 controller.GetLastCommittedEntry())->bindings()); | |
Chris Evans
2013/02/01 22:47:47
Is it possible to actually do a history.back() and
Charlie Reis
2013/02/04 06:03:40
In the first patchset, there's only one entry and
| |
892 } | |
893 | |
868 TEST_F(NavigationControllerTest, Reload) { | 894 TEST_F(NavigationControllerTest, Reload) { |
869 NavigationControllerImpl& controller = controller_impl(); | 895 NavigationControllerImpl& controller = controller_impl(); |
870 TestNotificationTracker notifications; | 896 TestNotificationTracker notifications; |
871 RegisterForAllNavNotifications(¬ifications, &controller); | 897 RegisterForAllNavNotifications(¬ifications, &controller); |
872 | 898 |
873 const GURL url1("http://foo1"); | 899 const GURL url1("http://foo1"); |
874 | 900 |
875 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); | 901 controller.LoadURL(url1, Referrer(), PAGE_TRANSITION_TYPED, std::string()); |
876 EXPECT_EQ(0U, notifications.size()); | 902 EXPECT_EQ(0U, notifications.size()); |
877 test_rvh()->SendNavigate(0, url1); | 903 test_rvh()->SendNavigate(0, url1); |
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3283 PAGE_TRANSITION_LINK); | 3309 PAGE_TRANSITION_LINK); |
3284 session_helper_.AssertNavigationEquals(nav, | 3310 session_helper_.AssertNavigationEquals(nav, |
3285 windows_[0]->tabs[0]->navigations[0]); | 3311 windows_[0]->tabs[0]->navigations[0]); |
3286 nav.set_url(url2); | 3312 nav.set_url(url2); |
3287 session_helper_.AssertNavigationEquals(nav, | 3313 session_helper_.AssertNavigationEquals(nav, |
3288 windows_[0]->tabs[0]->navigations[1]); | 3314 windows_[0]->tabs[0]->navigations[1]); |
3289 } | 3315 } |
3290 */ | 3316 */ |
3291 | 3317 |
3292 } // namespace content | 3318 } // namespace content |
OLD | NEW |