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

Side by Side Diff: content/test/test_web_contents.cc

Issue 789643005: PlzNavigate: make content unit tests work with browser side navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cancel-navigations
Patch Set: Fixed nits Created 5 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
« no previous file with comments | « content/browser/web_contents/web_contents_impl_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/test/test_web_contents.h" 5 #include "content/test/test_web_contents.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "content/browser/browser_url_handler_impl.h" 10 #include "content/browser/browser_url_handler_impl.h"
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 // LoadURL created a navigation entry, now simulate the RenderView sending 139 // LoadURL created a navigation entry, now simulate the RenderView sending
140 // a notification that it actually navigated. 140 // a notification that it actually navigated.
141 CommitPendingNavigation(); 141 CommitPendingNavigation();
142 } 142 }
143 143
144 void TestWebContents::TestSetIsLoading(bool value) { 144 void TestWebContents::TestSetIsLoading(bool value) {
145 SetIsLoading(GetRenderViewHost(), value, true, NULL); 145 SetIsLoading(GetRenderViewHost(), value, true, NULL);
146 } 146 }
147 147
148 void TestWebContents::CommitPendingNavigation() { 148 void TestWebContents::CommitPendingNavigation() {
149 const NavigationEntry* entry = GetController().GetPendingEntry();
150 DCHECK(entry);
151
149 // If we are doing a cross-site navigation, this simulates the current RFH 152 // If we are doing a cross-site navigation, this simulates the current RFH
150 // notifying that it has unloaded so the pending RFH is resumed and can 153 // notifying that it has unloaded so the pending RFH is resumed and can
151 // navigate. 154 // navigate.
152 TestRenderFrameHost* old_rfh = GetMainFrame();
153 const NavigationEntry* entry = GetController().GetPendingEntry();
154 DCHECK(entry);
155
156 // Simulate the BeforeUnload ACK if necessary.
157 // PlzNavigate: the pending RFH is not created before the navigation commit, 155 // PlzNavigate: the pending RFH is not created before the navigation commit,
158 // so it is necessary to simulate the IO thread response here to commit in the 156 // so it is necessary to simulate the IO thread response here to commit in the
159 // proper renderer. 157 // proper renderer. It is necessary to call PrepareForCommit before getting
160 old_rfh->PrepareForCommit(entry->GetURL()); 158 // the main and the pending frame because when we are trying to navigate to a
159 // webui from a new tab, a RenderFrameHost is created to display it that is
160 // committed immediately (since it is a new tab). Therefore the main frame is
161 // replaced without a pending frame being created, and we don't get the right
162 // values for the RFH to navigate: we try to use the old one that has been
163 // deleted in the meantime.
164 GetMainFrame()->PrepareForCommit(entry->GetURL());
161 165
166 TestRenderFrameHost* old_rfh = GetMainFrame();
162 TestRenderFrameHost* rfh = GetPendingMainFrame(); 167 TestRenderFrameHost* rfh = GetPendingMainFrame();
163 if (!rfh) 168 if (!rfh)
164 rfh = old_rfh; 169 rfh = old_rfh;
165 170
166 int page_id = entry->GetPageID(); 171 int page_id = entry->GetPageID();
167 if (page_id == -1) { 172 if (page_id == -1) {
168 // It's a new navigation, assign a never-seen page id to it. 173 // It's a new navigation, assign a never-seen page id to it.
169 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1; 174 page_id = GetMaxPageIDForSiteInstance(rfh->GetSiteInstance()) + 1;
170 } 175 }
171 176
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 } 261 }
257 262
258 void TestWebContents::ShowCreatedWidget(int route_id, 263 void TestWebContents::ShowCreatedWidget(int route_id,
259 const gfx::Rect& initial_pos) { 264 const gfx::Rect& initial_pos) {
260 } 265 }
261 266
262 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { 267 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) {
263 } 268 }
264 269
265 } // namespace content 270 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698