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

Side by Side Diff: chrome/browser/navigation_controller_unittest.cc

Issue 4250: Fix a crash when a frame was inserted into a popup and navigated. I added a... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 12 years, 2 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/navigation_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/path_service.h" 6 #include "base/path_service.h"
7 #include "base/string_util.h" 7 #include "base/string_util.h"
8 #include "chrome/browser/browser_type.h" 8 #include "chrome/browser/browser_type.h"
9 #include "chrome/browser/navigation_controller.h" 9 #include "chrome/browser/navigation_controller.h"
10 #include "chrome/browser/navigation_entry.h" 10 #include "chrome/browser/navigation_entry.h"
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
867 867
868 // The new entry should be appended. 868 // The new entry should be appended.
869 EXPECT_EQ(2, contents->controller()->GetEntryCount()); 869 EXPECT_EQ(2, contents->controller()->GetEntryCount());
870 870
871 // New entry should refer to the new page, but the old URL (entries only 871 // New entry should refer to the new page, but the old URL (entries only
872 // reflect the toplevel URL). 872 // reflect the toplevel URL).
873 EXPECT_EQ(url1, details.entry->url()); 873 EXPECT_EQ(url1, details.entry->url());
874 EXPECT_EQ(params.page_id, details.entry->page_id()); 874 EXPECT_EQ(params.page_id, details.entry->page_id());
875 } 875 }
876 876
877 // Some pages create a popup, then write an iframe into it. This causes a
878 // subframe navigation without having any committed entry. Such navigations
879 // just get thrown on the ground, but we shouldn't crash.
880 TEST_F(NavigationControllerTest, SubframeOnEmptyPage) {
881 TestNotificationTracker notifications;
882 RegisterForAllNavNotifications(&notifications, contents->controller());
883
884 // Navigation controller currently has no entries.
885 const GURL url("test1:foo2");
886 ViewHostMsg_FrameNavigate_Params params;
887 params.page_id = 1;
888 params.url = url;
889 params.transition = PageTransition::AUTO_SUBFRAME;
890 params.should_update_history = false;
891 params.gesture = NavigationGestureAuto;
892 params.is_post = false;
893
894 NavigationController::LoadCommittedDetails details;
895 EXPECT_FALSE(contents->controller()->RendererDidNavigate(params, false,
896 &details));
897 EXPECT_EQ(0, notifications.size());
898 }
899
877 // Auto subframes are ones the page loads automatically like ads. They should 900 // Auto subframes are ones the page loads automatically like ads. They should
878 // not create new navigation entries. 901 // not create new navigation entries.
879 TEST_F(NavigationControllerTest, AutoSubframe) { 902 TEST_F(NavigationControllerTest, AutoSubframe) {
880 TestNotificationTracker notifications; 903 TestNotificationTracker notifications;
881 RegisterForAllNavNotifications(&notifications, contents->controller()); 904 RegisterForAllNavNotifications(&notifications, contents->controller());
882 905
883 const GURL url1("test1:foo1"); 906 const GURL url1("test1:foo1");
884 contents->CompleteNavigationAsRenderer(0, url1); 907 contents->CompleteNavigationAsRenderer(0, url1);
885 EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED)); 908 EXPECT_TRUE(notifications.Check1AndReset(NOTIFY_NAV_ENTRY_COMMITTED));
886 909
(...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1414 1437
1415 helper_.AssertSingleWindowWithSingleTab(windows_, 2); 1438 helper_.AssertSingleWindowWithSingleTab(windows_, 2);
1416 helper_.AssertTabEquals(0, 1, 2, *(windows_[0]->tabs[0])); 1439 helper_.AssertTabEquals(0, 1, 2, *(windows_[0]->tabs[0]));
1417 1440
1418 TabNavigation nav(0, url0, std::wstring(), std::string(), 1441 TabNavigation nav(0, url0, std::wstring(), std::string(),
1419 PageTransition::LINK); 1442 PageTransition::LINK);
1420 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[0]); 1443 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[0]);
1421 nav.url = url2; 1444 nav.url = url2;
1422 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[1]); 1445 helper_.AssertNavigationEquals(nav, windows_[0]->tabs[0]->navigations[1]);
1423 } 1446 }
OLDNEW
« no previous file with comments | « chrome/browser/navigation_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698