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

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

Issue 743803002: Avoid stale navigation requests without excessive page id knowledge in the renderer process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update Created 6 years 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/test/test_web_contents.h ('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 15 matching lines...) Expand all
26 #include "content/test/browser_side_navigation_test_utils.h" 26 #include "content/test/browser_side_navigation_test_utils.h"
27 #include "content/test/test_navigation_url_loader.h" 27 #include "content/test/test_navigation_url_loader.h"
28 #include "content/test/test_render_view_host.h" 28 #include "content/test/test_render_view_host.h"
29 #include "ui/base/page_transition_types.h" 29 #include "ui/base/page_transition_types.h"
30 30
31 namespace content { 31 namespace content {
32 32
33 TestWebContents::TestWebContents(BrowserContext* browser_context) 33 TestWebContents::TestWebContents(BrowserContext* browser_context)
34 : WebContentsImpl(browser_context, NULL), 34 : WebContentsImpl(browser_context, NULL),
35 delegate_view_override_(NULL), 35 delegate_view_override_(NULL),
36 expect_set_history_length_and_prune_(false), 36 expect_set_history_offset_and_length_(false),
37 expect_set_history_length_and_prune_site_instance_(NULL), 37 expect_set_history_offset_and_length_history_length_(0) {
38 expect_set_history_length_and_prune_history_length_(0),
39 expect_set_history_length_and_prune_min_page_id_(-1) {
40 } 38 }
41 39
42 TestWebContents* TestWebContents::Create(BrowserContext* browser_context, 40 TestWebContents* TestWebContents::Create(BrowserContext* browser_context,
43 SiteInstance* instance) { 41 SiteInstance* instance) {
44 TestWebContents* test_web_contents = new TestWebContents(browser_context); 42 TestWebContents* test_web_contents = new TestWebContents(browser_context);
45 test_web_contents->Init(WebContents::CreateParams(browser_context, instance)); 43 test_web_contents->Init(WebContents::CreateParams(browser_context, instance));
46 return test_web_contents; 44 return test_web_contents;
47 } 45 }
48 46
49 TestWebContents::~TestWebContents() { 47 TestWebContents::~TestWebContents() {
50 EXPECT_FALSE(expect_set_history_length_and_prune_); 48 EXPECT_FALSE(expect_set_history_offset_and_length_);
51 } 49 }
52 50
53 TestRenderFrameHost* TestWebContents::GetMainFrame() { 51 TestRenderFrameHost* TestWebContents::GetMainFrame() {
54 return static_cast<TestRenderFrameHost*>(WebContentsImpl::GetMainFrame()); 52 return static_cast<TestRenderFrameHost*>(WebContentsImpl::GetMainFrame());
55 } 53 }
56 54
57 TestRenderViewHost* TestWebContents::GetRenderViewHost() const { 55 TestRenderViewHost* TestWebContents::GetRenderViewHost() const {
58 return static_cast<TestRenderViewHost*>( 56 return static_cast<TestRenderViewHost*>(
59 WebContentsImpl::GetRenderViewHost()); 57 WebContentsImpl::GetRenderViewHost());
60 } 58 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 opener_ = opener; 208 opener_ = opener;
211 AddDestructionObserver(opener_); 209 AddDestructionObserver(opener_);
212 } 210 }
213 211
214 void TestWebContents::AddPendingContents(TestWebContents* contents) { 212 void TestWebContents::AddPendingContents(TestWebContents* contents) {
215 // This is normally only done in WebContentsImpl::CreateNewWindow. 213 // This is normally only done in WebContentsImpl::CreateNewWindow.
216 pending_contents_[contents->GetRenderViewHost()->GetRoutingID()] = contents; 214 pending_contents_[contents->GetRenderViewHost()->GetRoutingID()] = contents;
217 AddDestructionObserver(contents); 215 AddDestructionObserver(contents);
218 } 216 }
219 217
220 void TestWebContents::ExpectSetHistoryLengthAndPrune( 218 void TestWebContents::ExpectSetHistoryOffsetAndLength(int history_offset,
221 const SiteInstance* site_instance, 219 int history_length) {
222 int history_length, 220 expect_set_history_offset_and_length_ = true;
223 int32 min_page_id) { 221 expect_set_history_offset_and_length_history_offset_ = history_offset;
224 expect_set_history_length_and_prune_ = true; 222 expect_set_history_offset_and_length_history_length_ = history_length;
225 expect_set_history_length_and_prune_site_instance_ =
226 static_cast<const SiteInstanceImpl*>(site_instance);
227 expect_set_history_length_and_prune_history_length_ = history_length;
228 expect_set_history_length_and_prune_min_page_id_ = min_page_id;
229 } 223 }
230 224
231 void TestWebContents::SetHistoryLengthAndPrune( 225 void TestWebContents::SetHistoryOffsetAndLength(int history_offset,
232 const SiteInstance* site_instance, int history_length, 226 int history_length) {
233 int32 min_page_id) { 227 EXPECT_TRUE(expect_set_history_offset_and_length_);
234 EXPECT_TRUE(expect_set_history_length_and_prune_); 228 expect_set_history_offset_and_length_ = false;
235 expect_set_history_length_and_prune_ = false; 229 EXPECT_EQ(expect_set_history_offset_and_length_history_offset_,
236 EXPECT_EQ(expect_set_history_length_and_prune_site_instance_.get(), 230 history_offset);
237 site_instance); 231 EXPECT_EQ(expect_set_history_offset_and_length_history_length_,
238 EXPECT_EQ(expect_set_history_length_and_prune_history_length_,
239 history_length); 232 history_length);
240 EXPECT_EQ(expect_set_history_length_and_prune_min_page_id_, min_page_id);
241 } 233 }
242 234
243 void TestWebContents::TestDidFinishLoad(const GURL& url) { 235 void TestWebContents::TestDidFinishLoad(const GURL& url) {
244 FrameHostMsg_DidFinishLoad msg(0, url); 236 FrameHostMsg_DidFinishLoad msg(0, url);
245 frame_tree_.root()->current_frame_host()->OnMessageReceived(msg); 237 frame_tree_.root()->current_frame_host()->OnMessageReceived(msg);
246 } 238 }
247 239
248 void TestWebContents::TestDidFailLoadWithError( 240 void TestWebContents::TestDidFailLoadWithError(
249 const GURL& url, 241 const GURL& url,
250 int error_code, 242 int error_code,
(...skipping 27 matching lines...) Expand all
278 } 270 }
279 271
280 void TestWebContents::ShowCreatedWidget(int route_id, 272 void TestWebContents::ShowCreatedWidget(int route_id,
281 const gfx::Rect& initial_pos) { 273 const gfx::Rect& initial_pos) {
282 } 274 }
283 275
284 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) { 276 void TestWebContents::ShowCreatedFullscreenWidget(int route_id) {
285 } 277 }
286 278
287 } // namespace content 279 } // namespace content
OLDNEW
« no previous file with comments | « content/test/test_web_contents.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698