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

Unified Diff: chrome/test/browser_with_test_window_test.cc

Issue 100031: Write a test for my previous patch to fix a crash in back/forward navigations... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 8 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
« no previous file with comments | « chrome/test/browser_with_test_window_test.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« no previous file with comments | « chrome/test/browser_with_test_window_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698