Index: chrome/test/browser_with_test_window_test.cc |
=================================================================== |
--- chrome/test/browser_with_test_window_test.cc (revision 14577) |
+++ chrome/test/browser_with_test_window_test.cc (working copy) |
@@ -5,6 +5,7 @@ |
#include "chrome/test/browser_with_test_window_test.h" |
#include "chrome/browser/browser.h" |
+#include "chrome/browser/tab_contents/navigation_entry.h" |
#include "chrome/common/render_messages.h" |
#include "chrome/test/test_browser_window.h" |
#include "chrome/test/testing_profile.h" |
@@ -51,25 +52,37 @@ |
TabContents* new_tab = browser->AddTabWithURL(url, GURL(), |
PageTransition::TYPED, true, |
0, NULL); |
- CommitPendingLoadAsNewNavigation(&new_tab->controller(), url); |
+ CommitPendingLoad(&new_tab->controller()); |
} |
-void BrowserWithTestWindowTest::CommitPendingLoadAsNewNavigation( |
- NavigationController* controller, |
- const GURL& url) { |
+void BrowserWithTestWindowTest::CommitPendingLoad( |
+ NavigationController* controller) { |
+ if (!controller->pending_entry()) |
+ return; // Nothing to commit. |
+ |
TestRenderViewHost* test_rvh = |
TestRenderViewHostForTab(controller->tab_contents()); |
MockRenderProcessHost* mock_rph = static_cast<MockRenderProcessHost*>( |
test_rvh->process()); |
- test_rvh->SendNavigate(mock_rph->max_page_id() + 1, url); |
+ // For new navigations, we need to send a larger page ID. For renavigations, |
+ // we need to send the preexisting page ID. We can tell these apart because |
+ // renavigations will have a pending_entry_index while new ones won't (they'll |
+ // just have a standalong pending_entry that isn't in the list already). |
+ if (controller->pending_entry_index() >= 0) { |
+ test_rvh->SendNavigate(controller->pending_entry()->page_id(), |
+ controller->pending_entry()->url()); |
+ } else { |
+ test_rvh->SendNavigate(mock_rph->max_page_id() + 1, |
+ controller->pending_entry()->url()); |
+ } |
} |
void BrowserWithTestWindowTest::NavigateAndCommit( |
NavigationController* controller, |
const GURL& url) { |
controller->LoadURL(url, GURL(), 0); |
- CommitPendingLoadAsNewNavigation(controller, url); |
+ CommitPendingLoad(controller); |
} |
void BrowserWithTestWindowTest::NavigateAndCommitActiveTab(const GURL& url) { |