diff options
author | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 16:29:54 +0000 |
---|---|---|
committer | jcivelli@chromium.org <jcivelli@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-07 16:29:54 +0000 |
commit | 876bc8333dd6641a98a641b33e5c2db6ddb65655 (patch) | |
tree | f1ff683ed9b7778a1f75302d3b488480da5f1aec /chrome/browser/tab_contents/test_tab_contents.cc | |
parent | 8d2704858e4d35f53dbafdc61536f66a6e66a80d (diff) | |
download | chromium_src-876bc8333dd6641a98a641b33e5c2db6ddb65655.zip chromium_src-876bc8333dd6641a98a641b33e5c2db6ddb65655.tar.gz chromium_src-876bc8333dd6641a98a641b33e5c2db6ddb65655.tar.bz2 |
Relanding this:
Don't create pending entries when a navigation is initiated by the page.
If the page reloads while such a navigation happens, we could end up with the wrong pending entry. Also make sure TestTabContents::NavigateAndCommit() does commit on the right RVH.
BUG=51680
TEST=See bug for steps.
TBR=creis
Review URL: http://codereview.chromium.org/3257002
Review URL: http://codereview.chromium.org/3346005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58701 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/test_tab_contents.cc')
-rw-r--r-- | chrome/browser/tab_contents/test_tab_contents.cc | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/chrome/browser/tab_contents/test_tab_contents.cc b/chrome/browser/tab_contents/test_tab_contents.cc index 54a6873..2c1ba39 100644 --- a/chrome/browser/tab_contents/test_tab_contents.cc +++ b/chrome/browser/tab_contents/test_tab_contents.cc @@ -45,7 +45,7 @@ void TestTabContents::Observe(NotificationType type, } } -TestRenderViewHost* TestTabContents::pending_rvh() { +TestRenderViewHost* TestTabContents::pending_rvh() const { return static_cast<TestRenderViewHost*>( render_manager_.pending_render_view_host_); } @@ -70,7 +70,34 @@ void TestTabContents::NavigateAndCommit(const GURL& url) { bool reverse_on_redirect = false; BrowserURLHandler::RewriteURLIfNecessary( &loaded_url, profile(), &reverse_on_redirect); - static_cast<TestRenderViewHost*>(render_view_host())->SendNavigate( - static_cast<MockRenderProcessHost*>(render_view_host()->process())-> - max_page_id() + 1, loaded_url); + + // LoadURL created a navigation entry, now simulate the RenderView sending + // a notification that it actually navigated. + CommitPendingNavigation(); +} + +void TestTabContents::CommitPendingNavigation() { + // If we are doing a cross-site navigation, this simulates the current RVH + // notifying that it has unloaded so the pending RVH is resumed and can + // navigate. + ProceedWithCrossSiteNavigation(); + TestRenderViewHost* rvh = pending_rvh(); + if (!rvh) + rvh = static_cast<TestRenderViewHost*>(render_manager_.current_host()); + + const NavigationEntry* entry = controller().pending_entry(); + DCHECK(entry); + int page_id = entry->page_id(); + if (page_id == -1) { + // It's a new navigation, assign a never-seen page id to it. + page_id = + static_cast<MockRenderProcessHost*>(rvh->process())->max_page_id() + 1; + } + rvh->SendNavigate(page_id, entry->url()); +} + +void TestTabContents::ProceedWithCrossSiteNavigation() { + if (!pending_rvh()) + return; + render_manager_.ShouldClosePage(true, true); } |