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

Side by Side Diff: chrome/test/base/browser_with_test_window_test.cc

Issue 88503002: Have the unload event execute in background on cross-site navigations (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added unit tests Created 6 years, 11 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/test/base/browser_with_test_window_test.h" 5 #include "chrome/test/base/browser_with_test_window_test.h"
6 6
7 #include "base/run_loop.h" 7 #include "base/run_loop.h"
8 #include "chrome/browser/profiles/profile_destroyer.h" 8 #include "chrome/browser/profiles/profile_destroyer.h"
9 #include "chrome/browser/ui/browser.h" 9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_navigator.h" 10 #include "chrome/browser/ui/browser_navigator.h"
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 if (pending_rvh) { 126 if (pending_rvh) {
127 // Simulate the ShouldClose_ACK that is received from the current renderer 127 // Simulate the ShouldClose_ACK that is received from the current renderer
128 // for a cross-site navigation. 128 // for a cross-site navigation.
129 DCHECK_NE(old_rvh, pending_rvh); 129 DCHECK_NE(old_rvh, pending_rvh);
130 RenderViewHostTester::For(old_rvh)->SendShouldCloseACK(true); 130 RenderViewHostTester::For(old_rvh)->SendShouldCloseACK(true);
131 } 131 }
132 // Commit on the pending_rvh, if one exists. 132 // Commit on the pending_rvh, if one exists.
133 RenderViewHost* test_rvh = pending_rvh ? pending_rvh : old_rvh; 133 RenderViewHost* test_rvh = pending_rvh ? pending_rvh : old_rvh;
134 RenderViewHostTester* test_rvh_tester = RenderViewHostTester::For(test_rvh); 134 RenderViewHostTester* test_rvh_tester = RenderViewHostTester::For(test_rvh);
135 135
136 // Simulate a SwapOut_ACK before the navigation commits.
137 if (pending_rvh)
138 RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK();
139 136
140 // For new navigations, we need to send a larger page ID. For renavigations, 137 // For new navigations, we need to send a larger page ID. For renavigations,
141 // we need to send the preexisting page ID. We can tell these apart because 138 // we need to send the preexisting page ID. We can tell these apart because
142 // renavigations will have a pending_entry_index while new ones won't (they'll 139 // renavigations will have a pending_entry_index while new ones won't (they'll
143 // just have a standalong pending_entry that isn't in the list already). 140 // just have a standalong pending_entry that isn't in the list already).
144 if (controller->GetPendingEntryIndex() >= 0) { 141 if (controller->GetPendingEntryIndex() >= 0) {
145 test_rvh_tester->SendNavigateWithTransition( 142 test_rvh_tester->SendNavigateWithTransition(
146 controller->GetPendingEntry()->GetPageID(), 143 controller->GetPendingEntry()->GetPageID(),
147 controller->GetPendingEntry()->GetURL(), 144 controller->GetPendingEntry()->GetURL(),
148 controller->GetPendingEntry()->GetTransitionType()); 145 controller->GetPendingEntry()->GetTransitionType());
149 } else { 146 } else {
150 test_rvh_tester->SendNavigateWithTransition( 147 test_rvh_tester->SendNavigateWithTransition(
151 controller->GetWebContents()-> 148 controller->GetWebContents()->
152 GetMaxPageIDForSiteInstance(test_rvh->GetSiteInstance()) + 1, 149 GetMaxPageIDForSiteInstance(test_rvh->GetSiteInstance()) + 1,
153 controller->GetPendingEntry()->GetURL(), 150 controller->GetPendingEntry()->GetURL(),
154 controller->GetPendingEntry()->GetTransitionType()); 151 controller->GetPendingEntry()->GetTransitionType());
155 } 152 }
153 // Simulate the SwapOut_ACK from the renderer.
nasko 2014/01/23 23:34:58 Why did this move?
clamy 2014/01/24 17:01:54 It was causing a problem with some tests in unit_t
154 if (pending_rvh)
155 RenderViewHostTester::For(old_rvh)->SimulateSwapOutACK();
156 } 156 }
157 157
158 void BrowserWithTestWindowTest::NavigateAndCommit( 158 void BrowserWithTestWindowTest::NavigateAndCommit(
159 NavigationController* controller, 159 NavigationController* controller,
160 const GURL& url) { 160 const GURL& url) {
161 controller->LoadURL( 161 controller->LoadURL(
162 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string()); 162 url, content::Referrer(), content::PAGE_TRANSITION_LINK, std::string());
163 CommitPendingLoad(controller); 163 CommitPendingLoad(controller);
164 } 164 }
165 165
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 Browser::CreateParams params(profile, host_desktop_type); 215 Browser::CreateParams params(profile, host_desktop_type);
216 params.window = browser_window; 216 params.window = browser_window;
217 return new Browser(params); 217 return new Browser(params);
218 } 218 }
219 219
220 #if defined(TOOLKIT_VIEWS) 220 #if defined(TOOLKIT_VIEWS)
221 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() { 221 views::ViewsDelegate* BrowserWithTestWindowTest::CreateViewsDelegate() {
222 return new views::TestViewsDelegate; 222 return new views::TestViewsDelegate;
223 } 223 }
224 #endif 224 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698