OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/tab_contents/test_tab_contents.h" | 5 #include "content/browser/tab_contents/test_tab_contents.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "chrome/browser/browser_url_handler.h" | 9 #include "chrome/browser/browser_url_handler.h" |
10 #include "chrome/browser/tab_contents/infobar_delegate.h" | 10 #include "chrome/browser/tab_contents/infobar_delegate.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // LoadURL created a navigation entry, now simulate the RenderView sending | 78 // LoadURL created a navigation entry, now simulate the RenderView sending |
79 // a notification that it actually navigated. | 79 // a notification that it actually navigated. |
80 CommitPendingNavigation(); | 80 CommitPendingNavigation(); |
81 } | 81 } |
82 | 82 |
83 void TestTabContents::CommitPendingNavigation() { | 83 void TestTabContents::CommitPendingNavigation() { |
84 // If we are doing a cross-site navigation, this simulates the current RVH | 84 // If we are doing a cross-site navigation, this simulates the current RVH |
85 // notifying that it has unloaded so the pending RVH is resumed and can | 85 // notifying that it has unloaded so the pending RVH is resumed and can |
86 // navigate. | 86 // navigate. |
87 ProceedWithCrossSiteNavigation(); | 87 ProceedWithCrossSiteNavigation(); |
| 88 RenderViewHost* old_rvh = render_manager_.current_host(); |
88 TestRenderViewHost* rvh = pending_rvh(); | 89 TestRenderViewHost* rvh = pending_rvh(); |
89 if (!rvh) | 90 if (!rvh) |
90 rvh = static_cast<TestRenderViewHost*>(render_manager_.current_host()); | 91 rvh = static_cast<TestRenderViewHost*>(old_rvh); |
91 | 92 |
92 const NavigationEntry* entry = controller().pending_entry(); | 93 const NavigationEntry* entry = controller().pending_entry(); |
93 DCHECK(entry); | 94 DCHECK(entry); |
94 int page_id = entry->page_id(); | 95 int page_id = entry->page_id(); |
95 if (page_id == -1) { | 96 if (page_id == -1) { |
96 // It's a new navigation, assign a never-seen page id to it. | 97 // It's a new navigation, assign a never-seen page id to it. |
97 page_id = | 98 page_id = |
98 static_cast<MockRenderProcessHost*>(rvh->process())->max_page_id() + 1; | 99 static_cast<MockRenderProcessHost*>(rvh->process())->max_page_id() + 1; |
99 } | 100 } |
100 rvh->SendNavigate(page_id, entry->url()); | 101 rvh->SendNavigate(page_id, entry->url()); |
| 102 |
| 103 // Simulate the SwapOut_ACK that fires if you commit a cross-site navigation |
| 104 // without making any network requests. |
| 105 if (old_rvh != rvh) |
| 106 old_rvh->OnSwapOutACK(); |
101 } | 107 } |
102 | 108 |
103 void TestTabContents::ProceedWithCrossSiteNavigation() { | 109 void TestTabContents::ProceedWithCrossSiteNavigation() { |
104 if (!pending_rvh()) | 110 if (!pending_rvh()) |
105 return; | 111 return; |
106 render_manager_.ShouldClosePage(true, true); | 112 render_manager_.ShouldClosePage(true, true); |
107 } | 113 } |
OLD | NEW |